EANBarCode.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #ifndef _EANBARCODE_H_
  3. #define _EANBARCODE_H_
  4. //////////////////////////////////////////////////
  5. // //
  6. // http://www.barcodeisland.com/ean13.phtml //
  7. // //
  8. //////////////////////////////////////////////////
  9. #define MAX_BARCODE_LENGTH 13
  10. // binary representation of numbers in EAN
  11. extern char* szEANs [10];
  12. class CEANBarCode
  13. {
  14. protected:
  15. // data
  16. // the code
  17. char m_szCode[MAX_BARCODE_LENGTH+1];
  18. protected:
  19. // methods
  20. // Check the validity of a the code
  21. bool CheckCode(void);
  22. // Get a Number in the code by its position
  23. int GetAt(int Position);
  24. // Gets the binary string representing the left part of the code when even parity
  25. CString GetLeftEven(int Digit);
  26. // Gets the binary string representing the right part of the code
  27. CString GetRight(int Digit);
  28. // Gets the binary string representing the left part of the code when odd parity
  29. CString GetLeftOdd(int Digit);
  30. public:
  31. // Accessors
  32. void SetCode(CString Code);
  33. CString GetCode();
  34. public:
  35. // operations
  36. // Draws the code using the specified DC and the rectangle
  37. void Draw(CPaintDC &dc);
  38. public:
  39. CEANBarCode(void);
  40. ~CEANBarCode(void);
  41. private:
  42. // reverse a String
  43. void ReverseString(CString &str);
  44. };
  45. #endif