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

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1998 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. #if !defined(CSpinH)
  6. #define CSpinH
  7. //----------------------------------------------------------------------------
  8. #include <Buttons.hpp>
  9. #include <Menus.hpp>
  10. #include <Graphics.hpp>
  11. #include <Forms.hpp>
  12. #include <SysUtils.hpp>
  13. #include <Messages.hpp>
  14. #include <Controls.hpp>
  15. #include <ExtCtrls.hpp>
  16. #include <StdCtrls.hpp>
  17. #include <Classes.hpp>
  18. #include <Windows.hpp>
  19. #include <System.hpp>
  20. #include <DBCtrls.hpp>    //for InitRepeatPause and RepeatPause
  21.  
  22. //-- type declarations -------------------------------------------------------
  23. namespace Cspin{
  24. class TCSpinButton;
  25. class TTimerSpeedButton;
  26. enum Spin_3 { tbFocusRect, tbAllowTimer };
  27.  
  28. typedef Set<Spin_3, tbFocusRect, tbAllowTimer>  TTimeBtnState;
  29.  
  30. class PACKAGE TTimerSpeedButton : public TSpeedButton
  31. {
  32. private:
  33.     TTimer *FRepeatTimer;
  34.     TTimeBtnState FTimeBtnState;
  35.     void __fastcall TimerExpired(TObject *Sender);
  36.  
  37. protected:
  38.     virtual void __fastcall Paint(void);
  39.     DYNAMIC void __fastcall MouseDown(TMouseButton Button,  TShiftState Shift, int X, int Y);
  40.     DYNAMIC void __fastcall MouseUp(TMouseButton Button,  TShiftState Shift, int X, int Y);
  41.  
  42. public:
  43.     __fastcall virtual ~TTimerSpeedButton(void);
  44.     __property TTimeBtnState TimeBtnState = {read=FTimeBtnState, write=FTimeBtnState, nodefault};
  45.     __fastcall virtual TTimerSpeedButton(TComponent *AOwner);
  46. };
  47.  
  48. class PACKAGE TCSpinButton : public TWinControl
  49. {
  50.  
  51. private:
  52.     TTimerSpeedButton *FUpButton;
  53.     TTimerSpeedButton *FDownButton;
  54.     TTimerSpeedButton *FFocusedButton;
  55.     TWinControl *FFocusControl;
  56.     TNotifyEvent FOnUpClick;
  57.     TNotifyEvent FOnDownClick;
  58.     TTimerSpeedButton *__fastcall CreateButton(void);
  59.     Graphics::TBitmap *__fastcall GetUpGlyph(void);
  60.     Graphics::TBitmap *__fastcall GetDownGlyph(void);
  61.     void __fastcall SetUpGlyph(Graphics::TBitmap *Value);
  62.     void __fastcall SetDownGlyph(Graphics::TBitmap *Value);
  63.     void __fastcall BtnClick(TObject *Sender);
  64.     void __fastcall BtnMouseDown(TObject *Sender, TMouseButton Button,  TShiftState Shift, int X, int
  65.         Y);
  66.     void __fastcall SetFocusBtn(TTimerSpeedButton *Btn);
  67.     void __fastcall AdjustSize(int &W, int &H);
  68.     MESSAGE void __fastcall WMSize(TWMSize &Message);
  69.     MESSAGE void __fastcall WMSetFocus(TWMSetFocus &Message);
  70.     MESSAGE void __fastcall WMKillFocus(TWMKillFocus &Message);
  71.     MESSAGE void __fastcall WMGetDlgCode(TWMNoParams &Message);
  72.  
  73. protected:
  74.     virtual void __fastcall Loaded(void);
  75.     DYNAMIC void __fastcall KeyDown(Word &Key,  TShiftState Shift);
  76.  
  77. public:
  78.     __fastcall virtual TCSpinButton(TComponent *AOwner);
  79.     __fastcall TCSpinButton(HWND Parent): TWinControl(Parent) {};
  80.     virtual void __fastcall SetBounds(int ALeft, int ATop, int AWidth, int AHeight);
  81.  
  82. __published:
  83.     __property Align ;
  84.     __property Ctl3D ;
  85.     __property Graphics::TBitmap * DownGlyph = {read=GetDownGlyph, write=SetDownGlyph, nodefault};
  86.     __property DragCursor ;
  87.     __property DragMode ;
  88.     __property Enabled ;
  89.     __property TWinControl * FocusControl = {read=FFocusControl, write=FFocusControl, nodefault};
  90.     __property ParentCtl3D ;
  91.     __property ParentShowHint ;
  92.     __property PopupMenu ;
  93.     __property ShowHint ;
  94.     __property TabOrder ;
  95.     __property TabStop ;
  96.     __property Graphics::TBitmap * UpGlyph = {read=GetUpGlyph, write=SetUpGlyph, nodefault};
  97.     __property Visible ;
  98.     __property TNotifyEvent OnDownClick = {read=FOnDownClick, write=FOnDownClick};
  99.     __property OnDragDrop ;
  100.     __property OnDragOver ;
  101.     __property OnEndDrag ;
  102.     __property OnEnter ;
  103.     __property OnExit ;
  104.     __property TNotifyEvent OnUpClick = {read=FOnUpClick, write=FOnUpClick};
  105.     __fastcall virtual ~TCSpinButton(void) { }
  106. BEGIN_MESSAGE_MAP
  107.     VCL_MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
  108.     VCL_MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus);
  109.     VCL_MESSAGE_HANDLER(WM_KILLFOCUS, TWMKillFocus, WMKillFocus);
  110.     VCL_MESSAGE_HANDLER(WM_GETDLGCODE, TWMNoParams, WMGetDlgCode);
  111. END_MESSAGE_MAP(TWinControl);
  112. };
  113.  
  114. class PACKAGE TCSpinEdit : public TCustomEdit
  115. {
  116. private:
  117.     long FMinValue;
  118.     long FMaxValue;
  119.     TCanvas *FCanvas;
  120.     long FIncrement;
  121.     TCSpinButton *FButton;
  122.     bool FEditorEnabled;
  123.     int __fastcall GetMinHeight(void);
  124.     long __fastcall GetValue(void);
  125.     long __fastcall CheckValue(long NewValue);
  126.     void __fastcall SetValue(long NewValue);
  127.     void __fastcall SetEditRect(void);
  128.     MESSAGE void __fastcall WMSize(TWMSize &Message);
  129.     MESSAGE void __fastcall CMEnter(TWMNoParams &Message);
  130.     MESSAGE void __fastcall CMExit(TWMNoParams &Message);
  131.     MESSAGE void __fastcall WMPaste(TWMNoParams &Message);
  132.     MESSAGE void __fastcall WMCut(TWMNoParams &Message);
  133.  
  134. protected:
  135.     DYNAMIC void __fastcall GetChildren(TGetChildProc Proc, TComponent * Root);
  136.     virtual bool __fastcall IsValidChar(Char Key);
  137.     virtual void __fastcall UpClick(TObject *Sender);
  138.     virtual void __fastcall DownClick(TObject *Sender);
  139.     DYNAMIC void __fastcall KeyDown(Word &Key,  TShiftState Shift);
  140.     DYNAMIC void __fastcall KeyPress(Char &Key);
  141.     virtual void __fastcall CreateParams(TCreateParams &Params);
  142.     virtual void __fastcall CreateWnd(void);
  143.  
  144. public:
  145.     __fastcall virtual TCSpinEdit(TComponent *AOwner);
  146.     __fastcall TCSpinEdit(HWND Parent): TCustomEdit(Parent) {};
  147.     __fastcall virtual ~TCSpinEdit(void);
  148.     __property TCSpinButton * Button = {read=FButton, nodefault};
  149.  
  150. __published:
  151.     __property AutoSelect ;
  152.     __property AutoSize ;
  153.     __property Color ;
  154.     __property Ctl3D ;
  155.     __property DragCursor ;
  156.     __property DragMode ;
  157.     __property bool EditorEnabled = {read=FEditorEnabled, write=FEditorEnabled, default=1};
  158.     __property Enabled ;
  159.     __property Font ;
  160.     __property long Increment = {read=FIncrement, write=FIncrement, default=1};
  161.     __property long MaxValue = {read=FMaxValue, write=FMaxValue, nodefault};
  162.     __property long MinValue = {read=FMinValue, write=FMinValue, nodefault};
  163.     __property ParentColor ;
  164.     __property ParentCtl3D ;
  165.     __property ParentFont ;
  166.     __property ParentShowHint ;
  167.     __property PopupMenu ;
  168.     __property ReadOnly ;
  169.     __property ShowHint ;
  170.     __property TabOrder ;
  171.     __property TabStop ;
  172.     __property long Value = {read=GetValue, write=SetValue, nodefault};
  173.     __property Visible ;
  174.     __property OnChange ;
  175.     __property OnClick ;
  176.     __property OnDblClick ;
  177.     __property OnDragDrop ;
  178.     __property OnDragOver ;
  179.     __property OnEndDrag ;
  180.     __property OnEnter ;
  181.     __property OnExit ;
  182.     __property OnKeyDown ;
  183.     __property OnKeyPress ;
  184.     __property OnKeyUp ;
  185.     __property OnMouseDown ;
  186.     __property OnMouseMove ;
  187.     __property OnMouseUp ;
  188. BEGIN_MESSAGE_MAP
  189.     VCL_MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
  190.     VCL_MESSAGE_HANDLER(CM_ENTER, TWMNoParams, CMEnter);
  191.     VCL_MESSAGE_HANDLER(CM_EXIT, TWMNoParams, CMExit);
  192.     VCL_MESSAGE_HANDLER(WM_PASTE, TWMNoParams, WMPaste);
  193.     VCL_MESSAGE_HANDLER(WM_CUT, TWMNoParams, WMCut);
  194. END_MESSAGE_MAP(TCustomEdit);
  195. };
  196.  
  197. //-- var, const, procedure ---------------------------------------------------
  198. //-- template instantiations -------------------------------------------------
  199. template class TTimeBtnState ;
  200. //-- end unit ----------------------------------------------------------------
  201. } //end namespace Cspin
  202.  
  203. #if !defined(NO_IMPLICIT_NAMESPACE_USE)
  204. using namespace Cspin;
  205. #endif
  206.  
  207. #endif    // CSpinH
  208.