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