home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 5 / Komponety.exe / cgrid.h < prev    next >
C/C++ Source or Header  |  1998-02-09  |  5KB  |  124 lines

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1998 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. #if !defined(CColorGrdH)
  6. #define CColorGrdH
  7. //----------------------------------------------------------------------------
  8. #include <Menus.hpp>
  9. #include <ExtCtrls.hpp>
  10. #include <Controls.hpp>
  11. #include <Forms.hpp>
  12. #include <Graphics.hpp>
  13. #include <Classes.hpp>
  14. #include <Messages.hpp>
  15. #include <Windows.hpp>
  16. #include <System.hpp>
  17. #include <consts.hpp>
  18.  
  19. //-- type declarations -------------------------------------------------------
  20. enum TGridOrdering { go16x1, go8x2, go4x4, go2x8, go1x16 };
  21.  
  22. class PACKAGE TCColorGrid : public TCustomControl
  23. {
  24. private:
  25.     TPaletteEntry FPaletteEntries[20];
  26.     Boolean FClickEnablesColor;
  27.     Integer FForegroundIndex;
  28.     Integer FBackgroundIndex;
  29.     Boolean FForegroundEnabled;
  30.     Boolean FBackgroundEnabled;
  31.     Integer FSelection;
  32.     Integer FCellXSize;
  33.     Integer FCellYSize;
  34.     Integer FNumXSquares;
  35.     Integer FNumYSquares;
  36.     TGridOrdering FGridOrdering;
  37.     Boolean FHasFocus;
  38.     TNotifyEvent FOnChange;
  39.     TMouseButton FButton;
  40.     Boolean FButtonDown;
  41.     void __fastcall DrawSquare(Integer Which, Boolean ShowSelector);
  42.     void __fastcall DrawFgBg(void);
  43.     void __fastcall UpdateCellSizes(Boolean DoRepaint);
  44.     void __fastcall SetGridOrdering(TGridOrdering Value);
  45.     TColor __fastcall GetForegroundColor(void);
  46.     TColor __fastcall GetBackgroundColor(void);
  47.     void __fastcall SetForegroundIndex(Integer Value);
  48.     void __fastcall SetBackgroundIndex(Integer Value);
  49.     void __fastcall SetSelection(Integer Value);
  50.     void __fastcall EnableForeground(Boolean Value);
  51.     void __fastcall EnableBackground(Boolean Value);
  52.     MESSAGE void __fastcall WMSetFocus(TWMSetFocus &Message);
  53.     MESSAGE void __fastcall WMKillFocus(TWMKillFocus &Message);
  54.     MESSAGE void __fastcall WMGetDlgCode(TWMNoParams &Message);
  55.     MESSAGE void __fastcall WMSize(TWMSize &Message);
  56.     MESSAGE void __fastcall CMCtl3DChanged(TMessage &Message);
  57.     
  58. protected:
  59.     DYNAMIC void __fastcall KeyDown(Word &Key,  TShiftState Shift);
  60.     DYNAMIC void __fastcall MouseDown(TMouseButton Button,  TShiftState Shift, Integer X, Integer Y);
  61.     DYNAMIC void __fastcall MouseMove( TShiftState Shift, Integer X, Integer Y);
  62.     DYNAMIC void __fastcall MouseUp(TMouseButton Button,  TShiftState Shift, Integer X, Integer Y);
  63.     virtual void __fastcall CreateWnd(void);
  64.     virtual void __fastcall Paint(void);
  65.     virtual void __fastcall Change(void);
  66.     Integer __fastcall SquareFromPos(Integer X, Integer Y);
  67.     
  68. public:
  69.     __fastcall virtual TCColorGrid(TComponent *AOwner);
  70.     __fastcall TCColorGrid(HWND Parent): TCustomControl(Parent) {};
  71.     __property TColor ForegroundColor = {read=GetForegroundColor, nodefault};
  72.     __property TColor BackgroundColor = {read=GetBackgroundColor, nodefault};
  73.     
  74. __published:
  75.     __property Boolean ClickEnablesColor = {read=FClickEnablesColor, write=FClickEnablesColor, default=0
  76.         };
  77.     __property Ctl3D ;
  78.     __property DragCursor ;
  79.     __property DragMode ;
  80.     __property Enabled ;
  81.     __property TGridOrdering GridOrdering = {read=FGridOrdering, write=SetGridOrdering, default=2};
  82.     __property Integer ForegroundIndex = {read=FForegroundIndex, write=SetForegroundIndex, default=0};
  83.     __property Integer BackgroundIndex = {read=FBackgroundIndex, write=SetBackgroundIndex, default=0};
  84.     __property Boolean ForegroundEnabled = {read=FForegroundEnabled, write=EnableForeground, default=1}
  85.         ;
  86.     __property Boolean BackgroundEnabled = {read=FBackgroundEnabled, write=EnableBackground, default=1}
  87.         ;
  88.     __property Font ;
  89.     __property ParentCtl3D ;
  90.     __property ParentFont ;
  91.     __property ParentShowHint ;
  92. //     __property PopUpMenu ;
  93.     __property Integer Selection = {read=FSelection, write=SetSelection, default=0};
  94.     __property ShowHint ;
  95.     __property TabOrder ;
  96.     __property TabStop ;
  97.     __property Visible ;
  98.     __property TNotifyEvent OnChange = {read=FOnChange, write=FOnChange};
  99.     __property OnClick ;
  100.     __property OnDragDrop ;
  101.     __property OnDragOver ;
  102.     __property OnEndDrag ;
  103.     __property OnEnter ;
  104.     __property OnExit ;
  105.     __property OnKeyDown ;
  106.     __property OnKeyPress ;
  107.     __property OnKeyUp ;
  108.     __property OnMouseDown ;
  109.     __property OnMouseMove ;
  110.     __property OnMouseUp ;
  111. BEGIN_MESSAGE_MAP
  112.     VCL_MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
  113.     VCL_MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus);
  114.     VCL_MESSAGE_HANDLER(WM_KILLFOCUS, TWMKillFocus, WMKillFocus);
  115.     VCL_MESSAGE_HANDLER(WM_GETDLGCODE, TWMNoParams, WMGetDlgCode);
  116.     VCL_MESSAGE_HANDLER(CM_CTL3DCHANGED,TMessage, CMCtl3DChanged);
  117. END_MESSAGE_MAP(TCustomControl);
  118. };
  119.  
  120. //-- var, const, procedure ---------------------------------------------------
  121. #define NumPaletteEntries Byte(20)
  122. //-- end unit ----------------------------------------------------------------
  123. #endif    // CColorGrdH
  124.