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

Delphi控件源码

开发平台:

Delphi

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "colordemou.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "fcColorCombo"
  8. #pragma link "fcCombo"
  9. #pragma link "fcDemoRichEdit"
  10. #pragma link "fcLabel"
  11. #pragma resource "*.dfm"
  12. TColorDemoForm *ColorDemoForm;
  13. //---------------------------------------------------------------------------
  14. __fastcall TColorDemoForm::TColorDemoForm(TComponent* Owner)
  15.         : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19. String StripTrailing(String s)
  20. {
  21.   int len1 = s.Length();
  22.   while ((len1 > 0) &&
  23.          ((s[len1] == ' ') || (s[len1] == 't'))) len1--;
  24.   s.SetLength(len1);
  25.   return(s);
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TColorDemoForm::CheckBox6Click(TObject *Sender)
  29. {
  30.   if (((TCheckBox *)Sender)->Checked == True){
  31.     fcColorCombo1->AutoDropDown = True;
  32.   } else fcColorCombo1->AutoDropDown = False;
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TColorDemoForm::fcColorCombo1Change(TObject *Sender)
  36. {
  37.   Shape1->Brush->Color = ((TfcColorCombo *)Sender)->SelectedColor;
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TColorDemoForm::ColorAlignmentRadioClick(TObject *Sender)
  41. {
  42.   switch (((TRadioGroup *)Sender)->ItemIndex) {
  43.     case 0:fcColorCombo1->ColorAlignment = taLeftJustify; break;
  44.     case 1:fcColorCombo1->ColorAlignment = taRightJustify;
  45.   }
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TColorDemoForm::ButtonStyleRadioClick(TObject *Sender)
  49. {
  50.   switch (((TRadioGroup *)Sender)->ItemIndex) {
  51.     case 0:fcColorCombo1->ButtonStyle = Fccombo::cbsEllipsis; break;
  52.     case 1:fcColorCombo1->ButtonStyle = cbsDownArrow;
  53.   }
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TColorDemoForm::ShowMatchCheckboxClick(TObject *Sender)
  57. {
  58.   if (((TCheckBox *)Sender)->Checked == True) {
  59.     fcColorCombo1->ShowMatchText = True;
  60.   } else fcColorCombo1->ShowMatchText = False;
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TColorDemoForm::ShowButtonCheckboxClick(TObject *Sender)
  64. {
  65.   if (((TCheckBox *)Sender)->Checked == True) {
  66.     fcColorCombo1->ShowButton = True;
  67.   } else fcColorCombo1->ShowButton = False;
  68. }
  69. //---------------------------------------------------------------------------
  70. void __fastcall TColorDemoForm::SortByRadioClick(TObject *Sender)
  71. {
  72.   switch (((TRadioGroup *)Sender)->ItemIndex) {
  73.     case 0:fcColorCombo1->ColorListOptions->SortBy = csoNone; break;
  74.     case 1:fcColorCombo1->ColorListOptions->SortBy = csoByRGB; break;
  75.     case 2:fcColorCombo1->ColorListOptions->SortBy = csoByName; break;
  76.     case 3:fcColorCombo1->ColorListOptions->SortBy = csoByIntensity;
  77.   }
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TColorDemoForm::CheckBox1Click(TObject *Sender)
  81. {
  82.  //with (Sender as TCheckBox),fcColorCombo1.ColorListOptions do begin
  83.  if (((TCheckBox *)Sender)->Checked == True) {
  84.     switch (((TCheckBox *)Sender)->Tag) {
  85.       case 1:fcColorCombo1->ColorListOptions->Options << ccoShowCustomColors; break;
  86.       case 2:fcColorCombo1->ColorListOptions->Options << ccoShowSystemColors; break;
  87.       case 3:fcColorCombo1->ColorListOptions->Options << ccoShowStandardColors; break;
  88.       case 4:fcColorCombo1->ColorListOptions->Options << ccoShowGreyScale; break;
  89.       case 5:fcColorCombo1->ColorListOptions->Options << ccoShowColorNone;
  90.     }
  91.  } else {
  92.     switch (((TCheckBox *)Sender)->Tag) {
  93.       case 1:fcColorCombo1->ColorListOptions->Options >> ccoShowCustomColors; break;
  94.       case 2:fcColorCombo1->ColorListOptions->Options >> ccoShowSystemColors; break;
  95.       case 3:fcColorCombo1->ColorListOptions->Options >> ccoShowStandardColors; break;
  96.       case 4:fcColorCombo1->ColorListOptions->Options >> ccoShowGreyScale; break;
  97.       case 5:fcColorCombo1->ColorListOptions->Options >> ccoShowColorNone;
  98.     }
  99.  }
  100.    fcColorCombo1->ListBox->AllColors->Clear();
  101.    fcColorCombo1->RefreshList();
  102.    fcColorCombo1->ItemIndex = -1;
  103.    fcColorCombo1->Text = "";
  104. }
  105. //---------------------------------------------------------------------------
  106. void __fastcall TColorDemoForm::ColorWidthEditExit(TObject *Sender)
  107. {
  108.   if (StrToIntDef(((TEdit *)Sender)->Text,UpDown3->Max+1) > UpDown3->Max)
  109.      ((TEdit *)Sender)->Text = IntToStr(UpDown3->Max);
  110.   fcColorCombo1->ColorListOptions->ColorWidth = StrToInt(StripTrailing(ColorWidthEdit->Text));
  111.   fcColorCombo1->ListBox->ColorWidth = fcColorCombo1->ColorListOptions->ColorWidth;
  112.   fcColorCombo1->Invalidate();
  113. }
  114. //---------------------------------------------------------------------------
  115. void __fastcall TColorDemoForm::ItemHeightEditExit(TObject *Sender)
  116. {
  117.   if (StrToIntDef(((TEdit *)Sender)->Text,UpDown4->Max+1) > UpDown4->Max)
  118.      ((TEdit *)Sender)->Text = IntToStr(UpDown4->Max);
  119.    fcColorCombo1->ColorListOptions->ItemHeight = StrToInt(StripTrailing(ItemHeightEdit->Text));
  120.    fcColorCombo1->ListBox->ItemHeight = fcColorCombo1->ColorListOptions->ItemHeight;
  121.    fcColorCombo1->Invalidate();
  122. }
  123. //---------------------------------------------------------------------------
  124. void __fastcall TColorDemoForm::UpDown3Click(TObject *Sender,
  125.       TUDBtnType Button)
  126. {
  127.  ColorWidthEditExit(ColorWidthEdit);
  128. }
  129. //---------------------------------------------------------------------------
  130. void __fastcall TColorDemoForm::UpDown4Click(TObject *Sender,
  131.       TUDBtnType Button)
  132. {
  133.    ItemHeightEditExit(ItemHeightEdit);
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TColorDemoForm::DropDownCountEditExit(TObject *Sender)
  137. {
  138.   if (StrToIntDef(((TEdit *)Sender)->Text,UpDown2->Max+1) > UpDown2->Max)
  139.      ((TEdit *)Sender)->Text = IntToStr(UpDown2->Max);
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TColorDemoForm::DropDownWidthEditExit(TObject *Sender)
  143. {
  144.   if (StrToIntDef(((TEdit *)Sender)->Text,UpDown1->Max+1) > UpDown1->Max)
  145.      ((TEdit *)Sender)->Text = IntToStr(UpDown1->Max);
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TColorDemoForm::fcColorCombo1DropDown(TObject *Sender)
  149. {
  150.    ((TfcColorCombo *)Sender)->DropDownCount = StrToInt(StripTrailing(DropDownCountEdit->Text));
  151.    ((TfcColorCombo *)Sender)->DropDownWidth = StrToInt(StripTrailing(DropDownWidthEdit->Text));
  152.    ((TfcColorCombo *)Sender)->ColorListOptions->ColorWidth = StrToInt(StripTrailing(ColorWidthEdit->Text));
  153.    ((TfcColorCombo *)Sender)->ColorListOptions->ItemHeight = StrToInt(StripTrailing(ItemHeightEdit->Text));
  154.    ((TfcColorCombo *)Sender)->ListBox->ItemHeight = ((TfcColorCombo *)Sender)->ColorListOptions->ItemHeight;
  155.    ((TfcColorCombo *)Sender)->ListBox->ColorWidth = ((TfcColorCombo *)Sender)->ColorListOptions->ColorWidth;
  156. }
  157. //---------------------------------------------------------------------------