Barcode
Previous topic  First topic  Next topic






Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE BARCODE cName | (cVarName) | &(cExpression) 
      [ ; OF cWindow | (cVarName) | &(cExpression) ]
Parent.Name
  
A reference to the Parent Window
      [ ROW nRow ]
0
  
Row position on container window in pixels coordinates
      [ COL nCol ]
0
  
Col position on container window in pixels coordinates
      [ WIDTH nWidth ]
?
  
The desired width size of the Control in pixels
      [ HEIGHT nHeight ]
?
  
The desired height size of the Control in pixels
      [ BARWIDTH nBarWidth ]
1
  
This property is used to enlarge the bar width of barcode
      [ ROWBOTTOM nRow ]
n/a
  
Bottom Row position on container window in pixels coordinates. This property adjust the HEIGHT property according the ROW property.
      [ COLRIGHT nCol ]
n/a
  
Right Col position on container window in pixels coordinates. This property adjust the WIDTH property according the COL property.
      [ ENABLED .T. | .F. ]
.T.
  
Enable or Disable control
      [ VALUE cValue ]
NIL
  
A text expressions for the control
      [ TYPE cType ]
"Code128"
  
This is the type of BARCODE to generate, availables values are:
EAN13 (12 Digits + Checksum Digit)
EAN8 (7 Digits + Checksum Digit)
UPCA (not tested yet!)
UPCE (not tested yet!)
CODE39 (only digits)
ITF (not tested yet!)
MSI (not tested yet!)
CODABAR (not tested yet!)
CODE93 (not tested yet!)
CODE11 (not tested yet!)
CODE128 (any characters)
PDF417 (not tested yet!)
DATAMATRIX (not tested yet!)
QRCode (any characters)
      [ TRANSPARENT .T. | .F. ]
.T.
  Don't fill background control, set Transparent attibute
      [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  
Set foreground color (text color)
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ TOOLTIP cToolTip ]
NIL
  
Text for display into tooltip
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide control (like methods SHOW and HIDE)
      [ FORCEACTION .T. | .F. ]
.F.
  
It force the execution of the actions defined by methods like ACTION, ONENTER, ONCLICK, ONDBLCLICK, etc. when NOTABSTOP property was set '.T.'. This property is useful when application focus is over a control when a VALID clause and it doesn't permit lostfocus.
      [ PARENT cControlParent ]   
Get or Set the control name of parent widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the control. Go to to learn more about it.
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
END BARCODE 

Jump to Context Menu topic



Methods


Methods
Status
Default
Planned
Started
Ready
Comments
    HIDE
n/a
  
This method HIDE the control
    SHOW
n/a
  
This method SHOW the control
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the control to default (Qt_ArrowCursor). Go to to learn more about it.
    RELEASE
n/a
  
This method is used to destroy the control.
    GETBARCODE
n/a
  
Return the barcode text including the checksum digit
    SAVETOFILE cFileName
n/a
  
This method is used to save BARCODE control to file. The image file type will be chosen from fileName's suffix. Default image type is 'png' and allowed types are: 'bmp', 'jpeg', 'jpg' and 'png'. Warning: by default, the BARCODE control has a transparent BACKCOLOR, this can create an apparent completely black image if not specified a BACKCOLOR
    GETFINALWIDTH
n/a
  
Thise method is used to calculates the WIDTH of drawed area for the control (not the WIDTH of control, only the drawed area WIDTH)
    GETFINALHEIGHT
n/a
  
Thise method is used to calculates the HEIGHT of drawed area for the control (not the HEIGHT of control, only the drawed area HEIGHT)




Example:

File: d_barcode.prg


#include "marinas-gui.ch"

Function main()

   SET APPLSTYLE TO "MarinasLooks"

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for Barcode Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {223,242,253}
      MAIN .T.

      d_barcode_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

Return .T.


File: d_barcode_def.prg

#include "marinas-gui.ch"

Function d_barcode_def()

      CREATE LABEL
             ROW    24
             COL    30
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "A-Z 0-9 .$/+% (Code39):"
      END LABEL

      CREATE TEXTBOX Barcode_T1
             ROW    20
             COL    220
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "12345678"
             ONCHANGE mg_Set( "d_window" , "Barcode_L1" , "value" , mg_Get( "d_window" , "barcode_t1" , "value" ) )
      END TEXTBOX

      CREATE BUTTON Barcode_B1
             ROW    20
             COL    mg_get( "d_window" , "barcode_t1" , "colRight" ) + 10
             WIDTH 45
             HEIGHT  mg_get( "d_window" , "barcode_t1" , "height" )
             CAPTION "Save"
             TOOLTIP "Export Barcode to image file"
             ONCLICK Barcode__save_as( "d_window" , "barcode_L1" )
      END BUTTON

      CREATE BARCODE Barcode_L1
             ROW    70
             COL    20
             WIDTH  ( mg_Get( "d_Window" , "width" ) / 2 ) - 40
             HEIGHT 80
             BACKCOLOR {128,128,255}
             TYPE "Code39"
             VALUE mg_Get( "d_window" , "Barcode_T1" , "value" )
             BARWIDTH 2
             TOOLTIP "Barcode Code39"
      END BARCODE

      CREATE LABEL
             ROW   184
             COL    45
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "12 numbers (EAN13):"
      END LABEL

      CREATE TEXTBOX Barcode_T2
             ROW   180
             COL   220
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "123456789012"
             MAXLENGTH 12
             ONCHANGE mg_Set( "d_window" , "Barcode_L2" , "value" , mg_Get( "d_window" , "barcode_t2" , "value" ) )
      END TEXTBOX

      CREATE BUTTON Barcode_B2
             ROW    mg_get( "d_window" , "barcode_t2" , "row" )
             COL    mg_get( "d_window" , "barcode_t2" , "colRight" ) + 10
             WIDTH 45
             HEIGHT  mg_get( "d_window" , "barcode_t2" , "height" )
             CAPTION "Save"
             TOOLTIP "Export Barcode to image file"
             ONCLICK Barcode__save_as( "d_window" , "barcode_L2" )
      END BUTTON

      CREATE BARCODE Barcode_L2
             ROW   230
             COL   100
             HEIGHT 80
             BACKCOLOR {255,255,255}
             TYPE "EAN13"
             BARWIDTH 2
             WIDTH mg_BarcodeGetFinalWidth( "123456789012" , mg_get( "d_window" , "barcode_l2" , "Type" ) , mg_get( "d_window" , "barcode_l2" , "barwidth" ) )
             VALUE mg_Get( "d_window" , "Barcode_T2" , "value" )
             TOOLTIP "Barcode EAN13"
      END BARCODE

      CREATE LABEL
             ROW    350
             COL    35
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "Alphanumeric (Code128):"
      END LABEL

      CREATE TEXTBOX Barcode_T4
             ROW    346
             COL    220
             WIDTH  ( mg_Get( "d_window" , "width" ) / 2 ) - 220
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "www.marinas-gui.org"
             ONCHANGE mg_Set( "d_window" , "Barcode_L4" , "value" , mg_Get( "d_window" , "barcode_t4" , "value" ) )
      END TEXTBOX

      CREATE BUTTON Barcode_B4
             ROW    mg_get( "d_window" , "barcode_t4" , "row" )
             COL    mg_get( "d_window" , "barcode_t4" , "colRight" ) + 10
             WIDTH 45
             HEIGHT  mg_get( "d_window" , "barcode_t4" , "height" )
             CAPTION "Save"
             TOOLTIP "Export Barcode to image file"
             ONCLICK Barcode__save_as( "d_window" , "barcode_L4" )
      END BUTTON

      CREATE BARCODE Barcode_L4
             ROW    380
             COL    20
             COLRIGHT  ( mg_Get( "d_window" , "width" ) / 2 ) + 90
             HEIGHT 80
             TYPE "code128"
             VALUE mg_Get( "d_window" , "Barcode_T4" , "value" )
             BARWIDTH 1
             TOOLTIP "Barcode CODE128"
      END BARCODE

      CREATE LABEL
             ROW   20
             COL   480
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE "Any string (QRCode):"
      END LABEL

      CREATE EDITBOX Barcode_T3
             ROW   60
             COL   ( mg_Get( "d_window" , "width" ) / 2 ) + 10
             WIDTH ( mg_Get( "d_window" , "width" ) / 2 ) - 60
             HEIGHT ( mg_Get( "d_window" , "height" ) / 2 ) - 180
             FONTSIZE 12
             FONTCOLOR {55,140,68}
             VALUE hb_eol() + "Marinas-GUI web site: " + hb_eol() + hb_eol() + "www.marinas-gui.org"
             ONCHANGE mg_Set( "d_window" , "Barcode_L3" , "value" , mg_Get( "d_window" , "barcode_t3" , "value" ) )
      END EDITBOX

      CREATE BUTTON Barcode_B3
             ROW    mg_get( "d_window" , "barcode_t1" , "row" )
             WIDTH 45
             COL    mg_get( "d_window" , "barcode_t3" , "colRight" ) - mg_get( "d_window" , "barcode_b3" , "width" )
             HEIGHT  mg_get( "d_window" , "barcode_t1" , "height" )
             CAPTION "Save"
             TOOLTIP "Export Barcode to image file"
             ONCLICK Barcode__save_as( "d_window" , "barcode_L3" )
      END BUTTON

      CREATE BARCODE Barcode_L3
             ROW   mg_Get( "d_window" , "height" ) / 2 - 80
             COL   ( mg_Get( "d_window" , "width" ) / 2 ) + 100
             WIDTH ( mg_Get( "d_window" , "width" ) / 2 )
             HEIGHT ( mg_Get( "d_window" , "height" ) / 3 ) * 2
             FONTCOLOR {0,0,255}
             TYPE "QRcode"
             VALUE mg_Get( "d_window" , "Barcode_T3" , "value" )
             BARWIDTH 7
             TOOLTIP "QRCode"
      END BARCODE

Return .T.

STATIC FUNCTION Barcode__save_as( cWin , cControl )
   LOCAL cSaveFileName
   cSaveFileName := mg_PutFile( { { "Images","*.bmp;*.jpg;*.jpeg;*.png" } } , "Save Image As..." , HB_DirBase() , .F. , , .T. )
   if !empty( cSaveFileName )
      if mg_Do( cWin , cControl , "SaveToFile" , cSaveFileName )
         IF mg_msgYesNo( "Image writed successful to: " + cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) + hb_eol() + "Do you like to show it?" )
            OPEN FILE ( cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) )
         ENDIF
      else
         mg_log( "Error writing image to file: " + cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) )
      endif
   endif
RETURN NIL

FUNCTION Barcode_SampleSaveToFile()
   LOCAL cString
   LOCAL cSaveFileName
   IF !empty( cString := mg_InputDialog( "Generate QRCode to File" , "Enter String:" , "www.marinas-gui.org" ) )
      cSaveFileName := mg_PutFile( { { "Images","*.bmp;*.jpg;*.jpeg;*.png" } } , "Save Image As..." , HB_DirBase() , .F. , , .T. )
      if !empty( cSaveFileName )
         if mg_barcodeSaveToFile( cString , "QRCode" , cSaveFileName , NIL /* nWidth */ , NIL /* nHeight */ , 6 /* nBarWidth */ )
            IF mg_msgYesNo( "Image writed successful to: " + cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) + hb_eol() + "Do you like to show it?" )
               OPEN FILE ( cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) )
            ENDIF
         else
            mg_log( "Error writing image to file: " + cSaveFileName + if( empty( mg_FileNameOnlyExt( cSaveFileName ) ) , ".png" , "" ) )
         endif
      endif
   ENDIF
RETURN NIL




Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: March 09
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Jump to Donation Topic


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic