]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/window.h
update button style to include BS_MULTILINE when a multiline label is set
[wxWidgets.git] / include / wx / x11 / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/window.h
3 // Purpose: wxWindow class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #include "wx/region.h"
16
17 // ----------------------------------------------------------------------------
18 // wxWindow class for Motif - see also wxWindowBase
19 // ----------------------------------------------------------------------------
20
21 class WXDLLIMPEXP_CORE wxWindowX11 : public wxWindowBase
22 {
23 friend class WXDLLIMPEXP_FWD_CORE wxDC;
24 friend class WXDLLIMPEXP_FWD_CORE wxWindowDC;
25
26 public:
27 wxWindowX11() { Init(); }
28
29 wxWindowX11(wxWindow *parent,
30 wxWindowID id,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 long style = 0,
34 const wxString& name = wxPanelNameStr)
35 {
36 Init();
37 Create(parent, id, pos, size, style, name);
38 }
39
40 virtual ~wxWindowX11();
41
42 bool Create(wxWindow *parent,
43 wxWindowID id,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxString& name = wxPanelNameStr);
48
49 virtual void Raise();
50 virtual void Lower();
51
52 virtual void SetLabel(const wxString& label);
53 virtual wxString GetLabel() const;
54
55 virtual bool Show( bool show = true );
56 virtual bool Enable( bool enable = true );
57
58 virtual void SetFocus();
59
60 virtual void WarpPointer(int x, int y);
61
62 virtual void Refresh( bool eraseBackground = true,
63 const wxRect *rect = (const wxRect *) NULL );
64 virtual void Update();
65
66 virtual bool SetBackgroundColour( const wxColour &colour );
67 virtual bool SetForegroundColour( const wxColour &colour );
68
69 virtual bool SetCursor( const wxCursor &cursor );
70 virtual bool SetFont( const wxFont &font );
71
72 virtual int GetCharHeight() const;
73 virtual int GetCharWidth() const;
74 virtual void GetTextExtent(const wxString& string,
75 int *x, int *y,
76 int *descent = (int *) NULL,
77 int *externalLeading = (int *) NULL,
78 const wxFont *theFont = (const wxFont *) NULL)
79 const;
80
81 virtual void ScrollWindow( int dx, int dy,
82 const wxRect* rect = (wxRect *) NULL );
83
84 virtual void DoSetSizeHints(int minW, int minH,
85 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
86 int incW = wxDefaultCoord, int incH = wxDefaultCoord);
87
88 #if wxUSE_DRAG_AND_DROP
89 virtual void SetDropTarget( wxDropTarget *dropTarget );
90 #endif // wxUSE_DRAG_AND_DROP
91
92 // Accept files for dragging
93 virtual void DragAcceptFiles(bool accept);
94
95 // Get the unique identifier of a window
96 virtual WXWindow GetHandle() const { return GetMainWindow(); }
97
98 // implementation from now on
99 // --------------------------
100
101 // accessors
102 // ---------
103
104 // Get main X11 window
105 virtual WXWindow GetMainWindow() const;
106
107 // Get X11 window representing the client area
108 virtual WXWindow GetClientAreaWindow() const;
109
110 void SetLastClick(int button, long timestamp)
111 { m_lastButton = button; m_lastTS = timestamp; }
112
113 int GetLastClickedButton() const { return m_lastButton; }
114 long GetLastClickTime() const { return m_lastTS; }
115
116 // Gives window a chance to do something in response to a size message, e.g.
117 // arrange status bar, toolbar etc.
118 virtual bool PreResize();
119
120 // Generates paint events from m_updateRegion
121 void SendPaintEvents();
122
123 // Generates paint events from flag
124 void SendNcPaintEvents();
125
126 // Generates erase events from m_clearRegion
127 void SendEraseEvents();
128
129 // Clip to paint region?
130 bool GetClipPaintRegion() { return m_clipPaintRegion; }
131
132 // Return clear region
133 wxRegion &GetClearRegion() { return m_clearRegion; }
134
135 void NeedUpdateNcAreaInIdle( bool update = true ) { m_updateNcArea = update; }
136
137 // Inserting into main window instead of client
138 // window. This is mostly for a wxWindow's own
139 // scrollbars.
140 void SetInsertIntoMain( bool insert = true ) { m_insertIntoMain = insert; }
141 bool GetInsertIntoMain() { return m_insertIntoMain; }
142
143 // sets the fore/background colour for the given widget
144 static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
145 static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = false);
146
147 // I don't want users to override what's done in idle so everything that
148 // has to be done in idle time in order for wxX11 to work is done in
149 // OnInternalIdle
150 virtual void OnInternalIdle();
151
152 protected:
153 // Responds to colour changes: passes event on to children.
154 void OnSysColourChanged(wxSysColourChangedEvent& event);
155
156 // For double-click detection
157 long m_lastTS; // last timestamp
158 int m_lastButton; // last pressed button
159
160 protected:
161 WXWindow m_mainWindow;
162 WXWindow m_clientWindow;
163 bool m_insertIntoMain;
164
165 bool m_winCaptured;
166 wxRegion m_clearRegion;
167 bool m_clipPaintRegion;
168 bool m_updateNcArea;
169 bool m_needsInputFocus; // Input focus set in OnIdle
170
171 // implement the base class pure virtuals
172 virtual void DoClientToScreen( int *x, int *y ) const;
173 virtual void DoScreenToClient( int *x, int *y ) const;
174 virtual void DoGetPosition( int *x, int *y ) const;
175 virtual void DoGetSize( int *width, int *height ) const;
176 virtual void DoGetClientSize( int *width, int *height ) const;
177 virtual void DoSetSize(int x, int y,
178 int width, int height,
179 int sizeFlags = wxSIZE_AUTO);
180 virtual void DoSetClientSize(int width, int height);
181 virtual void DoMoveWindow(int x, int y, int width, int height);
182 virtual void DoCaptureMouse();
183 virtual void DoReleaseMouse();
184
185 #if wxUSE_TOOLTIPS
186 virtual void DoSetToolTip( wxToolTip *tip );
187 #endif // wxUSE_TOOLTIPS
188
189 private:
190 // common part of all ctors
191 void Init();
192
193 DECLARE_DYNAMIC_CLASS(wxWindowX11)
194 DECLARE_NO_COPY_CLASS(wxWindowX11)
195 DECLARE_EVENT_TABLE()
196 };
197
198 // ----------------------------------------------------------------------------
199 // A little class to switch off `size optimization' while an instance of the
200 // object exists: this may be useful to temporarily disable the optimisation
201 // which consists to do nothing when the new size is equal to the old size -
202 // although quite useful usually to avoid flicker, sometimes it leads to
203 // undesired effects.
204 //
205 // Usage: create an instance of this class on the stack to disable the size
206 // optimisation, it will be reenabled as soon as the object goes out from scope.
207 // ----------------------------------------------------------------------------
208
209 class WXDLLEXPORT wxNoOptimize
210 {
211 public:
212 wxNoOptimize() { ms_count++; }
213 ~wxNoOptimize() { ms_count--; }
214
215 static bool CanOptimize() { return ms_count == 0; }
216
217 protected:
218 static int ms_count;
219 };
220
221 #endif // _WX_WINDOW_H_