Browse Source

- parameters are now set in a visual hierarchy
- new parameter: font size, independent of barcode size
- checkbox to activate check character
- window dimensions now on the window title
- EAN13 string length commented out
- added CVS tags

Frederic G. Marand 15 years ago
parent
commit
3d81bd7ee5
4 changed files with 380 additions and 125 deletions
  1. 4 2
      obarcode.dpr
  2. 70 46
      obarcode.dsk
  3. 175 55
      ubarcodeform.dfm
  4. 131 22
      ubarcodeform.pas

+ 4 - 2
obarcode.dpr

@@ -1,13 +1,15 @@
 program obarcode;
 
+{CVS $Id: obarcode.dpr,v 1.2 2009-04-16 13:30:36 marand Exp $}
+
 uses
   Forms,
-  ubarcodeform in 'ubarcodeform.pas' {Form1};
+  ubarcodeform in 'ubarcodeform.pas' {fmBarCodeForm};
 
 {$R *.res}
 
 begin
   Application.Initialize;
-  Application.CreateForm(TForm1, Form1);
+  Application.CreateForm(TfmBarCodeForm, fmBarCodeForm);
   Application.Run;
 end.

+ 70 - 46
obarcode.dsk

@@ -1,17 +1,17 @@
 [Closed Files]
-File_0=SourceModule,'E:\Images\OpenSource\TurboPower\Systools403\source\StBarC.pas',0,1,1879,1,1907,0,0
-File_1=SourceModule,'E:\Src\D32\barcode\Code39 Elwood\ubarcodeform.pas',0,1,1,1,1,1,0
-File_2=SourceModule,'E:\Src\D32\barcode\Code39 Elwood\ubarcodeform.dfm',0,1,1,1,1,0,0
-File_3=SourceModule,'c:\program files\borland\delphi7\source\vcl\Graphics.pas',0,1,3953,18,3981,0,0
-File_4=SourceModule,'E:\Images\OpenSource\TurboPower\Systools403\readme.txt',0,1,31,38,57,0,0
-File_5=SourceModule,'E:\TMP\gestion\u_fmlot.pas',0,1,1,1,1,0,0
-File_6=SourceModule,'E:\TMP\gestion\SDIMAIN.PAS',0,1,1,1,1,1,1
-File_7=SourceModule,'E:\Src\OSInetOffice\Recif\ufmGetter.pas',0,1,40,3,64,0,0
-File_8=SourceModule,'E:\Src\OSInetOffice\Recif\uRecifCore.PAS',0,1,169,25,498,0,0
+File_0=SourceModule,'E:\Images\OpenSource\TurboPower\Systools403\source\StBase.pas',0,1,506,1,525,0,0
+File_1=SourceModule,'E:\Images\OpenSource\TurboPower\Systools403\source\StConst.pas',0,1,823,1,844,0,0
+File_2=SourceModule,'c:\program files\borland\delphi7\source\vcl\StdCtrls.pas',0,1,2890,2,2906,0,0
+File_3=SourceModule,'E:\Src\D32\barcode\Code39 Elwood\ubarcodeform.pas',0,1,1,1,1,1,0
+File_4=SourceModule,'E:\Src\D32\barcode\Code39 Elwood\ubarcodeform.dfm',0,1,1,1,1,0,0
+File_5=SourceModule,'c:\program files\borland\delphi7\source\vcl\Graphics.pas',0,1,3953,18,3981,0,0
+File_6=SourceModule,'E:\Images\OpenSource\TurboPower\Systools403\readme.txt',0,1,31,38,57,0,0
+File_7=SourceModule,'E:\TMP\gestion\u_fmlot.pas',0,1,1,1,1,0,0
+File_8=SourceModule,'E:\TMP\gestion\SDIMAIN.PAS',0,1,1,1,1,1,1
 
 [Modules]
 Module0=E:\Src\D32\barcode\obarcode\ubarcodeform.pas
-Module1=E:\Src\D32\barcode\obarcode\obarcode.dpr
+Module1=E:\Images\OpenSource\TurboPower\Systools403\source\StBarC.pas
 Count=2
 EditWindowCount=1
 
@@ -20,18 +20,24 @@ ModuleType=SourceModule
 FormState=1
 FormOnTop=0
 
-[E:\Src\D32\barcode\obarcode\obarcode.dpr]
+[E:\Images\OpenSource\TurboPower\Systools403\source\StBarC.pas]
 ModuleType=SourceModule
 FormState=0
 FormOnTop=0
 
-[E:\Src\D32\barcode\Code39 Elwood\ProjectGroup1.bpg]
+[E:\Src\D32\barcode\obarcode\obarcode.dpr]
+FormState=0
+FormOnTop=0
+SymbolFile=E:\Src\D32\barcode\obarcode\obarcode.dsm
+ModSinceCompile=0
+
+[C:\Program Files\Borland\Delphi7\Projects\ProjectGroup1.bpg]
 FormState=0
 FormOnTop=0
 
 [EditWindow0]
 ViewCount=2
-CurrentView=1
+CurrentView=0
 View0=0
 View1=1
 CodeExplorer=CodeExplorer@EditWindow0
@@ -50,23 +56,25 @@ ClientHeight=731
 LeftPanelSize=140
 LeftPanelClients=CodeExplorer@EditWindow0
 LeftPanelData=000004000000000000000000000000000000000000000000000100000000000000000C000000436F64654578706C6F726572FFFFFFFF
-RightPanelSize=0
+RightPanelSize=294
+RightPanelClients=ObjectTree,CallStackWindow
+RightPanelData=0000040000000000260100000000000002DB020000000000000100000000930000000E0000004F626A65637454726565566965770100000000260100000F00000043616C6C537461636B57696E646F77FFFFFFFF
 BottomPanelSize=0
 BottomPanelClients=MessageView@EditWindow0
-BottomPanelData=00000400010000000B0000004D657373616765566965770000000000000000000000000000000000FFFFFFFF
+BottomPanelData=00000400010000000B0000004D6573736167655669657700000000000000000000000000000000000100000000000000000B0000004D65737361676556696577FFFFFFFF
 
 [View0]
-Module=E:\Src\D32\barcode\obarcode\obarcode.dpr
-CursorX=1
-CursorY=1
-TopLine=1
+Module=E:\Src\D32\barcode\obarcode\ubarcodeform.pas
+CursorX=53
+CursorY=173
+TopLine=175
 LeftCol=1
 
 [View1]
-Module=E:\Src\D32\barcode\obarcode\ubarcodeform.pas
+Module=E:\Images\OpenSource\TurboPower\Systools403\source\StBarC.pas
 CursorX=1
-CursorY=1
-TopLine=1
+CursorY=100
+TopLine=78
 LeftCol=1
 
 [Watches]
@@ -86,8 +94,8 @@ Left=0
 Top=0
 Width=1920
 Height=105
-MaxLeft=-1
-MaxTop=-1
+MaxLeft=-4
+MaxTop=-4
 MaxWidth=1928
 MaxHeight=105
 ClientWidth=1920
@@ -109,6 +117,22 @@ TBDockHeight=303
 LRDockWidth=437
 Dockable=1
 
+[Components]
+Left=240
+Top=237
+Width=183
+Height=233
+Create=1
+Visible=0
+State=0
+MaxLeft=-1
+MaxTop=-1
+ClientWidth=175
+ClientHeight=209
+TBDockHeight=233
+LRDockWidth=183
+Dockable=1
+
 [CPUWindow]
 Create=1
 Visible=0
@@ -156,8 +180,8 @@ LRDockWidth=196
 Dockable=1
 SplitPos=104
 ArrangeBy=Name
-SelectedItem=Action
-ExpandedItems=Anchors,Brush,EditLabel,Pen
+SelectedItem=Font.Size
+ExpandedItems=Brush,EditLabel,Font,Pen
 HiddenCategories=
 
 [BreakpointWindow]
@@ -184,33 +208,33 @@ Column5Width=75
 
 [CallStackWindow]
 Create=1
-Visible=0
+Visible=1
 State=0
-Left=1161
-Top=565
-Width=294
-Height=161
+Left=147
+Top=12
+Width=147
+Height=719
 MaxLeft=-1
 MaxTop=-1
-ClientWidth=286
-ClientHeight=137
-TBDockHeight=161
+ClientWidth=147
+ClientHeight=719
+TBDockHeight=719
 LRDockWidth=294
 Dockable=1
 
 [ObjectTree]
 Create=1
-Visible=0
+Visible=1
 State=0
-Left=1
-Top=136
-Width=194
-Height=276
+Left=0
+Top=12
+Width=143
+Height=719
 MaxLeft=-1
 MaxTop=-1
-ClientWidth=186
-ClientHeight=252
-TBDockHeight=278
+ClientWidth=143
+ClientHeight=719
+TBDockHeight=719
 LRDockWidth=196
 Dockable=1
 
@@ -250,13 +274,13 @@ Dockable=1
 Create=1
 Visible=0
 State=0
-Left=-54
-Top=-772
-Width=443
+Left=12
+Top=0
+Width=1282
 Height=85
 MaxLeft=-1
 MaxTop=-1
-ClientWidth=443
+ClientWidth=1282
 ClientHeight=85
 TBDockHeight=85
 LRDockWidth=443

+ 175 - 55
ubarcodeform.dfm

@@ -1,9 +1,9 @@
-object Form1: TForm1
+object fmBarCodeForm: TfmBarCodeForm
   Left = 288
   Top = 240
   Width = 1608
   Height = 827
-  Caption = 'Form1'
+  ActiveControl = edValue
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -11,6 +11,7 @@ object Form1: TForm1
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   OldCreateOrder = False
+  OnCreate = FormCreate
   OnResize = FormResize
   PixelsPerInch = 96
   TextHeight = 13
@@ -18,7 +19,7 @@ object Form1: TForm1
     Left = 0
     Top = 0
     Width = 1600
-    Height = 768
+    Height = 749
     Align = alClient
     Caption = 'pnTop'
     TabOrder = 0
@@ -26,7 +27,7 @@ object Form1: TForm1
       Left = 1
       Top = 1
       Width = 1598
-      Height = 766
+      Height = 747
       Align = alClient
       Color = clWhite
       Font.Charset = ANSI_CHARSET
@@ -51,68 +52,187 @@ object Form1: TForm1
   end
   object pnBottom: TPanel
     Left = 0
-    Top = 768
+    Top = 749
     Width = 1600
     Height = 32
     Align = alBottom
     TabOrder = 1
-    object Button1: TButton
-      Left = 240
-      Top = 4
-      Width = 105
-      Height = 25
-      Caption = 'Vers presse papiers'
-      TabOrder = 1
-      OnClick = Button1Click
-    end
-    object ED_Valeur: TEdit
-      Left = 112
-      Top = 6
-      Width = 121
-      Height = 21
+    object pnB1: TPanel
+      Left = 1
+      Top = 1
+      Width = 176
+      Height = 30
+      Align = alLeft
+      Caption = 'pnB1'
       TabOrder = 0
-      Text = '3418556'
-      OnChange = ED_ValeurChange
+      object lbValue: TLabel
+        Left = 8
+        Top = 8
+        Width = 30
+        Height = 13
+        Caption = '&Value:'
+      end
+      object edValue: TEdit
+        Left = 42
+        Top = 4
+        Width = 121
+        Height = 21
+        TabOrder = 0
+        Text = '3418556'
+        OnChange = edValueChange
+      end
     end
-    object CheckBox1: TCheckBox
-      Left = 352
-      Top = 8
-      Width = 97
-      Height = 17
-      Caption = 'Inclure texte'
-      Checked = True
-      State = cbChecked
+    object pnB2: TPanel
+      Left = 177
+      Top = 1
+      Width = 288
+      Height = 30
+      Align = alLeft
+      TabOrder = 1
+      object lbSize: TLabel
+        Left = 8
+        Top = 8
+        Width = 51
+        Height = 13
+        Caption = 'Code &Size:'
+      end
+      object Label1: TLabel
+        Left = 136
+        Top = 8
+        Width = 45
+        Height = 13
+        Caption = '&Font size:'
+      end
+      object edSize: TEdit
+        Left = 64
+        Top = 4
+        Width = 45
+        Height = 21
+        TabOrder = 0
+        Text = '120'
+        OnChange = edSizeChange
+      end
+      object udBarWidth: TUpDown
+        Left = 109
+        Top = 4
+        Width = 15
+        Height = 21
+        Associate = edSize
+        Max = 1000
+        Increment = 10
+        Position = 120
+        TabOrder = 1
+      end
+      object edFontSize: TEdit
+        Left = 184
+        Top = 4
+        Width = 25
+        Height = 21
+        TabOrder = 2
+        Text = '48'
+        OnChange = edFontSizeChange
+      end
+      object udFotnSize: TUpDown
+        Left = 209
+        Top = 4
+        Width = 15
+        Height = 21
+        Associate = edFontSize
+        Position = 48
+        TabOrder = 3
+      end
+    end
+    object pnB3: TPanel
+      Left = 465
+      Top = 1
+      Width = 288
+      Height = 30
+      Align = alLeft
       TabOrder = 2
-      OnClick = CheckBox1Click
+      object lbFormat: TLabel
+        Left = 8
+        Top = 8
+        Width = 35
+        Height = 13
+        Caption = '&Format:'
+      end
+      object coBarCodeType: TComboBox
+        Left = 48
+        Top = 4
+        Width = 145
+        Height = 21
+        Style = csDropDownList
+        ItemHeight = 13
+        TabOrder = 0
+        OnChange = coBarCodeTypeChange
+      end
+      object coCode128Subsets: TComboBox
+        Left = 199
+        Top = 4
+        Width = 81
+        Height = 21
+        Style = csDropDownList
+        ItemHeight = 13
+        TabOrder = 1
+        Visible = False
+        OnChange = coCode128SubsetsChange
+      end
     end
-    object edWidth: TEdit
-      Left = 440
-      Top = 6
-      Width = 121
-      Height = 21
+    object pnB4: TPanel
+      Left = 753
+      Top = 1
+      Width = 208
+      Height = 30
+      Align = alLeft
       TabOrder = 3
-      Text = '120'
-      OnChange = edWidthChange
-    end
-    object udBarWidth: TUpDown
-      Left = 561
-      Top = 6
-      Width = 15
-      Height = 21
-      Associate = edWidth
-      Max = 1000
-      Increment = 10
-      Position = 120
-      TabOrder = 5
+      object cbShowCode: TCheckBox
+        Left = 8
+        Top = 8
+        Width = 81
+        Height = 17
+        Caption = 'Show &code'
+        Checked = True
+        State = cbChecked
+        TabOrder = 0
+        OnClick = cbShowCodeClick
+      end
+      object cbAddCheckChar: TCheckBox
+        Left = 104
+        Top = 8
+        Width = 97
+        Height = 17
+        Caption = 'Add chec&k char'
+        TabOrder = 1
+        OnClick = cbAddCheckCharClick
+      end
     end
-    object stWidth: TStaticText
-      Left = 8
-      Top = 8
-      Width = 40
-      Height = 17
-      BevelKind = bkSoft
-      Caption = 'stWidth'
+    object pnBLast: TPanel
+      Left = 961
+      Top = 1
+      Width = 638
+      Height = 30
+      Align = alClient
       TabOrder = 4
+      object Button1: TButton
+        Left = 5
+        Top = 2
+        Width = 105
+        Height = 25
+        Caption = 'C&opy to clipboard'
+        Default = True
+        TabOrder = 0
+        OnClick = Button1Click
+      end
     end
   end
+  object sb: TStatusBar
+    Left = 0
+    Top = 781
+    Width = 1600
+    Height = 19
+    Panels = <
+      item
+        Width = 60
+      end>
+  end
 end

+ 131 - 22
ubarcodeform.pas

@@ -4,64 +4,173 @@ interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, StBarC, ExtCtrls, ComCtrls;
+  Dialogs, StdCtrls, StBarC, ExtCtrls, ComCtrls, Typinfo;
 
 type
-  TForm1 = class(TForm)
+  TfmBarCodeForm = class(TForm)
     pnTop: TPanel;
     StBarCode1: TStBarCode;
     pnBottom: TPanel;
-    Button1: TButton;
-    ED_Valeur: TEdit;
-    CheckBox1: TCheckBox;
-    edWidth: TEdit;
+    sb: TStatusBar;
+    pnB1: TPanel;
+    lbValue: TLabel;
+    edValue: TEdit;
+    pnB2: TPanel;
+    lbSize: TLabel;
+    edSize: TEdit;
     udBarWidth: TUpDown;
-    stWidth: TStaticText;
+    pnB3: TPanel;
+    lbFormat: TLabel;
+    coBarCodeType: TComboBox;
+    coCode128Subsets: TComboBox;
+    pnB4: TPanel;
+    cbShowCode: TCheckBox;
+    cbAddCheckChar: TCheckBox;
+    pnBLast: TPanel;
+    Button1: TButton;
+    Label1: TLabel;
+    edFontSize: TEdit;
+    udFotnSize: TUpDown;
     procedure Button1Click(Sender: TObject);
-    procedure ED_ValeurChange(Sender: TObject);
-    procedure CheckBox1Click(Sender: TObject);
-    procedure edWidthChange(Sender: TObject);
+    procedure edValueChange(Sender: TObject);
+    procedure cbShowCodeClick(Sender: TObject);
+    procedure edSizeChange(Sender: TObject);
     procedure FormResize(Sender: TObject);
+    procedure FormCreate(Sender: TObject);
+    procedure coBarCodeTypeChange(Sender: TObject);
+    procedure cbAddCheckCharClick(Sender: TObject);
+    procedure coCode128SubsetsChange(Sender: TObject);
+    procedure edFontSizeChange(Sender: TObject);
   private
     { Déclarations privées }
+    name    : String;
+    version : String;
+    procedure buildBarCodeTypes();
+    procedure buildCode128Subsets();
+
   public
     { Déclarations publiques }
   end;
 
 var
-  Form1: TForm1;
+  fmBarCodeForm: TfmBarCodeForm;
 
 implementation
 
+uses StrUtils;
+
 {$R *.dfm}
 
-procedure TForm1.Button1Click(Sender: TObject);
+procedure TfmBarCodeForm.Button1Click(Sender: TObject);
 begin
 StBarCode1.CopyToClipboard ;
 end;
 
-procedure TForm1.ED_ValeurChange(Sender: TObject);
-begin
-StBarCode1.Code := ED_Valeur.Text ;
-end;
+procedure TfmBarCodeForm.edValueChange(Sender: TObject);
 
-procedure TForm1.CheckBox1Click(Sender: TObject);
+  var s : String;
+
+  begin
+  s := edValue.Text;
+{
+  if (coBarCodeType.ItemIndex = ord(bcEAN_13))
+  and (length (s) < 12) or (length(s) > 13) then
+    begin
+    s := '';
+    end;
+ }
+  StBarCode1.Code := s;
+  end;
+
+procedure TfmBarCodeForm.cbShowCodeClick(Sender: TObject);
 
 begin
 StBarCode1.ShowCode := (sender as TCheckBox).Checked;
 end;
 
-procedure TForm1.edWidthChange(Sender: TObject);
+procedure TfmBarCodeForm.edSizeChange(Sender: TObject);
 
   begin
   StBarCode1.BarWidth := StrToFloat((sender as TEdit).Text);
   end;
 
-procedure TForm1.FormResize(Sender: TObject);
+procedure TfmBarCodeForm.FormResize(Sender: TObject);
+  begin
+  self.Caption := self.name + ' - '
+    + IntToStr(StBarCode1.Width) + 'x' + IntToStr(StBarCode1.Height);
+  end;
+
+procedure TfmBarCodeForm.coBarCodeTypeChange(Sender: TObject);
+
+  var this : TComboBox;
+
+  begin
+  this := sender as TComboBox;
+  sb.SimpleText := 'Selected ' + IntToStr(this.ItemIndex);
+  coCode128Subsets.Visible := this.ItemIndex = ord(bcCode128);
+  StBarCode1.BarCodeType := TStBarCodeType(this.ItemIndex);
+  end;
+
+procedure TfmBarCodeForm.buildBarCodeTypes();
+
+  var i : Integer;
+      s : String;
+
+  begin
+  for i := ord(low(TstBarCodeType)) to ord(high(TstBarCodeType)) do
+    begin
+    s := getEnumName(typeInfo(TStBarCodeType), i);
+    s := Midstr(s, 3, 100);
+    coBarCodeType.Items.Add(s);
+    end;
+  coBarCodeType.ItemIndex := ord(bcCode39);
+  StBarCode1.BarCodeType := bcCode39;
+  end;
+
+procedure TfmBarCodeForm.buildCode128Subsets();
+
+  var i : Integer;
+      s : String;
+
+  begin
+  for i := ord(low(TStCode128CodeSubset)) to ord(high(TStCode128CodeSubset)) do
+    begin
+    s := getEnumName(typeInfo(TStCode128CodeSubset), i);
+    s := Midstr(s, 3, 100);
+    coCode128Subsets.Items.Add(s);
+    end;
+  coCode128Subsets.ItemIndex := ord(csCodeA);
+  coCode128Subsets.Visible := FALSE;
+  end;
+
+procedure TfmBarCodeForm.FormCreate(Sender: TObject);
+
+  begin
+  self.version := '$Id: ubarcodeform.pas,v 1.2 2009-04-16 13:30:36 marand Exp $';
+  self.name    := 'OSInet barcode generator';
+
+  sb.SimplePanel := True;
+  sb.SimpleText := self.name + ' - ' + self.version;
+
+  buildBarCodeTypes;
+  buildCode128Subsets;
+  end;
+
+procedure TfmBarCodeForm.cbAddCheckCharClick(Sender: TObject);
+
+  begin
+  StBarCode1.AddCheckChar := (sender as TCheckBox).Checked;
+  end;
+
+procedure TfmBarCodeForm.coCode128SubsetsChange(Sender: TObject);
+  begin
+  StBarCode1.Code128Subset := TStCode128CodeSubset((sender as TComboBox).ItemIndex);
+  end;
+
+procedure TfmBarCodeForm.edFontSizeChange(Sender: TObject);
+
   begin
-  stWidth.Caption := IntToStr(StBarCode1.Width)
-    + 'x'
-    + IntToStr(StBarCode1.Height);
+  StBarCode1.Font.Size := StrToInt(edFontSize.Text);
   end;
 
 end.