]>
Commit | Line | Data |
---|---|---|
ec376c8f VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/pickerbase.h | |
3 | // Purpose: wxPickerBase definition | |
4 | // Author: Francesco Montorsi (based on Vadim Zeitlin's code) | |
5 | // Modified by: | |
6 | // Created: 14/4/2006 | |
7 | // Copyright: (c) Vadim Zeitlin, Francesco Montorsi | |
8 | // RCS-ID: $Id$ | |
9 | // Licence: wxWindows Licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PICKERBASE_H_BASE_ | |
13 | #define _WX_PICKERBASE_H_BASE_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | #include "wx/control.h" | |
17 | #include "wx/textctrl.h" | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // wxPickerBase is the base class for the picker controls which support | |
21 | // a wxPB_USE_TEXTCTRL style; i.e. for those pickers which can use an auxiliary | |
22 | // text control next to the 'real' picker. | |
23 | // | |
24 | // The wxTextPickerHelper class manages enabled/disabled state of the text control, | |
25 | // its sizing and positioning. | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | #define wxPB_USE_TEXTCTRL 0x0002 | |
29 | ||
30 | class WXDLLIMPEXP_CORE wxPickerBase : public wxControl | |
31 | { | |
32 | public: | |
33 | // ctor: text is the associated text control | |
34 | wxPickerBase() : m_text(NULL), m_picker(NULL), | |
35 | m_margin(5), m_textProportion(2) {} | |
36 | virtual ~wxPickerBase(); | |
37 | ||
38 | ||
39 | // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control | |
40 | // The 3rd argument is the initial wxString to display in the text control | |
41 | bool CreateBase(wxWindow *parent, wxWindowID id, | |
42 | const wxString& text = wxEmptyString, | |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, long style = 0, | |
45 | const wxValidator& validator = wxDefaultValidator, | |
46 | const wxString& name = wxButtonNameStr); | |
47 | ||
48 | ||
49 | public: // public API | |
50 | ||
51 | // margin between the text control and the picker | |
52 | void SetInternalMargin(int newmargin); | |
53 | int GetInternalMargin() const { return m_margin; } | |
54 | ||
55 | // proportion of the text control respect the picker | |
56 | // (which has a fixed proportion value of 1) | |
57 | void SetTextCtrlProportion(int prop) { wxASSERT(prop>=1); m_textProportion=prop; } | |
58 | int GetTextCtrlProportion() const { return m_textProportion; } | |
59 | ||
60 | bool HasTextCtrl() const | |
61 | { return m_text != NULL; } | |
62 | wxTextCtrl *GetTextCtrl() | |
63 | { return m_text; } | |
64 | wxControl *GetPickerCtrl() | |
65 | { return m_picker; } | |
66 | ||
67 | public: // wxWindow overrides | |
68 | ||
69 | void DoSetSizeHints(int minW, int minH, | |
70 | int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, | |
71 | int incW = wxDefaultCoord, int incH = wxDefaultCoord ); | |
72 | ||
73 | void DoSetSize(int x, int y, | |
74 | int width, int height, | |
75 | int sizeFlags = wxSIZE_AUTO); | |
76 | ||
77 | wxSize DoGetBestSize() const; | |
78 | ||
79 | ||
80 | public: // methods that derived class must/may override | |
81 | ||
82 | virtual void UpdatePickerFromTextCtrl() = 0; | |
83 | virtual void UpdateTextCtrlFromPicker() = 0; | |
84 | ||
85 | protected: // utility functions | |
86 | ||
87 | inline int GetTextCtrlWidth(int given); | |
88 | ||
89 | // event handlers | |
90 | void OnTextCtrlDelete(wxWindowDestroyEvent &); | |
91 | void OnTextCtrlUpdate(wxCommandEvent &); | |
92 | void OnTextCtrlKillFocus(wxFocusEvent &); | |
93 | ||
94 | // returns the set of styles for the attached wxTextCtrl | |
95 | // from given wxPickerBase's styles | |
96 | virtual long GetTextCtrlStyle(long style) const | |
97 | { return (style & wxWINDOW_STYLE_MASK); } | |
98 | ||
99 | // returns the set of styles for the m_picker | |
100 | virtual long GetPickerStyle(long style) const | |
101 | { return (style & wxWINDOW_STYLE_MASK); } | |
102 | ||
103 | protected: | |
104 | wxTextCtrl *m_text; // can be NULL | |
105 | wxControl *m_picker; | |
106 | ||
107 | int m_margin; // distance between subcontrols | |
108 | int m_textProportion; // proportion between textctrl and other item | |
109 | ||
110 | private: | |
111 | DECLARE_ABSTRACT_CLASS(wxPickerBase) | |
112 | }; | |
113 | ||
114 | ||
115 | #endif | |
116 | // _WX_PICKERBASE_H_BASE_ |