home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kolekce / d6 / FRCLX.ZIP / SOURCE / FR_FmtEd.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-03  |  4KB  |  160 lines

  1.  
  2. {******************************************}
  3. {                                          }
  4. {           FastReport CLX v2.4            }
  5. {              Format editor               }
  6. {                                          }
  7. { Copyright (c) 1998-2001 by Tzyganenko A. }
  8. {                                          }
  9. {******************************************}
  10.  
  11. unit FR_FmtEd;
  12.  
  13. interface
  14.  
  15. {$I FR.inc}
  16.  
  17. uses
  18.   SysUtils, Classes, QGraphics, QControls, QForms, QDialogs, QStdCtrls, QExtCtrls;
  19.  
  20. type
  21.   TfrFmtForm = class(TForm)
  22.     GroupBox2: TGroupBox;
  23.     Button1: TButton;
  24.     Button2: TButton;
  25.     CatLB: TListBox;
  26.     TypeLB: TListBox;
  27.     Label3: TLabel;
  28.     FormatEdit: TEdit;
  29.     Label1: TLabel;
  30.     DecEdit: TEdit;
  31.     Label2: TLabel;
  32.     SplEdit: TEdit;
  33.     procedure FormActivate(Sender: TObject);
  34.     procedure SplEditEnter(Sender: TObject);
  35.     procedure FormCreate(Sender: TObject);
  36.     procedure CatLBClick(Sender: TObject);
  37.     procedure TypeLBClick(Sender: TObject);
  38.     procedure FormDeactivate(Sender: TObject);
  39.   private
  40.     { Private declarations }
  41.     procedure ShowPanels;
  42.     procedure Localize;
  43.   public
  44.     { Public declarations }
  45.     Format: Integer;
  46.     FormatStr: String;
  47.   end;
  48.  
  49.  
  50. implementation
  51.  
  52. {$R *.xfm}
  53.  
  54. uses FR_Class, FR_Const, FR_Utils;
  55.  
  56. const
  57.   CategCount = 5;
  58.   CategNames: array[0..CategCount - 1, 0..5] of string =
  59.     ((SCateg1, SFormat11, SFormat12, SFormat13, SFormat14, SFormat15),
  60.      (SCateg2, SFormat21, SFormat22, SFormat23, SFormat24, SFormat25),
  61.      (SCateg3, SFormat31, SFormat32, SFormat33, SFormat34, SFormat35),
  62.      (SCateg4, SFormat41, SFormat42, SFormat43, SFormat44, SFormat45),
  63.      (SCateg5, SFormat51, SFormat52, SFormat53, SFormat54, SFormat55));
  64.  
  65.  
  66. {$WARNINGS OFF}
  67. procedure TfrFmtForm.FormActivate(Sender: TObject);
  68. var
  69.   i: Integer;
  70. begin
  71.   CatLB.Items.Clear;
  72.   for i := 0 to CategCount - 1 do
  73.     CatLB.Items.Add(CategNames[i, 0]);
  74.   CatLB.ItemIndex := (Format and $0F000000) div $01000000;
  75.   CatLBClick(nil);
  76.   TypeLB.ItemIndex := (Format and $00FF0000) div $00010000;
  77.   ShowPanels;
  78. end;
  79.  
  80. procedure TfrFmtForm.FormDeactivate(Sender: TObject);
  81. var
  82.   c: WideChar;
  83. begin
  84.   if ModalResult = mrOk then
  85.   begin
  86.     Format := CatLB.ItemIndex * $01000000 + TypeLB.ItemIndex * $00010000 +
  87.       StrToIntDef(DecEdit.Text, 0) * $00000100;
  88.     c := ',';
  89.     if SplEdit.Text <> '' then
  90.       c := SplEdit.Text[1];
  91.     Format := Format + Ord(c);
  92.     if FormatEdit.Enabled then
  93.       FormatStr := FormatEdit.Text;
  94.   end;
  95. end;
  96.  
  97. procedure TfrFmtForm.ShowPanels;
  98. begin
  99.   frEnableControls([Label1, Label2, DecEdit, SplEdit], CatLB.ItemIndex = 1);
  100.   if DecEdit.Enabled then
  101.   begin
  102.     DecEdit.Text := IntToStr((Format and $0000FF00) div $00000100);
  103.     SplEdit.Text := Chr(Format and $000000FF);
  104.   end
  105.   else
  106.   begin
  107.     DecEdit.Text := '';
  108.     SplEdit.Text := '';
  109.   end;
  110.  
  111.   frEnableControls([Label3, FormatEdit], TypeLB.ItemIndex = 4);
  112.   if FormatEdit.Enabled then
  113.     FormatEdit.Text := FormatStr else
  114.     FormatEdit.Text := '';
  115. end;
  116.  
  117. procedure TfrFmtForm.CatLBClick(Sender: TObject);
  118. var
  119.   i: Integer;
  120.   s: String;
  121. begin
  122.   TypeLB.Items.Clear;
  123.   for i := 1 to 5 do
  124.   begin
  125.     s := CategNames[CatLB.ItemIndex, i];
  126.     if s <> '' then
  127.       TypeLB.Items.Add(s);
  128.   end;
  129.   TypeLB.ItemIndex := 0;
  130.   TypeLBClick(nil);
  131. end;
  132.  
  133. procedure TfrFmtForm.TypeLBClick(Sender: TObject);
  134. begin
  135.   ShowPanels;
  136. end;
  137.  
  138. procedure TfrFmtForm.SplEditEnter(Sender: TObject);
  139. begin
  140.   SplEdit.SelectAll;
  141. end;
  142. {$WARNINGS ON}
  143.  
  144. procedure TfrFmtForm.Localize;
  145. begin
  146.   Caption := S53420;
  147.   Label1.Caption := S53422;
  148.   Label2.Caption := S53423;
  149.   Label3.Caption := S53424;
  150.   Button1.Caption := SOk;
  151.   Button2.Caption := SCancel;
  152. end;
  153.  
  154. procedure TfrFmtForm.FormCreate(Sender: TObject);
  155. begin
  156.   Localize;
  157. end;
  158.  
  159. end.
  160.