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