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

Delphi控件源码

开发平台:

Delphi

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "buttongroupdemo.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "fcButton"
  8. #pragma link "fcButtonGroup"
  9. #pragma link "fcClearPanel"
  10. #pragma link "fcColorCombo"
  11. #pragma link "fcCombo"
  12. #pragma link "fcDemoRichEdit"
  13. #pragma link "fcImager"
  14. #pragma link "fcImgBtn"
  15. #pragma link "fcLabel"
  16. #pragma link "fcShapeBtn"
  17. #pragma link "fcTreeCombo"
  18. #pragma link "fctreecombo"
  19. #pragma resource "*.dfm"
  20. TButtonGroupDemoForm *ButtonGroupDemoForm;
  21. //---------------------------------------------------------------------------
  22. __fastcall TButtonGroupDemoForm::TButtonGroupDemoForm(TComponent* Owner)
  23.         : TForm(Owner)
  24. {
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TButtonGroupDemoForm::SlantOval1MouseEnter(TObject *Sender)
  28. {
  29.   if (!((TfcImageBtn *)Sender)->Down)
  30.      ((TfcImageBtn *)Sender)->Color = HotTrackColorCombo->SelectedColor;
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TButtonGroupDemoForm::SlantOval1MouseLeave(TObject *Sender)
  34. {
  35.   if (!((TfcImageBtn *)Sender)->Down)
  36.      ((TfcImageBtn *)Sender)->Color = UpColorCombo->SelectedColor;
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TButtonGroupDemoForm::HotTrackBtnGroupChange(
  40.       TfcCustomButtonGroup *ButtonGroup, TfcButtonGroupItem *OldSelected,
  41.       TfcButtonGroupItem *Selected)
  42. {
  43.   //Restore Old Selected Color
  44.   if ((OldSelected != NULL) && (OldSelected->Button != NULL))
  45.      OldSelected->Button->Color = UpColorCombo->SelectedColor;
  46.   //Set New Down Color
  47.   if (DownColorCombo->SelectedColor != clNullColor)
  48.      Selected->Button->Color = DownColorCombo->SelectedColor;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TButtonGroupDemoForm::DownColorComboChange(TObject *Sender)
  52. {
  53.   if (HotTrackBtnGroup->Selected != NULL)
  54.      HotTrackBtnGroup->Selected->Button->Color =
  55.         ((TfcColorCombo *)Sender)->SelectedColor;
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TButtonGroupDemoForm::FontColorComboChange(TObject *Sender)
  59. {
  60.   for (int i= 0;i<=HotTrackBtnGroup->ButtonItems->Count-1;i++)
  61.      HotTrackBtnGroup->ButtonItems->Items[i]->Button->Font->Color =
  62.         ((TfcColorCombo *)Sender)->SelectedColor;
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TButtonGroupDemoForm::ShapeComboChange(TObject *Sender)
  66. {
  67.   for (int i= 0;i<=ShapeBtnGroup1->ButtonItems->Count-1;i++)
  68.     switch (((TfcTreeCombo *)Sender)->TreeView->Selected->Index) {
  69.      case 0:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsArrow; break;
  70.      case 1:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsDiamond; break;
  71.      case 2:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsEllipse; break;
  72.      case 3:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsRect; break;
  73.      case 4:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsRoundRect; break;
  74.      case 5:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsStar; break;
  75.      case 6:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Shape = bsTriangle;
  76.     }
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TButtonGroupDemoForm::OrientationComboChange(TObject *Sender)
  80. {
  81.   if (((TfcTreeCombo *)Sender)->TreeView->Selected==NULL) return;
  82.   for (int i= 0;i<=ShapeBtnGroup1->ButtonItems->Count-1;i++)
  83.     switch (((TfcTreeCombo *)Sender)->TreeView->Selected->Index) {
  84.       case 0:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Orientation = soRight; break;
  85.       case 1:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Orientation = soUp; break;
  86.       case 2:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Orientation = soLeft; break;
  87.       case 3:((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Orientation = soDown;
  88.     }
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TButtonGroupDemoForm::RadioGroup1Click(TObject *Sender)
  92. {
  93.   for (int i=0;i<=ShapeBtnGroup1->ButtonItems->Count-1;i++)
  94.       ((TfcShapeBtn *)(ShapeBtnGroup1->ButtonItems->Items[i]->Button))->Down = False;
  95.   switch (((TRadioGroup *)Sender)->ItemIndex) {
  96.   case 0: ShapeBtnGroup1->ClickStyle = bcsRadioGroup;
  97.           ShapeBtnGroup1->AutoBold = true;
  98.           break;
  99.   case 1: ShapeBtnGroup1->ClickStyle = bcsCheckList;
  100.           ShapeBtnGroup1->AutoBold = false;
  101.           break;
  102.   default: ShapeBtnGroup1->ClickStyle = bcsClick;
  103.            ShapeBtnGroup1->AutoBold = false;
  104.   }
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TButtonGroupDemoForm::CheckBox1Click(TObject *Sender)
  108. {
  109.   if (((TCheckBox *)Sender)->Checked) {
  110.      OvalImageBtnGroup->Transparent = True;
  111.      CheckBoxEditBtnGroup->Transparent = True;
  112.   }
  113.   else {
  114.      OvalImageBtnGroup->Transparent = False;
  115.      CheckBoxEditBtnGroup->Transparent = False;
  116.   }
  117. }
  118. //---------------------------------------------------------------------------
  119. void __fastcall TButtonGroupDemoForm::CheckBox2Click(TObject *Sender)
  120. {
  121.   if (((TCheckBox *)Sender)->Checked) {
  122.       VerticalShapeBtnGroup2->AutoBold = True;
  123.   }
  124.   else VerticalShapeBtnGroup2->AutoBold = False;
  125. }
  126. //---------------------------------------------------------------------------
  127. void __fastcall TButtonGroupDemoForm::RadioGroup2Click(TObject *Sender)
  128. {
  129.   for (int i=0;i<=VerticalShapeBtnGroup2->ButtonItems->Count-1;i++)
  130.       ((TfcShapeBtn *)(VerticalShapeBtnGroup2->ButtonItems->Items[i]->Button))->Down = False;
  131.   switch (((TRadioGroup *)Sender)->ItemIndex) {
  132.   case 0: VerticalShapeBtnGroup2->ClickStyle = bcsRadioGroup;
  133.           CheckBox2->Checked = True;
  134.           CheckBox2->Enabled = True;
  135.           break;
  136.   case 1: VerticalShapeBtnGroup2->ClickStyle = bcsCheckList;
  137.           CheckBox2->Checked = False;
  138.           CheckBox2->Enabled = False;
  139.           break;
  140.   default:
  141.      CheckBox2->Checked = False;
  142.      CheckBox2->Enabled = False;
  143.      VerticalShapeBtnGroup2->ClickStyle = bcsClick;
  144.   }
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TButtonGroupDemoForm::UpColorComboChange(TObject *Sender)
  148. {
  149.   for (int i= 0;i<=HotTrackBtnGroup->ButtonItems->Count-1;i++)
  150.      if (!HotTrackBtnGroup->ButtonItems->Items[i]->Selected)
  151.         ((TfcImageBtn*)(HotTrackBtnGroup->ButtonItems->Items[i]->Button))->Color =
  152.           ((TfcColorCombo *)Sender)->SelectedColor;
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall TButtonGroupDemoForm::HorizontalImageBtnGroupChange(
  156.       TfcCustomButtonGroup *ButtonGroup, TfcButtonGroupItem *OldSelected,
  157.       TfcButtonGroupItem *Selected)
  158. {
  159.   if ((OldSelected != NULL) && (OldSelected != NULL))
  160.      OldSelected->Button->Font->Color = clWhite;
  161.   Selected->Button->Font->Color = clBlack;
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TButtonGroupDemoForm::OvalSlantBtnGroup2Change(
  165.       TfcCustomButtonGroup *ButtonGroup, TfcButtonGroupItem *OldSelected,
  166.       TfcButtonGroupItem *Selected)
  167. {
  168.   if ((OldSelected != NULL) && (OldSelected != NULL))
  169.      OldSelected->Button->Color = clNone;
  170.   Selected->Button->Color = clYellow;
  171. }
  172. //---------------------------------------------------------------------------
  173. void __fastcall TButtonGroupDemoForm::FormShow(TObject *Sender)
  174. {
  175.    ShapeCombo->Text = "RoundRect";
  176.    OrientationCombo->Text = "Right";
  177.    if ((GetDeviceCaps(Canvas->Handle, BITSPIXEL) *
  178.         GetDeviceCaps(Canvas->Handle, PLANES)) <= 8) {
  179.      fcImager1->Visible = False;
  180.      fcImager2->Visible = False;
  181.    }
  182.    PageControl1->ActivePage = TabSheet1;
  183. }
  184. //---------------------------------------------------------------------------