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

Delphi控件源码

开发平台:

Delphi

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "ImagerMain.h"
  5. #include "PicEdt.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "fcButton"
  9. #pragma link "fcButtonGroup"
  10. #pragma link "fcClearPanel"
  11. #pragma link "fcColorCombo"
  12. #pragma link "fcCombo"
  13. #pragma link "fcDemoRichEdit"
  14. #pragma link "fcImager"
  15. #pragma link "fcImgBtn"
  16. #pragma link "fcOutlookBar"
  17. #pragma link "fcShapeBtn"
  18. #pragma link "fcStatusBar"
  19. #pragma resource "*.dfm"
  20. TImagerForm *ImagerForm;
  21. //---------------------------------------------------------------------------
  22. __fastcall TImagerForm::TImagerForm(TComponent* Owner)
  23.         : TForm(Owner)
  24. {
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TImagerForm::FormCreate(TObject *Sender)
  28. {
  29.   FDefaultsStream = new TMemoryStream;
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TImagerForm::FormDestroy(TObject *Sender)
  33. {
  34.   FDefaultsStream->Free();
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TImagerForm::FormShow(TObject *Sender)
  38. {
  39.   combo_DrawStyle->ItemIndex = 0;
  40.   fcImager1->BitmapOptions->BeginUpdate();
  41.   for (int i = 0; i < CheckListBox1->Items->Count; i++)
  42.     CheckListBox1->Checked[i] = (bool)(fcGetOrdProp(i < 5 ? (TPersistent *)fcImager1->BitmapOptions : (TPersistent *)fcImager1,
  43.       fcReplace(CheckListBox1->Items->Strings[i], " ", "")));
  44.   fcImager1->BitmapOptions->EndUpdate();
  45.   fcImager1->Invalidate();
  46.   if (FDefaultsStream->Size == 0) for (int i = 0; i < ComponentCount; i++)
  47.     if (!dynamic_cast<TfcCustomButtonGroup *>(Components[i]) &&
  48.         !dynamic_cast<TfcCustomColorCombo *>(Components[i]) &&
  49.         !dynamic_cast<TRichEdit *>(Components[i]))
  50.       FDefaultsStream->WriteComponent(Components[i]);
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TImagerForm::fcImager1Click(TObject *Sender)
  54. {
  55.   TfcPicEditor::ExecutePictureEditor(fcImager1->Picture->Graphic, fcImager1->Picture);
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TImagerForm::Track_LightnessChange(TObject *Sender)
  59. {
  60.   fcSetOrdProp(fcImager1->BitmapOptions, fcGetToken(((TTrackBar *)(Sender))->Name, '_', 1), ((TTrackBar *)(Sender))->Position);
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TImagerForm::combo_DrawStyleChange(TObject *Sender)
  64. {
  65.   fcImager1->DrawStyle = TfcImagerDrawStyle(((TComboBox *)(Sender))->ItemIndex);
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TImagerForm::combo_ColorChange(TObject *Sender)
  69. {
  70.   fcSetOrdProp(fcImager1->BitmapOptions, fcGetToken(((TComponent *)(Sender))->Name, '_', 1), ((TfcColorCombo *)(Sender))->SelectedColor);
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TImagerForm::SpeedButton1Click(TObject *Sender)
  74. {
  75.   FDefaultsStream->Position = 0;
  76.   for (int i = 0; i < ComponentCount; i++)
  77.     if (!dynamic_cast<TfcCustomButtonGroup *>(Components[i]) &&
  78.         !dynamic_cast<TfcCustomColorCombo *>(Components[i]) &&
  79.         !dynamic_cast<TRichEdit *>(Components[i]))
  80.       FDefaultsStream->ReadComponent(Components[i]);
  81.   combo_Color->SelectedColor = clNone;
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TImagerForm::CheckListBox1Click(TObject *Sender)
  85. {
  86.   fcImager1->BitmapOptions->BeginUpdate();
  87.   for (int i = 0; i < ((TCheckListBox *)(Sender))->Items->Count; i++)
  88.     fcSetOrdProp(i < 5 ? (TPersistent *)fcImager1->BitmapOptions : (TPersistent *)fcImager1,
  89.       fcReplace(((TCheckListBox *)(Sender))->Items->Strings[i], " ", ""),
  90.       int(((TCheckListBox *)(Sender))->Checked[i]));
  91.   fcImager1->BitmapOptions->EndUpdate();
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TImagerForm::edit_Rotation_AngleChange(TObject *Sender)
  95. {
  96.   fcSetOrdProp(fcImager1->BitmapOptions->Rotation, fcGetToken(((TEdit *)(Sender))->Name, '_', 2), StrToIntDef(((TEdit *)(Sender))->Text, 0));
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TImagerForm::edit_Rotation_XChange(TObject *Sender)
  100. {
  101.   fcSetOrdProp(fcImager1->BitmapOptions->Rotation, "Center" + fcGetToken(((TEdit *)(Sender))->Name, '_', 2), StrToIntDef(((TEdit *)(Sender))->Text, 0));
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TImagerForm::SpeedButton2Click(TObject *Sender)
  105. {
  106.   Graphics::TBitmap* ABitmap = new Graphics::TBitmap;
  107.   fcImager1->BitmapOptions->AlphaBlend->Bitmap->Transparent = false;
  108.   if (TfcPicEditor::ExecutePictureEditor(fcImager1->BitmapOptions->AlphaBlend->Bitmap, ABitmap))
  109.     fcImager1->BitmapOptions->AlphaBlend->Bitmap->Assign(ABitmap);
  110.   fcImager1->BitmapOptions->AlphaBlend->Bitmap->Transparent = fcImager1->BitmapOptions->AlphaBlend->Transparent;
  111.   ABitmap->Free();
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TImagerForm::edit_AlphaBlend_AmountChange(TObject *Sender)
  115. {
  116.   fcImager1->BitmapOptions->AlphaBlend->Bitmap->Transparent = checkbox_AlphaBlend_Transparent->Checked;
  117.   fcSetOrdProp(fcImager1->BitmapOptions->AlphaBlend, fcGetToken(((TEdit *)(Sender))->Name, '_', 2), StrToIntDef(((TEdit *)(Sender))->Text, 0));
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TImagerForm::checkbox_AlphaBlend_TransparentClick(
  121.       TObject *Sender)
  122. {
  123.   fcSetOrdProp(fcImager1->BitmapOptions->AlphaBlend,
  124.        fcGetToken(((TCheckBox *)(Sender))->Name, '_', 2), int(((TCheckBox *)(Sender))->Checked));
  125. }
  126. //---------------------------------------------------------------------------
  127. void __fastcall TImagerForm::edit_Wave_XDivChange(TObject *Sender)
  128. {
  129.   fcSetOrdProp(fcImager1->BitmapOptions->Wave, fcGetToken(((TEdit *)(Sender))->Name, '_', 2), StrToIntDef(((TEdit *)(Sender))->Text, 0));
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TImagerForm::checkbox_Wave_WrapClick(TObject *Sender)
  133. {
  134.   fcSetOrdProp(fcImager1->BitmapOptions->Wave, fcGetToken(((TCheckBox *)(Sender))->Name, '_', 2), int(((TCheckBox *)(Sender))->Checked));
  135. }
  136. //---------------------------------------------------------------------------