control.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/control.h
  3. // Purpose: wxControl class
  4. // Author: David Webster
  5. // Modified by:
  6. // Created: 09/17/99
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CONTROL_H_
  11. #define _WX_CONTROL_H_
  12. #include "wx/dynarray.h"
  13. // General item class
  14. class WXDLLIMPEXP_CORE wxControl : public wxControlBase
  15. {
  16. DECLARE_ABSTRACT_CLASS(wxControl)
  17. public:
  18. wxControl();
  19. wxControl( wxWindow* pParent
  20. ,wxWindowID vId
  21. ,const wxPoint& rPos = wxDefaultPosition
  22. ,const wxSize& rSize = wxDefaultSize
  23. ,long lStyle = 0
  24. ,const wxValidator& rValidator = wxDefaultValidator
  25. ,const wxString& rsName = wxControlNameStr
  26. )
  27. {
  28. Create( pParent, vId, rPos, rSize, lStyle, rValidator, rsName );
  29. }
  30. bool Create( wxWindow* pParent
  31. ,wxWindowID vId
  32. ,const wxPoint& rPos = wxDefaultPosition
  33. ,const wxSize& rSize = wxDefaultSize
  34. ,long lStyle = 0
  35. ,const wxValidator& rValidator = wxDefaultValidator
  36. ,const wxString& rsName = wxControlNameStr
  37. );
  38. virtual void SetLabel(const wxString& rsLabel);
  39. virtual wxString GetLabel() const { return m_label; }
  40. //
  41. // Simulates an event
  42. //
  43. virtual void Command(wxCommandEvent& rEvent) { ProcessCommand(rEvent); }
  44. //
  45. // Implementation from now on
  46. // --------------------------
  47. //
  48. //
  49. // Calls the callback and appropriate event handlers
  50. //
  51. bool ProcessCommand(wxCommandEvent& rEvent);
  52. //
  53. // For ownerdraw items
  54. //
  55. virtual bool OS2OnDraw(WXDRAWITEMSTRUCT* WXUNUSED(pItem)) { return false; }
  56. virtual long OS2OnMeasure(WXMEASUREITEMSTRUCT* WXUNUSED(pItem)) { return 0L; }
  57. wxArrayLong& GetSubcontrols() { return m_aSubControls; }
  58. void OnEraseBackground(wxEraseEvent& rEvent);
  59. virtual WXHBRUSH OnCtlColor( WXHDC hDC
  60. ,WXHWND pWnd
  61. ,WXUINT nCtlColor
  62. ,WXUINT uMessage
  63. ,WXWPARAM wParam
  64. ,WXLPARAM lParam
  65. );
  66. public:
  67. //
  68. // For controls like radiobuttons which are really composite
  69. //
  70. wxArrayLong m_aSubControls;
  71. virtual wxSize DoGetBestSize(void) const;
  72. //
  73. // Create the control of the given PM class
  74. //
  75. bool OS2CreateControl( const wxChar* zClassname
  76. ,const wxString& rsLabel
  77. ,const wxPoint& rPos
  78. ,const wxSize& rSize
  79. ,long lStyle
  80. );
  81. //
  82. // Create the control of the given class with the given style, returns false
  83. // if creation failed.
  84. //
  85. bool OS2CreateControl( const wxChar* zClassname
  86. ,WXDWORD dwStyle
  87. ,const wxPoint& rPos = wxDefaultPosition
  88. ,const wxSize& rSize = wxDefaultSize
  89. ,const wxString& rsLabel = wxEmptyString
  90. ,WXDWORD dwExstyle = (WXDWORD)-1
  91. );
  92. //
  93. // Default style for the control include WS_TABSTOP if it AcceptsFocus()
  94. //
  95. virtual WXDWORD OS2GetStyle( long lStyle
  96. ,WXDWORD* pdwExstyle
  97. ) const;
  98. inline int GetXComp(void) const {return m_nXComp;}
  99. inline int GetYComp(void) const {return m_nYComp;}
  100. inline void SetXComp(const int nXComp) {m_nXComp = nXComp;}
  101. inline void SetYComp(const int nYComp) {m_nYComp = nYComp;}
  102. private:
  103. int m_nXComp;
  104. int m_nYComp;
  105. wxString m_label;
  106. WXDWORD m_dwStyle;
  107. DECLARE_EVENT_TABLE()
  108. }; // end of wxControl
  109. #endif // _WX_CONTROL_H_