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

  1.  
  2. {******************************************}
  3. {                                          }
  4. {           FastReport CLX v2.4            }
  5. {       Highlight attributes dialog        }
  6. {                                          }
  7. { Copyright (c) 1998-2001 by Tzyganenko A. }
  8. {                                          }
  9. {******************************************}
  10.  
  11. unit FR_Hilit;
  12.  
  13. interface
  14.  
  15. {$I FR.inc}
  16.  
  17. uses
  18.   SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs,
  19.   QStdCtrls, QButtons, FR_Ctrls, FR_Const, QExtCtrls;
  20.  
  21. type
  22.   TfrHilightForm = class(TForm)
  23.     GroupBox1: TGroupBox;
  24.     GroupBox2: TGroupBox;
  25.     CB1: TCheckBox;
  26.     CB2: TCheckBox;
  27.     CB3: TCheckBox;
  28.     Button3: TButton;
  29.     Button4: TButton;
  30.     ColorDialog1: TColorDialog;
  31.     SpeedButton1: TfrSpeedButton;
  32.     SpeedButton2: TfrSpeedButton;
  33.     RB1: TRadioButton;
  34.     RB2: TRadioButton;
  35.     GroupBox3: TGroupBox;
  36.     Edit1: TfrComboEdit;
  37.     Image1: TImage;
  38.     procedure SpeedButton1Click(Sender: TObject);
  39.     procedure SpeedButton2Click(Sender: TObject);
  40.     procedure FormActivate(Sender: TObject);
  41.     procedure RB1Click(Sender: TObject);
  42.     procedure FormCreate(Sender: TObject);
  43.     procedure Edit1ButtonClick(Sender: TObject);
  44.   private
  45.     { Private declarations }
  46.     procedure Localize;
  47.     procedure SetGlyph(Color: TColor; sb: TfrSpeedButton; n: Integer);
  48.   public
  49.     { Public declarations }
  50.     FontColor, FillColor: TColor;
  51.   end;
  52.  
  53.  
  54. implementation
  55.  
  56. uses FR_Desgn, FR_Class, FR_Expr, FR_Utils;
  57.  
  58. {$R *.xfm}
  59.  
  60. procedure TfrHilightForm.SetGlyph(Color: TColor; sb: TfrSpeedButton; n: Integer);
  61. var
  62.   b: TBitmap;
  63.   r: TRect;
  64.   i, j: Integer;
  65. begin
  66.   b := TBitmap.Create;
  67.   b.Width := 32;
  68.   b.Height := 16;
  69.   with b.Canvas do
  70.   begin
  71.     r := Rect(n * 32, 0, n * 32 + 32, 16);
  72.     CopyRect(Rect(0, 0, 32, 16), Image1.Picture.Bitmap.Canvas, r);
  73.     Pen.Color := Color;
  74.     for i := 0 to 15 do
  75.       for j := 12 to 14 do
  76.         DrawPoint(i, j);
  77. {    if Color = clNone then
  78.       for i := 1 to 14 do
  79.         Pixels[i, 13] := clBtnFace;}
  80.   end;
  81.   sb.Glyph.Assign(b);
  82.   sb.NumGlyphs := 2;
  83.   b.Free;
  84. end;
  85.  
  86. procedure TfrHilightForm.SpeedButton1Click(Sender: TObject);
  87. begin
  88.   ColorDialog1.Color := FontColor;
  89.   if ColorDialog1.Execute then
  90.   begin
  91.     FontColor := ColorDialog1.Color;
  92.     SetGlyph(FontColor, SpeedButton1, 0);
  93.   end;
  94. end;
  95.  
  96. procedure TfrHilightForm.SpeedButton2Click(Sender: TObject);
  97. begin
  98.   ColorDialog1.Color := FillColor;
  99.   if ColorDialog1.Execute then
  100.   begin
  101.     FillColor := ColorDialog1.Color;
  102.     SetGlyph(FillColor, SpeedButton2, 1);
  103.   end;
  104. end;
  105.  
  106. procedure TfrHilightForm.FormActivate(Sender: TObject);
  107. begin
  108.   SetGlyph(FontColor, SpeedButton1, 0);
  109.   SetGlyph(FillColor, SpeedButton2, 1);
  110.   if FillColor = clNone then
  111.     RB1.Checked := True else
  112.     RB2.Checked := True;
  113.   RB1Click(nil);
  114. end;
  115.  
  116. procedure TfrHilightForm.RB1Click(Sender: TObject);
  117. begin
  118.   SpeedButton2.Enabled := RB2.Checked;
  119.   if RB1.Checked then FillColor := clNone;
  120. end;
  121.  
  122. procedure TfrHilightForm.Edit1ButtonClick(Sender: TObject);
  123. begin
  124.   with TfrExprForm.Create(nil) do
  125.   begin
  126.     ExprMemo.Text := Edit1.Text;
  127.     if ShowModal = mrOk then
  128.       Edit1.Text := ExprMemo.Text;
  129.     Free;
  130.   end;
  131. end;
  132.  
  133. procedure TfrHilightForm.Localize;
  134. begin
  135.   Caption := S53520;
  136.   GroupBox3.Caption := S53521;
  137.   GroupBox1.Caption := S53522;
  138.   SpeedButton1.Caption := S53523;
  139.   CB1.Caption := S53524;
  140.   CB2.Caption := S53525;
  141.   CB3.Caption := S53526;
  142.   GroupBox2.Caption := S53527;
  143.   SpeedButton2.Caption := S53528;
  144.   RB1.Caption := S53529;
  145.   RB2.Caption := S53530;
  146.   Edit1.ButtonHint := S53575;
  147.   Button3.Caption := (SOk);
  148.   Button4.Caption := (SCancel);
  149. end;
  150.  
  151. procedure TfrHilightForm.FormCreate(Sender: TObject);
  152. begin
  153.   Localize;
  154. end;
  155.  
  156.  
  157. end.
  158.  
  159.