]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/window.h
Initial move from C to C++. The functionality of the code should not have
[wxWidgets.git] / include / wx / x11 / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "window.h"
17 #endif
18
19 #include "wx/region.h"
20
21 // ----------------------------------------------------------------------------
22 // wxWindow class for Motif - see also wxWindowBase
23 // ----------------------------------------------------------------------------
24
25 class wxWindowX11 : public wxWindowBase
26 {
27 friend class WXDLLEXPORT wxDC;
28 friend class WXDLLEXPORT wxWindowDC;
29
30 public:
31 wxWindowX11() { Init(); }
32
33 wxWindowX11(wxWindow *parent,
34 wxWindowID id,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize,
37 long style = 0,
38 const wxString& name = wxPanelNameStr)
39 {
40 Init();
41 Create(parent, id, pos, size, style, name);
42 }
43
44 virtual ~wxWindowX11();
45
46 bool Create(wxWindow *parent,
47 wxWindowID id,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 long style = 0,
51 const wxString& name = wxPanelNameStr);
52
53 virtual void Raise();
54 virtual void Lower();
55
56 virtual bool Show( bool show = TRUE );
57 virtual bool Enable( bool enable = TRUE );
58
59 virtual void SetFocus();
60
61 virtual void WarpPointer(int x, int y);
62
63 virtual void Refresh( bool eraseBackground = TRUE,
64 const wxRect *rect = (const wxRect *) NULL );
65 virtual void Update();
66
67 virtual bool SetBackgroundColour( const wxColour &colour );
68 virtual bool SetForegroundColour( const wxColour &colour );
69
70 virtual bool SetCursor( const wxCursor &cursor );
71 virtual bool SetFont( const wxFont &font );
72
73 virtual int GetCharHeight() const;
74 virtual int GetCharWidth() const;
75 virtual void GetTextExtent(const wxString& string,
76 int *x, int *y,
77 int *descent = (int *) NULL,
78 int *externalLeading = (int *) NULL,
79 const wxFont *theFont = (const wxFont *) NULL)
80 const;
81
82 virtual void ScrollWindow( int dx, int dy,
83 const wxRect* rect = (wxRect *) NULL );
84
85 virtual void SetSizeHints(int minW, int minH,
86 int maxW = -1, int maxH = -1,
87 int incW = -1, int incH = -1);
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 // For implementation purposes - sometimes decorations make the client area
148 // smaller
149 virtual wxPoint GetClientAreaOrigin() const;
150
151 // I don't want users to override what's done in idle so everything that
152 // has to be done in idle time in order for wxX11 to work is done in
153 // OnInternalIdle
154 virtual void OnInternalIdle();
155
156 protected:
157 // Responds to colour changes: passes event on to children.
158 void OnSysColourChanged(wxSysColourChangedEvent& event);
159
160 // For double-click detection
161 long m_lastTS; // last timestamp
162 int m_lastButton; // last pressed button
163
164 protected:
165 WXWindow m_mainWindow;
166 WXWindow m_clientWindow;
167 bool m_insertIntoMain;
168
169 bool m_winCaptured;
170 wxRegion m_clearRegion;
171 bool m_clipPaintRegion;
172 bool m_updateNcArea;
173 bool m_needsInputFocus; // Input focus set in OnIdle
174
175 // implement the base class pure virtuals
176 virtual void DoClientToScreen( int *x, int *y ) const;
177 virtual void DoScreenToClient( int *x, int *y ) const;
178 virtual void DoGetPosition( int *x, int *y ) const;
179 virtual void DoGetSize( int *width, int *height ) const;
180 virtual void DoGetClientSize( int *width, int *height ) const;
181 virtual void DoSetSize(int x, int y,
182 int width, int height,
183 int sizeFlags = wxSIZE_AUTO);
184 virtual void DoSetClientSize(int width, int height);
185 virtual void DoMoveWindow(int x, int y, int width, int height);
186 virtual void DoCaptureMouse();
187 virtual void DoReleaseMouse();
188
189 #if wxUSE_TOOLTIPS
190 virtual void DoSetToolTip( wxToolTip *tip );
191 #endif // wxUSE_TOOLTIPS
192
193 private:
194 // common part of all ctors
195 void Init();
196
197 DECLARE_DYNAMIC_CLASS(wxWindowX11)
198 DECLARE_NO_COPY_CLASS(wxWindowX11)
199 DECLARE_EVENT_TABLE()
200 };
201
202 // ----------------------------------------------------------------------------
203 // A little class to switch off `size optimization' while an instance of the
204 // object exists: this may be useful to temporarily disable the optimisation
205 // which consists to do nothing when the new size is equal to the old size -
206 // although quite useful usually to avoid flicker, sometimes it leads to
207 // undesired effects.
208 //
209 // Usage: create an instance of this class on the stack to disable the size
210 // optimisation, it will be reenabled as soon as the object goes out from scope.
211 // ----------------------------------------------------------------------------
212
213 class WXDLLEXPORT wxNoOptimize
214 {
215 public:
216 wxNoOptimize() { ms_count++; }
217 ~wxNoOptimize() { ms_count--; }
218
219 static bool CanOptimize() { return ms_count == 0; }
220
221 protected:
222 static int ms_count;
223 };
224
225 #endif
226 // _WX_WINDOW_H_