]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/window.h
Applied patch [ 1196679 ] wxIMPLEMENT_CLASS_COMMON2 bad parameter count compil fix.
[wxWidgets.git] / include / wx / x11 / window.h
CommitLineData
83df96d6
JS
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
65571936 9// Licence: wxWindows licence
83df96d6
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WINDOW_H_
13#define _WX_WINDOW_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
83df96d6
JS
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
bc797f4c 25class wxWindowX11 : public wxWindowBase
83df96d6
JS
26{
27 friend class WXDLLEXPORT wxDC;
28 friend class WXDLLEXPORT wxWindowDC;
29
30public:
bc797f4c 31 wxWindowX11() { Init(); }
83df96d6 32
bc797f4c 33 wxWindowX11(wxWindow *parent,
83df96d6
JS
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
f79bd02d 44 virtual ~wxWindowX11();
83df96d6
JS
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
83df96d6
JS
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 );
d02cb44e
RR
65 virtual void Update();
66
83df96d6
JS
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
83df96d6
JS
82 virtual void ScrollWindow( int dx, int dy,
83 const wxRect* rect = (wxRect *) NULL );
84
571f6981 85 virtual void DoSetSizeHints(int minW, int minH,
83df96d6
JS
86 int maxW = -1, int maxH = -1,
87 int incW = -1, int incH = -1);
571f6981 88
83df96d6
JS
89#if wxUSE_DRAG_AND_DROP
90 virtual void SetDropTarget( wxDropTarget *dropTarget );
91#endif // wxUSE_DRAG_AND_DROP
92
93 // Accept files for dragging
94 virtual void DragAcceptFiles(bool accept);
95
96 // Get the unique identifier of a window
bc797f4c 97 virtual WXWindow GetHandle() const { return GetMainWindow(); }
83df96d6
JS
98
99 // implementation from now on
100 // --------------------------
101
102 // accessors
103 // ---------
104
ab6b6b15 105 // Get main X11 window
bc797f4c 106 virtual WXWindow GetMainWindow() const;
83df96d6 107
ab6b6b15 108 // Get X11 window representing the client area
f41bc3e3
JS
109 virtual WXWindow GetClientAreaWindow() const;
110
83df96d6 111 void SetLastClick(int button, long timestamp)
ba696cfa 112 { m_lastButton = button; m_lastTS = timestamp; }
83df96d6
JS
113
114 int GetLastClickedButton() const { return m_lastButton; }
115 long GetLastClickTime() const { return m_lastTS; }
116
117 // Gives window a chance to do something in response to a size message, e.g.
118 // arrange status bar, toolbar etc.
119 virtual bool PreResize();
120
887dd52f
RR
121 // Generates paint events from m_updateRegion
122 void SendPaintEvents();
123
ab6b6b15
RR
124 // Generates paint events from flag
125 void SendNcPaintEvents();
126
887dd52f
RR
127 // Generates erase events from m_clearRegion
128 void SendEraseEvents();
83df96d6 129
3cd0b8c5
RR
130 // Clip to paint region?
131 bool GetClipPaintRegion() { return m_clipPaintRegion; }
132
ba696cfa
RR
133 // Return clear region
134 wxRegion &GetClearRegion() { return m_clearRegion; }
135
ab6b6b15
RR
136 void NeedUpdateNcAreaInIdle( bool update = TRUE ) { m_updateNcArea = update; }
137
138 // Inserting into main window instead of client
139 // window. This is mostly for a wxWindow's own
140 // scrollbars.
141 void SetInsertIntoMain( bool insert = TRUE ) { m_insertIntoMain = insert; }
142 bool GetInsertIntoMain() { return m_insertIntoMain; }
143
83df96d6 144 // sets the fore/background colour for the given widget
bc797f4c
JS
145 static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
146 static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
83df96d6 147
0d1dff01
RR
148 // I don't want users to override what's done in idle so everything that
149 // has to be done in idle time in order for wxX11 to work is done in
150 // OnInternalIdle
151 virtual void OnInternalIdle();
152
0d1dff01 153protected:
83df96d6
JS
154 // Responds to colour changes: passes event on to children.
155 void OnSysColourChanged(wxSysColourChangedEvent& event);
156
83df96d6
JS
157 // For double-click detection
158 long m_lastTS; // last timestamp
159 int m_lastButton; // last pressed button
160
83df96d6 161protected:
ab6b6b15
RR
162 WXWindow m_mainWindow;
163 WXWindow m_clientWindow;
164 bool m_insertIntoMain;
165
166 bool m_winCaptured;
1934d291
RR
167 wxRegion m_clearRegion;
168 bool m_clipPaintRegion;
ab6b6b15 169 bool m_updateNcArea;
3a0b23eb 170 bool m_needsInputFocus; // Input focus set in OnIdle
b513212d 171
83df96d6
JS
172 // implement the base class pure virtuals
173 virtual void DoClientToScreen( int *x, int *y ) const;
174 virtual void DoScreenToClient( int *x, int *y ) const;
175 virtual void DoGetPosition( int *x, int *y ) const;
176 virtual void DoGetSize( int *width, int *height ) const;
177 virtual void DoGetClientSize( int *width, int *height ) const;
178 virtual void DoSetSize(int x, int y,
179 int width, int height,
180 int sizeFlags = wxSIZE_AUTO);
181 virtual void DoSetClientSize(int width, int height);
182 virtual void DoMoveWindow(int x, int y, int width, int height);
83df96d6
JS
183 virtual void DoCaptureMouse();
184 virtual void DoReleaseMouse();
7edcafa4 185
83df96d6
JS
186#if wxUSE_TOOLTIPS
187 virtual void DoSetToolTip( wxToolTip *tip );
188#endif // wxUSE_TOOLTIPS
189
190private:
191 // common part of all ctors
192 void Init();
193
bc797f4c
JS
194 DECLARE_DYNAMIC_CLASS(wxWindowX11)
195 DECLARE_NO_COPY_CLASS(wxWindowX11)
83df96d6
JS
196 DECLARE_EVENT_TABLE()
197};
198
199// ----------------------------------------------------------------------------
200// A little class to switch off `size optimization' while an instance of the
201// object exists: this may be useful to temporarily disable the optimisation
202// which consists to do nothing when the new size is equal to the old size -
203// although quite useful usually to avoid flicker, sometimes it leads to
204// undesired effects.
205//
206// Usage: create an instance of this class on the stack to disable the size
207// optimisation, it will be reenabled as soon as the object goes out from scope.
208// ----------------------------------------------------------------------------
209
210class WXDLLEXPORT wxNoOptimize
211{
212public:
213 wxNoOptimize() { ms_count++; }
214 ~wxNoOptimize() { ms_count--; }
215
216 static bool CanOptimize() { return ms_count == 0; }
217
218protected:
219 static int ms_count;
220};
221
222#endif
223// _WX_WINDOW_H_