]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/window.h
wxRTC: fixed guidelines overwriting adjacent cell borders; corrected capitalisation...
[wxWidgets.git] / include / wx / x11 / window.h
CommitLineData
83df96d6 1/////////////////////////////////////////////////////////////////////////////
ffd84c94 2// Name: wx/x11/window.h
83df96d6
JS
3// Purpose: wxWindow class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
83df96d6 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
83df96d6
JS
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_WINDOW_H_
12#define _WX_WINDOW_H_
13
83df96d6
JS
14#include "wx/region.h"
15
16// ----------------------------------------------------------------------------
17// wxWindow class for Motif - see also wxWindowBase
18// ----------------------------------------------------------------------------
19
968eb2ef 20class WXDLLIMPEXP_CORE wxWindowX11 : public wxWindowBase
83df96d6 21{
b5dbe15d
VS
22 friend class WXDLLIMPEXP_FWD_CORE wxDC;
23 friend class WXDLLIMPEXP_FWD_CORE wxWindowDC;
ffd84c94 24
83df96d6 25public:
bc797f4c 26 wxWindowX11() { Init(); }
ffd84c94 27
bc797f4c 28 wxWindowX11(wxWindow *parent,
83df96d6
JS
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 }
ffd84c94 38
f79bd02d 39 virtual ~wxWindowX11();
ffd84c94 40
83df96d6
JS
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);
ffd84c94 47
83df96d6
JS
48 virtual void Raise();
49 virtual void Lower();
ffd84c94
WS
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
83df96d6 57 virtual void SetFocus();
ffd84c94 58
83df96d6 59 virtual void WarpPointer(int x, int y);
ffd84c94
WS
60
61 virtual void Refresh( bool eraseBackground = true,
62 const wxRect *rect = (const wxRect *) NULL );
d02cb44e 63 virtual void Update();
ffd84c94 64
83df96d6
JS
65 virtual bool SetBackgroundColour( const wxColour &colour );
66 virtual bool SetForegroundColour( const wxColour &colour );
ffd84c94 67
83df96d6
JS
68 virtual bool SetCursor( const wxCursor &cursor );
69 virtual bool SetFont( const wxFont &font );
ffd84c94 70
83df96d6
JS
71 virtual int GetCharHeight() const;
72 virtual int GetCharWidth() const;
ffd84c94 73
6de70470 74 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = NULL );
ffd84c94 75
83df96d6
JS
76#if wxUSE_DRAG_AND_DROP
77 virtual void SetDropTarget( wxDropTarget *dropTarget );
78#endif // wxUSE_DRAG_AND_DROP
ffd84c94 79
83df96d6
JS
80 // Accept files for dragging
81 virtual void DragAcceptFiles(bool accept);
ffd84c94 82
83df96d6 83 // Get the unique identifier of a window
679918f9 84 virtual WXWindow GetHandle() const { return X11GetMainWindow(); }
ffd84c94 85
83df96d6
JS
86 // implementation from now on
87 // --------------------------
ffd84c94 88
83df96d6
JS
89 // accessors
90 // ---------
ffd84c94 91
ab6b6b15 92 // Get main X11 window
679918f9 93 virtual WXWindow X11GetMainWindow() const;
ffd84c94 94
ab6b6b15 95 // Get X11 window representing the client area
f41bc3e3
JS
96 virtual WXWindow GetClientAreaWindow() const;
97
83df96d6 98 void SetLastClick(int button, long timestamp)
ba696cfa 99 { m_lastButton = button; m_lastTS = timestamp; }
ffd84c94 100
83df96d6
JS
101 int GetLastClickedButton() const { return m_lastButton; }
102 long GetLastClickTime() const { return m_lastTS; }
ffd84c94 103
83df96d6
JS
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();
ffd84c94 107
887dd52f
RR
108 // Generates paint events from m_updateRegion
109 void SendPaintEvents();
ffd84c94 110
ab6b6b15
RR
111 // Generates paint events from flag
112 void SendNcPaintEvents();
ffd84c94 113
887dd52f
RR
114 // Generates erase events from m_clearRegion
115 void SendEraseEvents();
ffd84c94 116
3cd0b8c5
RR
117 // Clip to paint region?
118 bool GetClipPaintRegion() { return m_clipPaintRegion; }
ffd84c94 119
ba696cfa
RR
120 // Return clear region
121 wxRegion &GetClearRegion() { return m_clearRegion; }
ffd84c94
WS
122
123 void NeedUpdateNcAreaInIdle( bool update = true ) { m_updateNcArea = update; }
124
ab6b6b15
RR
125 // Inserting into main window instead of client
126 // window. This is mostly for a wxWindow's own
127 // scrollbars.
ffd84c94 128 void SetInsertIntoMain( bool insert = true ) { m_insertIntoMain = insert; }
ab6b6b15 129 bool GetInsertIntoMain() { return m_insertIntoMain; }
ffd84c94 130
83df96d6 131 // sets the fore/background colour for the given widget
bc797f4c 132 static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
ffd84c94
WS
133 static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = false);
134
0d1dff01
RR
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();
ffd84c94 139
0d1dff01 140protected:
83df96d6
JS
141 // Responds to colour changes: passes event on to children.
142 void OnSysColourChanged(wxSysColourChangedEvent& event);
ffd84c94 143
83df96d6
JS
144 // For double-click detection
145 long m_lastTS; // last timestamp
146 int m_lastButton; // last pressed button
ffd84c94 147
83df96d6 148protected:
ab6b6b15
RR
149 WXWindow m_mainWindow;
150 WXWindow m_clientWindow;
151 bool m_insertIntoMain;
ffd84c94 152
ab6b6b15 153 bool m_winCaptured;
1934d291
RR
154 wxRegion m_clearRegion;
155 bool m_clipPaintRegion;
ab6b6b15 156 bool m_updateNcArea;
3a0b23eb 157 bool m_needsInputFocus; // Input focus set in OnIdle
b513212d 158
83df96d6 159 // implement the base class pure virtuals
6de70470
VZ
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;
83df96d6
JS
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);
b2e10dac
PC
175 virtual void DoSetSizeHints(int minW, int minH,
176 int maxW, int maxH,
177 int incW, int incH);
83df96d6
JS
178 virtual void DoCaptureMouse();
179 virtual void DoReleaseMouse();
7edcafa4 180
83df96d6
JS
181#if wxUSE_TOOLTIPS
182 virtual void DoSetToolTip( wxToolTip *tip );
183#endif // wxUSE_TOOLTIPS
ffd84c94 184
83df96d6
JS
185private:
186 // common part of all ctors
187 void Init();
ffd84c94 188
bc797f4c 189 DECLARE_DYNAMIC_CLASS(wxWindowX11)
c0c133e1 190 wxDECLARE_NO_COPY_CLASS(wxWindowX11);
83df96d6
JS
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
53a2db12 205class WXDLLIMPEXP_CORE wxNoOptimize
83df96d6
JS
206{
207public:
208 wxNoOptimize() { ms_count++; }
209 ~wxNoOptimize() { ms_count--; }
ffd84c94 210
83df96d6 211 static bool CanOptimize() { return ms_count == 0; }
ffd84c94 212
83df96d6
JS
213protected:
214 static int ms_count;
215};
216
ffd84c94 217#endif // _WX_WINDOW_H_