control.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/control.h
  3. // Purpose: wxControl class
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2003/02/15
  7. // Copyright: (c) 2003 David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef __WX_COCOA_CONTROL_H__
  11. #define __WX_COCOA_CONTROL_H__
  12. #include "wx/cocoa/NSControl.h"
  13. // ========================================================================
  14. // wxControl
  15. // ========================================================================
  16. class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxCocoaNSControl
  17. {
  18. DECLARE_ABSTRACT_CLASS(wxControl)
  19. WX_DECLARE_COCOA_OWNER(NSControl,NSView,NSView)
  20. DECLARE_EVENT_TABLE()
  21. // ------------------------------------------------------------------------
  22. // initialization
  23. // ------------------------------------------------------------------------
  24. public:
  25. wxControl() {}
  26. wxControl(wxWindow *parent, wxWindowID winid,
  27. const wxPoint& pos = wxDefaultPosition,
  28. const wxSize& size = wxDefaultSize, long style = 0,
  29. const wxValidator& validator = wxDefaultValidator,
  30. const wxString& name = wxControlNameStr)
  31. {
  32. Create(parent, winid, pos, size, style, validator, name);
  33. }
  34. bool Create(wxWindow *parent, wxWindowID winid,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize, long style = 0,
  37. const wxValidator& validator = wxDefaultValidator,
  38. const wxString& name = wxControlNameStr);
  39. virtual ~wxControl();
  40. // ------------------------------------------------------------------------
  41. // Implementation
  42. // ------------------------------------------------------------------------
  43. public:
  44. // implementation from now on
  45. // --------------------------
  46. void OnEraseBackground(wxEraseEvent& event);
  47. virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
  48. // Calls the callback and appropriate event handlers
  49. bool ProcessCommand(wxCommandEvent& event);
  50. // Enables the control
  51. virtual void CocoaSetEnabled(bool enable);
  52. protected:
  53. virtual wxSize DoGetBestSize() const;
  54. // Provides a common implementation of title setting which strips mnemonics
  55. // and then calls setTitle: with the stripped string. May be implemented
  56. // to call setTitleWithMnemonic: on OpenStep-compatible systems. Only
  57. // intended for use by views or cells which implement at least setTitle:
  58. // and possibly setTitleWithMnemonic: such as NSBox and NSButton or NSCell
  59. // classes, for example as used by wxRadioBox. Not usable with classes like
  60. // NSTextField which expect setStringValue:.
  61. static void CocoaSetLabelForObject(const wxString& labelWithWxMnemonic, struct objc_object *anObject);
  62. };
  63. #endif
  64. // __WX_COCOA_CONTROL_H__