buttongroupdemo.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:11k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit buttongroupdemo;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   fcImager, ExtCtrls, fcClearPanel, fcButtonGroup, fcImgBtn, StdCtrls,
  6.   fcCombo, fcColorCombo, fcLabel, ComCtrls, fcTreeCombo, fccommon,
  7.   fcButton, fcShapeBtn, TypInfo, fcDemoRichEdit, ImgList;
  8. type
  9.   TButtonGroupDemo2 = class(TForm)
  10.     PageControl1: TPageControl;
  11.     TabSheet1: TTabSheet;
  12.     GroupBox1: TGroupBox;
  13.     fcLabel1: TfcLabel;
  14.     fcLabel2: TfcLabel;
  15.     fcLabel3: TfcLabel;
  16.     DownColorCombo: TfcColorCombo;
  17.     HotTrackColorCombo: TfcColorCombo;
  18.     FontColorCombo: TfcColorCombo;
  19.     TabSheet2: TTabSheet;
  20.     fcLabel4: TfcLabel;
  21.     ImageList1: TImageList;
  22.     TabSheet3: TTabSheet;
  23.     TabSheet4: TTabSheet;
  24.     TabSheet5: TTabSheet;
  25.     TabSheet6: TTabSheet;
  26.     RichEdit6: TRichEdit;
  27.     GroupBox2: TGroupBox;
  28.     ShapeCombo: TfcTreeCombo;
  29.     fcLabel5: TfcLabel;
  30.     GroupBox4: TGroupBox;
  31.     ShapeBtnGroup1: TfcButtonGroup;
  32.     OrientationCombo: TfcTreeCombo;
  33.     fcLabel10: TfcLabel;
  34.     HotTrackBtnGroup: TfcButtonGroup;
  35.     fcImager1: TfcImager;
  36.     RadioGroup1: TRadioGroup;
  37.     OvalSlantBtnGroup2: TfcButtonGroup;
  38.     DiamondBtnGroup: TfcButtonGroup;
  39.     fcImager2: TfcImager;
  40.     CheckBox1: TCheckBox;
  41.     OvalImageBtnGroup: TfcButtonGroup;
  42.     CheckBoxEditBtnGroup: TfcButtonGroup;
  43.     MultiColumnBtnGroup: TfcButtonGroup;
  44.     fcLabel12: TfcLabel;
  45.     Panel1: TPanel;
  46.     HorizontalShapeBtnGroup: TfcButtonGroup;
  47.     Choice1: TfcShapeBtn;
  48.     Choice2: TfcShapeBtn;
  49.     Choice3: TfcShapeBtn;
  50.     Choice4: TfcShapeBtn;
  51.     fcLabel9: TfcLabel;
  52.     Panel2: TPanel;
  53.     fcLabel11: TfcLabel;
  54.     VerticalShapeBtnGroup2: TfcButtonGroup;
  55.     Bevel1: TBevel;
  56.     CheckBox2: TCheckBox;
  57.     RadioGroup2: TRadioGroup;
  58.     Bevel2: TBevel;
  59.     UpColorCombo: TfcColorCombo;
  60.     fcLabel16: TfcLabel;
  61.     fcLabel17: TfcLabel;
  62.     HorizontalImageBtnGroup: TfcButtonGroup;
  63.     Shape1: TShape;
  64.     SlantOval1: TfcImageBtn;
  65.     SlantOval2: TfcImageBtn;
  66.     SlantOval3: TfcImageBtn;
  67.     SlantOval4: TfcImageBtn;
  68.     SlantOval5: TfcImageBtn;
  69.     SlantOval6: TfcImageBtn;
  70.     Right: TfcImageBtn;
  71.     Up: TfcImageBtn;
  72.     Left: TfcImageBtn;
  73.     Down: TfcImageBtn;
  74.     Diamond: TfcImageBtn;
  75.     Diamond2: TfcImageBtn;
  76.     Diamond3: TfcImageBtn;
  77.     Diamond4: TfcImageBtn;
  78.     OvalGold: TfcImageBtn;
  79.     OvalGold2: TfcImageBtn;
  80.     OvalGold3: TfcImageBtn;
  81.     RoundRectShape1: TfcShapeBtn;
  82.     RoundRectShape2: TfcShapeBtn;
  83.     RoundRectShape3: TfcShapeBtn;
  84.     Bar4: TfcImageBtn;
  85.     Bar3: TfcImageBtn;
  86.     Bar2: TfcImageBtn;
  87.     Bar1: TfcImageBtn;
  88.     MultiColumnBtnGroupfcShapeBtn1: TfcShapeBtn;
  89.     MultiColumnBtnGroupfcShapeBtn2: TfcShapeBtn;
  90.     MultiColumnBtnGroupfcShapeBtn3: TfcShapeBtn;
  91.     MultiColumnBtnGroupfcShapeBtn4: TfcShapeBtn;
  92.     MultiColumnBtnGroupfcShapeBtn5: TfcShapeBtn;
  93.     MultiColumnBtnGroupfcShapeBtn6: TfcShapeBtn;
  94.     MultiColumnBtnGroupfcShapeBtn7: TfcShapeBtn;
  95.     MultiColumnBtnGroupfcShapeBtn8: TfcShapeBtn;
  96.     MultiColumnBtnGroupfcShapeBtn9: TfcShapeBtn;
  97.     ShapeBtnGroup1fcShapeBtn1: TfcShapeBtn;
  98.     ShapeBtnGroup1fcShapeBtn2: TfcShapeBtn;
  99.     ShapeBtnGroup1fcShapeBtn3: TfcShapeBtn;
  100.     ShapeBtnGroup1fcShapeBtn4: TfcShapeBtn;
  101.     ShapeBtnGroup1fcShapeBtn5: TfcShapeBtn;
  102.     CheckboxButtonEdt: TfcImageBtn;
  103.     CheckBoxBtnEdit2: TfcImageBtn;
  104.     CheckBoxBtnEdit3: TfcImageBtn;
  105.     fcDemoRichEdit1: TfcDemoRichEdit;
  106.     fcDemoRichEdit2: TfcDemoRichEdit;
  107.     fcDemoRichEdit3: TfcDemoRichEdit;
  108.     fcDemoRichEdit4: TfcDemoRichEdit;
  109.     fcDemoRichEdit5: TfcDemoRichEdit;
  110.     fcImager3: TfcImager;
  111.     procedure HotTrackBtnGroupChange(ButtonGroup: TfcCustomButtonGroup;
  112.       OldSelected, Selected: TfcButtonGroupItem);
  113.     procedure DownColorComboChange(Sender: TObject);
  114.     procedure FontColorComboChange(Sender: TObject);
  115.     procedure ShapeComboChange(Sender: TObject);
  116.     procedure FormShow(Sender: TObject);
  117.     procedure OrientationComboChange(Sender: TObject);
  118.     procedure RadioGroup1Click(Sender: TObject);
  119.     procedure CheckBox1Click(Sender: TObject);
  120.     procedure fcButtonGroup3Item1MouseEnter(Sender: TObject);
  121.     procedure fcButtonGroup3Item1MouseLeave(Sender: TObject);
  122.     procedure OvalSlantBtnGroup2Change(ButtonGroup: TfcCustomButtonGroup;
  123.       OldSelected, Selected: TfcButtonGroupItem);
  124.     procedure CheckBox2Click(Sender: TObject);
  125.     procedure RadioGroup2Click(Sender: TObject);
  126.     procedure UpColorComboChange(Sender: TObject);
  127.     procedure DownDitherColorComboChange(Sender: TObject);
  128.     procedure HorizontalImageBtnGroupChange(ButtonGroup: TfcCustomButtonGroup;
  129.       OldSelected, Selected: TfcButtonGroupItem);
  130.     procedure SlantOval1MouseEnter(Sender: TObject);
  131.     procedure SlantOval1MouseLeave(Sender: TObject);
  132.   private
  133.     { Private declarations }
  134.   public
  135.     { Public declarations }
  136.   end;
  137. var
  138.   ButtonGroupDemo2: TButtonGroupDemo2;
  139. implementation
  140. {$R *.DFM}
  141. procedure TButtonGroupDemo2.HotTrackBtnGroupChange(
  142.   ButtonGroup: TfcCustomButtonGroup; OldSelected,
  143.   Selected: TfcButtonGroupItem);
  144. begin
  145.   //Restore Old Selected Color
  146.   if (OldSelected <> nil) and (OldSelected.Button <> nil) then
  147.      OldSelected.Button.Color := UpColorCombo.SelectedColor;
  148.   //Set New Down Color
  149.   if DownColorCombo.SelectedColor <> clNullColor then
  150.      Selected.Button.Color := DownColorCombo.SelectedColor;
  151. end;
  152. procedure TButtonGroupDemo2.DownColorComboChange(Sender: TObject);
  153. begin
  154.   if (HotTrackBtnGroup.Selected <> nil) then
  155.      HotTrackBtnGroup.Selected.Button.Color :=
  156.         (Sender as TfcColorCombo).SelectedColor;
  157. end;
  158. procedure TButtonGroupDemo2.FontColorComboChange(Sender: TObject);
  159. var i:integer;
  160. begin
  161.   for i:= 0 to HotTrackBtnGroup.ButtonItems.Count-1 do
  162.      HotTrackBtnGroup.ButtonItems[i].Button.Font.Color :=
  163.         (Sender as TfcColorCombo).SelectedColor;
  164. end;
  165. procedure TButtonGroupDemo2.ShapeComboChange(Sender: TObject);
  166. var i:integer;
  167. begin
  168.   for i:= 0 to ShapeBtnGroup1.ButtonItems.Count-1 do
  169.     with (Sender as TfcTreeCombo).TreeView.Selected,
  170.          ShapeBtnGroup1.ButtonItems[i].Button as TfcShapeBtn do
  171.     case index of
  172.        0:Shape := bsArrow;
  173.        1:Shape := bsDiamond;
  174.        2:Shape := bsEllipse;
  175.        3:Shape := bsRect;
  176.        4:Shape := bsRoundRect;
  177.        5:Shape := bsStar;
  178.        6:Shape := bsTriangle;
  179.     end;
  180.   with (Sender as TfcTreeCombo).TreeView.Selected do
  181.     OrientationCombo.enabled:= (index=0) or (index=5) or (index=6);
  182. end;
  183. procedure TButtonGroupDemo2.FormShow(Sender: TObject);
  184. begin
  185.    ShapeCombo.Text := 'RoundRect';
  186.    OrientationCombo.Text := 'Right';
  187.    if ((GetDeviceCaps(Canvas.Handle, BITSPIXEL) *
  188.         GetDeviceCaps(Canvas.Handle, PLANES)) <= 8) then begin
  189.      fcImager1.Visible := False;
  190.      fcImager2.Visible := False;
  191.    end;
  192.    PageControl1.ActivePage := TabSheet1;
  193. end;
  194. procedure TButtonGroupDemo2.OrientationComboChange(Sender: TObject);
  195. var i:integer;
  196.     orientation: TfcShapeOrientation;
  197. begin
  198.   with (Sender as TfcTreecombo).TreeView do begin
  199.      if (Selected=nil) then exit;
  200.      for i:= 0 to ShapeBtnGroup1.ButtonItems.Count-1 do
  201.      begin
  202.         orientation:=  TfcShapeOrientation(
  203.               GetEnumValue(TypeInfo(TfcShapeOrientation), Selected.StringData));
  204.         TfcShapeBtn(ShapeBtnGroup1.ButtonItems[i].Button).Orientation := orientation;
  205.      end;
  206.   end;
  207. {  with (Sender as TfcTreeCombo).TreeView.Selected,
  208.        fcButtonGroup2.Items[i].Button as TfcShapeBtn do
  209.     case index of
  210.        0:Orientation := soRight;
  211.        1:Orientation := soUp;
  212.        2:Orientation := soLeft;
  213.        3:Orientation := soDown;
  214.     end;}
  215. end;
  216. procedure TButtonGroupDemo2.RadioGroup1Click(Sender: TObject);
  217. var i:integer;
  218. begin
  219.   for i:=0 to ShapeBtnGroup1.ButtonItems.Count-1 do
  220.      TfcShapeBtn(ShapeBtnGroup1.ButtonItems[i].Button).Down := False;
  221.   case ((Sender as TRadioGroup).ItemIndex) of
  222.   0:begin
  223.     ShapeBtnGroup1.ClickStyle := bcsRadioGroup;
  224.     ShapeBtnGroup1.AutoBold := True;
  225.     end;
  226.   1:begin
  227.     ShapeBtnGroup1.ClickStyle := bcsCheckList;
  228.     ShapeBtnGroup1.AutoBold := False;
  229.     end;
  230.   2:begin
  231.     ShapeBtnGroup1.ClickStyle := bcsClick;
  232.     ShapeBtnGroup1.AutoBold := False;
  233.     end;
  234.   end;
  235. end;
  236. procedure TButtonGroupDemo2.CheckBox1Click(Sender: TObject);
  237. begin
  238.   if (Sender as TCheckBox).Checked then
  239.   begin
  240.      OvalImageBtnGroup.Transparent := True;
  241.      CheckBoxEditBtnGroup.Transparent := True
  242.   end
  243.   else begin
  244.      OvalImageBtnGroup.Transparent := False;
  245.      CheckBoxEditBtnGroup.Transparent := False;
  246.   end;
  247. end;
  248. procedure TButtonGroupDemo2.fcButtonGroup3Item1MouseEnter(Sender: TObject);
  249. begin
  250.   if not (Sender as TfcImageBtn).Down then
  251.      (Sender as TfcImageBtn).Color := clWhite;
  252. end;
  253. procedure TButtonGroupDemo2.fcButtonGroup3Item1MouseLeave(Sender: TObject);
  254. begin
  255.   if not (Sender as TfcImageBtn).Down then
  256.      (Sender as TfcImageBtn).Color := clNone;
  257. end;
  258. procedure TButtonGroupDemo2.OvalSlantBtnGroup2Change(
  259.   ButtonGroup: TfcCustomButtonGroup; OldSelected,
  260.   Selected: TfcButtonGroupItem);
  261. begin
  262.   if (OldSelected <> nil) and (OldSelected.Button <> nil) then
  263.      OldSelected.Button.Color := clNone;
  264.   Selected.Button.Color := clYellow;
  265. end;
  266. procedure TButtonGroupDemo2.CheckBox2Click(Sender: TObject);
  267. begin
  268.    if (Sender as TCheckBox).Checked then
  269.       VerticalShapeBtnGroup2.AutoBold := True
  270.    else VerticalShapeBtnGroup2.AutoBold := False;
  271. end;
  272. procedure TButtonGroupDemo2.RadioGroup2Click(Sender: TObject);
  273. var i:integer;
  274. begin
  275.   for i:=0 to VerticalShapeBtnGroup2.ButtonItems.Count-1 do
  276.      TfcShapeBtn(VerticalShapeBtnGroup2.ButtonItems[i].Button).Down := False;
  277.   case ((Sender as TRadioGroup).ItemIndex) of
  278.   0:begin
  279.     VerticalShapeBtnGroup2.ClickStyle := bcsRadioGroup;
  280.     CheckBox2.Enabled := True;
  281.     CheckBox2.Checked := True;
  282.     end;
  283.   1:begin
  284.     VerticalShapeBtnGroup2.ClickStyle := bcsCheckList;
  285.     CheckBox2.Checked := False;
  286.     CheckBox2.Enabled := False;
  287.     end;
  288.   2:begin
  289.     VerticalShapeBtnGroup2.ClickStyle := bcsClick;
  290.     CheckBox2.Checked := False;
  291.     CheckBox2.Enabled := False;
  292.     end;
  293.   end;
  294. end;
  295. procedure TButtonGroupDemo2.UpColorComboChange(Sender: TObject);
  296. var i:integer;
  297. begin
  298.   for i:= 0 to HotTrackBtnGroup.ButtonItems.Count-1 do
  299.      if not HotTrackBtnGroup.ButtonItems[i].selected then
  300.      TfcImageBtn(HotTrackBtnGroup.ButtonItems[i].Button).Color :=
  301.         (Sender as TfcColorCombo).SelectedColor;
  302. end;
  303. procedure TButtonGroupDemo2.DownDitherColorComboChange(Sender: TObject);
  304. var i:integer;
  305. begin
  306.   for i:= 0 to HotTrackBtnGroup.ButtonItems.Count-1 do
  307.      TfcImageBtn(HotTrackBtnGroup.ButtonItems[i].Button).DitherColor :=
  308.         (Sender as TfcColorCombo).SelectedColor;
  309. end;
  310. procedure TButtonGroupDemo2.HorizontalImageBtnGroupChange(
  311.   ButtonGroup: TfcCustomButtonGroup; OldSelected,
  312.   Selected: TfcButtonGroupItem);
  313. begin
  314.   if (OldSelected <> nil) and (OldSelected.Button <> nil) then
  315.      OldSelected.Button.Font.Color := clWhite;
  316.   Selected.Button.Font.Color := clBlack;
  317. end;
  318. procedure TButtonGroupDemo2.SlantOval1MouseEnter(Sender: TObject);
  319. begin
  320.   if not (Sender as TfcImageBtn).Down then
  321.      (Sender as TfcImageBtn).Color := HotTrackColorCombo.SelectedColor;
  322. end;
  323. procedure TButtonGroupDemo2.SlantOval1MouseLeave(Sender: TObject);
  324. begin
  325.   if not (Sender as TfcImageBtn).Down then
  326.      (Sender as TfcImageBtn).Color := UpColorCombo.SelectedColor;
  327. end;
  328. end.