// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxValidator;
+class WXDLLEXPORT wxToolTip;
#if wxUSE_DRAG_AND_DROP
class WXDLLEXPORT wxDropTarget;
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
+//-----------------------------------------------------------------------------
+// wxClientData
+//-----------------------------------------------------------------------------
+
+class wxClientData
+{
+public:
+ wxClientData() { }
+ virtual ~wxClientData() { }
+};
+
+//-----------------------------------------------------------------------------
+// wxStringClientData
+//-----------------------------------------------------------------------------
+
+class wxStringClientData: public wxClientData
+{
+public:
+ wxStringClientData() { }
+ wxStringClientData( wxString &data ) { m_data = data; }
+ void SetData( wxString &data ) { m_data = data; }
+ wxString GetData() const { return m_data; }
+
+private:
+ wxString m_data;
+};
+
+// Clash with Windows headers
+#ifdef GetCharWidth
+#undef GetCharWidth
+#endif
+
+#ifdef FindWindow
+#undef FindWindow
+#endif
+
class WXDLLEXPORT wxWindow : public wxEvtHandler
{
DECLARE_ABSTRACT_CLASS(wxWindow)
long style = 0,
const wxString& name = wxPanelNameStr)
{
+ Init();
Create(parent, id, pos, size, style, name);
}
// Set the cursor
virtual void SetCursor(const wxCursor& cursor);
- inline virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; };
+ inline virtual wxCursor& GetCursor() const { return (wxCursor& ) m_windowCursor; };
// Get the window with the focus
static wxWindow *FindFocus();
// Get overall window size
virtual void GetSize(int *width, int *height) const;
+ wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); }
// Get window position, relative to parent (or screen if no parent)
virtual void GetPosition(int *x, int *y) const;
+ wxPoint GetPosition() const
+ { int x, y; GetPosition(&x, &y); return wxPoint(x, y); }
+
+ // Get size and position
+ wxRect GetRect() const
+ { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); }
// Get client (application-useable) size
virtual void GetClientSize(int *width, int *height) const;
+ wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
// Set overall size and position
+ // generic function, may be overriden in derived classes
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
- inline virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
- inline virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); }
+
+ void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
+ { SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
+
+ // set size only
+ void SetSize(int width, int height)
+ { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
+ void SetSize(const wxSize& size)
+ { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); }
+
+ // set position only
+ virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); }
+ void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); }
// Set client size
- virtual void SetClientSize(int width, int size);
+ virtual void SetClientSize(int width, int height);
+ void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); }
// Convert client to screen coordinates
virtual void ClientToScreen(int *x, int *y) const;
+ wxPoint ClientToScreen(const wxPoint& pt) const
+ { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
// Convert screen to client coordinates
virtual void ScreenToClient(int *x, int *y) const;
+ wxPoint ScreenToClient(const wxPoint& pt) const
+ { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
// Set the focus to this window
virtual void SetFocus();
wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
#endif
+ // tooltips
+ // create a tooltip with this text
+ void SetToolTip(const wxString &tip);
+ // pointer may be NULL to remove the tooltip
+ void SetToolTip(wxToolTip *tooltip);
+ // get the current tooltip (may return NULL if none)
+ wxToolTip* GetToolTip() const { return m_tooltip; }
+
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
inline wxWindow *GetParent() const;
inline void SetParent(wxWindow *p) ;
inline wxWindow *GetGrandParent() const;
- inline wxList *GetChildren() const;
+ inline wxList& GetChildren() const;
+ // Set this window to be the child of 'parent'.
+ // Returns FALSE it's not possible (some systems
+ // won't allow it)
+ virtual bool Reparent(wxWindow *parent);
// Set/get the window's font
virtual void SetFont(const wxFont& f);
- inline virtual wxFont *GetFont() const;
+ inline virtual wxFont& GetFont() const;
// Set/get the window's validator
void SetValidator(const wxValidator& validator);
// be searched)
void PushEventHandler(wxEvtHandler *handler) ;
wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
-
+
// Close the window by calling OnClose, posting a deletion
virtual bool Close(bool force = FALSE);
// For backward compatibility
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
- inline virtual wxFont *GetLabelFont() const { return GetFont(); };
- inline virtual wxFont *GetButtonFont() const { return GetFont(); };
+ inline virtual wxFont& GetLabelFont() const { return GetFont(); };
+ inline virtual wxFont& GetButtonFont() const { return GetFont(); };
// Get the default button, if there is one
inline virtual wxButton *GetDefaultItem() const;
void OnEraseBackground(wxEraseEvent& event);
void OnChar(wxKeyEvent& event);
- void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event);
// Does this window want to accept keyboard focus?
virtual bool AcceptsFocus() const;
- virtual void PrepareDC( wxDC &dc ) {};
+ virtual void PrepareDC( wxDC& WXUNUSED(dc) ) {};
public:
////////////////////////////////////////////////////////////////////////
//// IMPLEMENTATION
-
+
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
virtual void MSWOnMouseLeave(int x, int y, WXUINT flags);
virtual void MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE);
+ virtual void MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE);
+ virtual void MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE);
virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate);
virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate);
// Detach "Window" menu from menu bar so it doesn't get deleted
void MSWDetachWindowMenu();
-
+
inline WXFARPROC MSWGetOldWndProc() const;
inline void MSWSetOldWndProc(WXFARPROC proc);
// Define for each class of dialog and control
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
inline void SetShowing(bool show);
inline bool IsUserEnabled() const;
protected:
wxAcceleratorTable m_acceleratorTable;
int m_windowId;
- long m_windowStyle; // Store the window's style
- wxEvtHandler * m_windowEventHandler; // Usually is 'this'
+ long m_windowStyle; // Store the window's style
+ wxEvtHandler * m_windowEventHandler; // Usually is 'this'
wxLayoutConstraints * m_constraints; // Constraints for this window
wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
wxSizer * m_windowSizer; // Window's top-level sizer (if any)
WXFARPROC m_oldWndProc;
bool m_useCtl3D; // Using CTL3D for this control
- bool m_inOnSize; // Protection against OnSize reentry
+ bool m_inOnSize; // Protection against OnSize reentry
#ifndef _WX_WIN32__
// Pointer to global memory, for EDIT controls that need
// special treatment to reduce USER area consumption.
#endif //USE_DRAG_AND_DROP
public:
- WXHWND m_hWnd; // MS Windows window handle
+ WXHWND m_hWnd; // MS Windows window handle
WXUINT m_lastMsg;
WXWPARAM m_lastWParam;
WXLPARAM m_lastLParam;
// common part of all ctors
void Init();
+ // the associated tooltip (may be NULL if none)
+ wxToolTip *m_tooltip;
+
DECLARE_EVENT_TABLE()
};
inline void wxWindow::SetId(int id) { m_windowId = id; }
inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
-inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); }
-inline wxList *wxWindow::GetChildren() const { return m_children; }
-inline wxFont *wxWindow::GetFont() const { return (wxFont *) & m_windowFont; }
+inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); }
+inline wxList& wxWindow::GetChildren() const { return (wxList&) *m_children; }
+inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; }
inline wxString wxWindow::GetName() const { return m_windowName; }
inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }