home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / KTMBEVEL / UNIT1.PAS < prev   
Pascal/Delphi Source File  |  1997-11-18  |  9KB  |  353 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5.  
  6. uses
  7.     {$IFDEF    Win32} Windows,    {$ELSE}WinTypes, WinProcs, {$ENDIF}Messages, SysUtils,
  8.     Classes, Graphics, Controls, Forms,    Dialogs, ExtCtrls, StdCtrls, Buttons,    Spin,
  9.     ktMBevel;
  10.  
  11.  
  12. type
  13.   TForm1 = class(TForm)
  14.     ktMultiBevel1: TktMultiBevel;
  15.     ktMultiBevel2: TktMultiBevel;
  16.     SpinEdit1: TSpinEdit;
  17.     SpinEdit2: TSpinEdit;
  18.     SpinEdit3: TSpinEdit;
  19.     SpinEdit4: TSpinEdit;
  20.     SpinEdit5: TSpinEdit;
  21.     Label1: TLabel;
  22.     Label2: TLabel;
  23.     Label3: TLabel;
  24.     Label4: TLabel;
  25.     Label5: TLabel;
  26.     Label6: TLabel;
  27.     Label7: TLabel;
  28.     Label8: TLabel;
  29.     Label9: TLabel;
  30.     Label10: TLabel;
  31.     Label11: TLabel;
  32.     Panel1: TPanel;
  33.     Panel2: TPanel;
  34.     Panel3: TPanel;
  35.     Panel4: TPanel;
  36.     ColorDialog1: TColorDialog;
  37.     RadioGroup1: TRadioGroup;
  38.     RadioGroup2: TRadioGroup;
  39.     RadioGroup3: TRadioGroup;
  40.     RadioGroup4: TRadioGroup;
  41.     RadioGroup5: TRadioGroup;
  42.     CheckBox1: TCheckBox;
  43.     ComboBox1: TComboBox;
  44.     ktBevelButton1: TktBevelButton;
  45.     Exit: TLabel;
  46.     Label12: TLabel;
  47.     SpinEdit6: TSpinEdit;
  48.     Label13: TLabel;
  49.     SpinEdit7: TSpinEdit;
  50.     RadioGroup6: TRadioGroup;
  51.  
  52.     procedure FormCreate(Sender: TObject);
  53.     procedure SpinEdit1Change(Sender: TObject);
  54.     procedure SpinEdit2Change(Sender: TObject);
  55.     procedure Panel1Click(Sender: TObject);
  56.     procedure Panel2Click(Sender: TObject);
  57.     procedure Panel3Click(Sender: TObject);
  58.     procedure RadioGroup1Click(Sender: TObject);
  59.     procedure RadioGroup2Click(Sender: TObject);
  60.     procedure RadioGroup3Click(Sender: TObject);
  61.     procedure RadioGroup4Click(Sender: TObject);
  62.     procedure CheckBox1Click(Sender: TObject);
  63.     procedure SpinEdit3Change(Sender: TObject);
  64.     procedure SpinEdit4Change(Sender: TObject);
  65.     procedure Panel4Click(Sender: TObject);
  66.     procedure ComboBox1Change(Sender: TObject);
  67.     procedure RadioGroup5Click(Sender: TObject);
  68.     procedure SpinEdit5Change(Sender: TObject);
  69.     procedure FormPaint(Sender: TObject);
  70.     procedure FormDestroy(Sender: TObject);
  71.     procedure ktBevelButton1Click(Sender: TObject);
  72.     procedure ktBevelButton1Exit(Sender: TObject);
  73.     procedure ktBevelButton1Enter(Sender: TObject);
  74.     procedure ktBevelButton1MouseDown(Sender: TObject);
  75.     procedure RadioGroup6Click(Sender: TObject);
  76.     procedure SpinEdit7Change(Sender: TObject);
  77.     procedure SpinEdit6Change(Sender: TObject);
  78.   private
  79.     { Private-Deklarationen }
  80.     Bmp: TBitmap;
  81.     SStyle: TShadowStyle;
  82.   public
  83.     { Public-Deklarationen }
  84.   end;
  85.  
  86. var
  87.   Form1: TForm1;
  88.  
  89. implementation
  90.  
  91. {$R *.DFM}  
  92.  
  93. procedure    TForm1.FormCreate(Sender:    TObject);
  94. begin
  95.     Bmp:= TBitmap.Create;
  96.   Bmp.LoadfromFile(ExtractFilePath(Application.ExeName) + 'Demo.bmp');
  97.     ktMultiBevel1.BevelWidth:= SpinEdit1.Value;
  98.     ktMultiBevel1.BorderWidth:=    SpinEdit2.Value;
  99.   ktMultiBevel1.ShadowOffsetX:=    SpinEdit3.Value;
  100.   ktMultiBevel1.ShadowOffsetY:=    SpinEdit4.Value;
  101.   ktMultiBevel1.EdgeSize:= SpinEdit5.Value;
  102.   ktMultiBevel1.ShadowDensity:= SpinEdit6.Value;
  103.     CheckBox1.Checked:= ktMultiBevel1.Shadowed;
  104.   ComboBox1.ItemIndex:= 2;
  105.   SStyle:= ktBevelButton1.ShadowStyle;
  106.   ktBevelButton1.ShadowStyle:= ssTransparent;
  107. end;
  108.  
  109. procedure    TForm1.SpinEdit1Change(Sender: TObject);
  110. begin
  111.     ktMultiBevel1.BevelWidth:= SpinEdit1.Value;
  112. end;
  113.  
  114. procedure    TForm1.SpinEdit2Change(Sender: TObject);
  115. begin
  116.     ktMultiBevel1.BorderWidth:=    SpinEdit2.Value;
  117. end;
  118.  
  119. procedure TForm1.SpinEdit3Change(Sender: TObject);
  120. begin
  121.   ktMultiBevel1.ShadowOffsetX:= SpinEdit3.Value;
  122. end;
  123.  
  124. procedure TForm1.SpinEdit4Change(Sender: TObject);
  125. begin
  126.   ktMultiBevel1.ShadowOffsetY:= SpinEdit4.Value;
  127. end;
  128.  
  129. procedure TForm1.SpinEdit5Change(Sender: TObject);
  130. begin
  131.     ktMultiBevel1.EdgeSize:= SpinEdit5.Value;
  132. end;
  133.  
  134. procedure TForm1.SpinEdit6Change(Sender: TObject);
  135. begin
  136.   if not ktMultiBevel1.DensityDepended then
  137.       ktMultiBevel1.ShadowDensity:= SpinEdit6.Value;
  138. end;
  139.  
  140. procedure TForm1.SpinEdit7Change(Sender: TObject);
  141. var v: Integer;
  142. begin
  143.     try
  144.       v:= SpinEdit7.Value;
  145.   except
  146.       SpinEdit7.Value:= 0;
  147.         v:= SpinEdit7.Value;
  148.   end;
  149.   ktMultiBevel1.ColorDensity:= v;
  150.   case v of
  151.       0            :    RadioGroup5.ItemIndex:= 2;
  152.     1..99    :    RadioGroup5.ItemIndex:= 1;
  153.     100        :    RadioGroup5.ItemIndex:= 0;
  154.   end;
  155.   if ktMultiBevel1.DensityDepended then SpinEdit6.Value:= Round(v * 60 / 100);
  156. end;
  157.  
  158. procedure TForm1.CheckBox1Click(Sender: TObject);
  159. begin
  160.   ktMultiBevel1.Shadowed:= CheckBox1.Checked;
  161. end;
  162.  
  163. procedure    TForm1.Panel1Click(Sender: TObject);
  164. begin
  165.   ColorDialog1.Color:= Panel1.Color;
  166.     if ColorDialog1.Execute    then
  167.     begin
  168.         Panel1.Color:= ColorDialog1.Color;
  169.         ktMultiBevel1.Color:=    Panel1.Color;
  170.         if ktMultiBevel1.ColorFixed    then
  171.         begin
  172.             Panel2.Color:= ktMultiBevel1.ColorHighlight;
  173.             Panel3.Color:= ktMultiBevel1.ColorShadow;
  174.         end;
  175.     end;
  176. end;
  177.  
  178. procedure    TForm1.Panel2Click(Sender: TObject);
  179. begin
  180.     ColorDialog1.Color:= Panel2.Color;
  181.     if ColorDialog1.Execute    then
  182.         if not ktMultiBevel1.ColorFixed    then
  183.         begin
  184.             Panel2.Color:= ColorDialog1.Color;
  185.             ktMultiBevel1.ColorHighlight:= Panel2.Color;
  186.         end;
  187. end;
  188.  
  189. procedure    TForm1.Panel3Click(Sender: TObject);
  190. begin
  191.     ColorDialog1.Color:= Panel3.Color;
  192.     if ColorDialog1.Execute    then
  193.         if not ktMultiBevel1.ColorFixed    then
  194.         begin
  195.             Panel3.Color:= ColorDialog1.Color;
  196.             ktMultiBevel1.ColorShadow:=    Panel3.Color;
  197.         end;
  198. end;
  199.  
  200. procedure TForm1.Panel4Click(Sender: TObject);
  201. begin
  202.   ColorDialog1.Color:= Panel4.Color;
  203.     if ColorDialog1.Execute    then
  204.   begin
  205.       Panel4.Color:= ColorDialog1.Color;
  206.     ktMultiBevel1.ShadowColor:=    Panel4.Color;
  207.   end;
  208. end;
  209.  
  210. procedure    TForm1.RadioGroup1Click(Sender:    TObject);
  211. begin
  212.     case RadioGroup1.ItemIndex of
  213.         0    :    ktMultiBevel1.Shape:=    bspBottomLine;
  214.         1    :    ktMultiBevel1.Shape:=    bspLeftLine;
  215.     2    : ktMultiBevel1.Shape:=    bspPortrait;
  216.         3    :    ktMultiBevel1.Shape:=    bspRect;
  217.         4    :    ktMultiBevel1.Shape:=    bspRightLine;
  218.         5    :    ktMultiBevel1.Shape:=    bspTopLine;
  219.     end;
  220.   RadioGroup3.Enabled:= ((RadioGroup1.ItemIndex = 2) or (RadioGroup1.ItemIndex = 3));
  221. end;
  222.  
  223. procedure    TForm1.RadioGroup2Click(Sender:    TObject);
  224. begin
  225.     case RadioGroup2.ItemIndex of
  226.         0    :    ktMultiBevel1.BevelOuter:= bstLowered;
  227.         1    :    ktMultiBevel1.BevelOuter:= bstNone;
  228.         2    :    ktMultiBevel1.BevelOuter:= bstRaised;
  229.     end;
  230. end;
  231.  
  232. procedure    TForm1.RadioGroup3Click(Sender:    TObject);
  233. begin
  234.     case RadioGroup3.ItemIndex of
  235.         0    :    ktMultiBevel1.BevelInner:= bstLowered;
  236.         1    :    ktMultiBevel1.BevelInner:= bstNone;
  237.         2    :    ktMultiBevel1.BevelInner:= bstRaised;
  238.     end;
  239. end;
  240.  
  241. procedure    TForm1.RadioGroup4Click(Sender:    TObject);
  242. begin
  243.     case RadioGroup4.ItemIndex of
  244.         0    :    begin
  245.                     ktMultiBevel1.ColorFixed:= True;
  246.                     Panel2.Color:= ktMultiBevel1.ColorHighlight;
  247.                     Panel3.Color:= ktMultiBevel1.ColorShadow;
  248.                 end;
  249.         1    :    ktMultiBevel1.ColorFixed:= False;
  250.     end;
  251. end;
  252.  
  253. procedure TForm1.RadioGroup5Click(Sender: TObject);
  254. begin
  255.     case RadioGroup5.ItemIndex of
  256.         0    :    ktMultiBevel1.Transparence:= trNone;
  257.     1    :    ktMultiBevel1.Transparence:= trSemi;
  258.         2    :    begin
  259.                 ktMultiBevel1.Transparence:= trTransparent;
  260.           CheckBox1.Checked:= False;
  261.             end;
  262.     end;
  263.   SpinEdit7.Value:= ktMultiBevel1.ColorDensity;
  264.   SpinEdit6.Value:= ktMultiBevel1.ShadowDensity;
  265. end;
  266.  
  267. procedure TForm1.ComboBox1Change(Sender: TObject);
  268. begin
  269.     with ktMultiBevel1 do
  270.   begin
  271.         case ComboBox1.ItemIndex of
  272.           0    :    ShadowStyle:= ssBlack;
  273.       1    :    ShadowStyle:= ssCopy;
  274.       2    : ShadowStyle:= ssDithered;
  275.       3    :    ShadowStyle:= ssMask;
  276.       4    :    ShadowStyle:= ssMaskNotPen;
  277.       5    :    ShadowStyle:= ssMerge;
  278.       6    :    ShadowStyle:= ssMergeNotPen;
  279.       7    :    ShadowStyle:= ssNot;
  280.       8    :    ShadowStyle:= ssNotAND;
  281.       9    :    ShadowStyle:= ssNotCopy;
  282.       10:    ShadowStyle:= ssNotMask;
  283.       11:    ShadowStyle:= ssNotMerge;
  284.       12:    ShadowStyle:= ssNotOR;
  285.       13:    ShadowStyle:= ssNotXor;
  286.       14:    ShadowStyle:= ssTransparent;
  287.       15:    ShadowStyle:= ssWhite;
  288.       16:    ShadowStyle:= ssXor;
  289.     end;
  290.   end;
  291. end;
  292.  
  293. procedure TForm1.FormPaint(Sender: TObject);
  294. var
  295.   x, y: Integer; r: TRect;
  296. begin
  297.     r:= rect(Width div 2,0,Width,Height);
  298.   Canvas.Brush.Color:= clBtnFace;
  299.   Canvas.FillRect(r);
  300.   y := 0;
  301.   while y < Height do
  302.   begin
  303.     x := 0;
  304.     while x < Width div 2 do
  305.     begin
  306.       Canvas.Draw(x, y, Bmp);
  307.       x := x + Bmp.Width;
  308.     end;
  309.     y := y + Bmp.Height;
  310.   end;
  311. end;
  312.  
  313. procedure TForm1.FormDestroy(Sender: TObject);
  314. begin
  315.     Bmp.Free;
  316. end;
  317.  
  318. procedure TForm1.ktBevelButton1Click(Sender: TObject);
  319. begin
  320.     Application.Terminate;
  321. end;
  322.  
  323. procedure TForm1.ktBevelButton1Exit(Sender: TObject);
  324. begin
  325.     ktBevelButton1.ShadowStyle:= ssTransparent;
  326. end;
  327.  
  328. procedure TForm1.ktBevelButton1Enter(Sender: TObject);
  329. begin
  330.     ktBevelButton1.ShadowStyle:= SStyle;
  331. end;
  332.  
  333. procedure TForm1.ktBevelButton1MouseDown(Sender: TObject);
  334. begin
  335.     ktBevelButton1.ShadowStyle:= ssTransparent;
  336. end;
  337.  
  338.  
  339.  
  340. procedure TForm1.RadioGroup6Click(Sender: TObject);
  341. begin
  342.   case RadioGroup6.ItemIndex of
  343.         0    :    begin
  344.                     ktMultiBevel1.DensityDepended:= True;
  345.              //        := ktMultiBevel1.ColorHighlight;
  346.                 end;
  347.         1    :    ktMultiBevel1.DensityDepended:= False;
  348.     end;
  349. end;
  350.  
  351. end.
  352.  
  353.