From 2b854a32613f34669af815e1416a6c623a4c2c5b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Feb 1999 14:26:48 +0000 Subject: [PATCH] wxWindow::OnClose() removed completely from wxGTK, wxCloseEvent is now processed properly. Also, fixes for compilation without WXWIN_COMPATIBILITY on. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/docview.h | 8 +- include/wx/event.h | 935 ++++++++++++++++++++----------------- include/wx/gtk/dialog.h | 47 +- include/wx/gtk/minifram.h | 64 +-- include/wx/gtk/window.h | 16 +- include/wx/gtk1/dialog.h | 47 +- include/wx/gtk1/minifram.h | 64 +-- include/wx/gtk1/window.h | 16 +- src/generic/tabg.cpp | 764 +++++++++++++++--------------- src/gtk/dialog.cpp | 128 +++-- src/gtk/frame.cpp | 12 +- src/gtk/window.cpp | 15 +- src/gtk1/dialog.cpp | 128 +++-- src/gtk1/frame.cpp | 12 +- src/gtk1/window.cpp | 15 +- 15 files changed, 1160 insertions(+), 1111 deletions(-) diff --git a/include/wx/docview.h b/include/wx/docview.h index d38e19be92..86ad9c3801 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -187,8 +187,11 @@ class WXDLLEXPORT wxView: public wxEvtHandler // Override to do cleanup/veto close virtual bool OnClose(bool deleteWindow); + +#ifdef WXWIN_COMPATIBILITY // Defeat compiler warning - inline bool OnClose(void) { return wxEvtHandler::OnClose(); } + bool OnClose(void) { return wxEvtHandler::OnClose(); } +#endif // Extend event processing to search the document's event table virtual bool ProcessEvent(wxEvent& event); @@ -197,7 +200,8 @@ class WXDLLEXPORT wxView: public wxEvtHandler // The function then notifies the document manager. virtual void Activate(bool activate); - inline wxDocManager *GetDocumentManager(void) const { return m_viewDocument->GetDocumentManager(); } + wxDocManager *GetDocumentManager(void) const + { return m_viewDocument->GetDocumentManager(); } #if wxUSE_PRINTING_ARCHITECTURE virtual wxPrintout *OnCreatePrintout(void); diff --git a/include/wx/event.h b/include/wx/event.h index 9ab216b3d5..e934c01419 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -6,14 +6,14 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_EVENTH__ #define _WX_EVENTH__ #ifdef __GNUG__ -#pragma interface "event.h" + #pragma interface "event.h" #endif #include "wx/defs.h" @@ -245,7 +245,7 @@ const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; #define wxEVENT_TYPE_SCROLL_PAGEDOWN wxEVT_SCROLL_PAGEDOWN #define wxEVENT_TYPE_SCROLL_THUMBTRACK wxEVT_SCROLL_THUMBTRACK -#endif +#endif // WXWIN_COMPATIBILITY /* * wxWindows events, covering all interesting things that might happen @@ -259,37 +259,38 @@ const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; * */ -class WXDLLEXPORT wxEvent: public wxObject +class WXDLLEXPORT wxEvent : public wxObject { - DECLARE_ABSTRACT_CLASS(wxEvent) + DECLARE_ABSTRACT_CLASS(wxEvent) public: - wxEvent(int id = 0); - inline ~wxEvent(void) {} - - inline void SetEventType(wxEventType typ) { m_eventType = typ; } - inline wxEventType GetEventType(void) const { return m_eventType; } - inline wxObject *GetEventObject(void) const { return m_eventObject; } - inline void SetEventObject(wxObject *obj) { m_eventObject = obj; } - inline long GetTimestamp(void) const { return m_timeStamp; } - inline void SetTimestamp(long ts = 0) { m_timeStamp = ts; } - inline int GetId() const { return m_id; } - inline void SetId(int Id) { m_id = Id; } - - // Can instruct event processor that we wish to ignore this event - // (treat as if the event table entry had not been found) - inline void Skip(bool skip = TRUE) { m_skipped = skip; } - inline bool GetSkipped(void) const { return m_skipped; }; + wxEvent(int id = 0); + ~wxEvent() {} + + void SetEventType(wxEventType typ) { m_eventType = typ; } + wxEventType GetEventType() const { return m_eventType; } + wxObject *GetEventObject() const { return m_eventObject; } + void SetEventObject(wxObject *obj) { m_eventObject = obj; } + long GetTimestamp() const { return m_timeStamp; } + void SetTimestamp(long ts = 0) { m_timeStamp = ts; } + int GetId() const { return m_id; } + void SetId(int Id) { m_id = Id; } + + // Can instruct event processor that we wish to ignore this event + // (treat as if the event table entry had not been found): this must be done + // to allow the event processing by the base classes (calling event.Skip() + // is the analog of calling the base class verstion of a virtual function) + void Skip(bool skip = TRUE) { m_skipped = skip; } + bool GetSkipped() const { return m_skipped; }; public: - bool m_skipped; - wxObject* m_eventObject; - char* m_eventHandle; // Handle of an underlying windowing system event - wxEventType m_eventType; - long m_timeStamp; - int m_id; - wxObject* m_callbackUserData; - + bool m_skipped; + wxObject* m_eventObject; + char* m_eventHandle; // Handle of an underlying windowing system event + wxEventType m_eventType; + long m_timeStamp; + int m_id; + wxObject* m_callbackUserData; }; // Item or menu event class @@ -312,56 +313,57 @@ public: class WXDLLEXPORT wxClientData; -class WXDLLEXPORT wxCommandEvent: public wxEvent +class WXDLLEXPORT wxCommandEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxCommandEvent) + DECLARE_DYNAMIC_CLASS(wxCommandEvent) - wxCommandEvent(wxEventType commandType = wxEVT_NULL, int id = 0); - inline ~wxCommandEvent(void) {} +public: + wxCommandEvent(wxEventType commandType = wxEVT_NULL, int id = 0); + ~wxCommandEvent() {} - /* - * Accessors dependent on context - * - */ + /* + * Accessors dependent on context + * + */ - // Set/Get client data from controls - inline void SetClientData(void* clientData) { m_clientData = clientData; } - inline void *GetClientData() const { return m_clientData; } + // Set/Get client data from controls + void SetClientData(void* clientData) { m_clientData = clientData; } + void *GetClientData() const { return m_clientData; } - // Set/Get client object from controls - inline void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } - inline void *GetClientObject() const { return m_clientObject; } + // Set/Get client object from controls + void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } + void *GetClientObject() const { return m_clientObject; } - // Get listbox selection if single-choice - inline int GetSelection() const { return m_commandInt; } + // Get listbox selection if single-choice + int GetSelection() const { return m_commandInt; } - // Set/Get listbox/choice selection string - inline void SetString(char* s) { m_commandString = s; } - inline char *GetString() const { return m_commandString; } + // Set/Get listbox/choice selection string + void SetString(char* s) { m_commandString = s; } + char *GetString() const { return m_commandString; } - // Get checkbox value - inline bool Checked() const { return (m_commandInt != 0); } + // Get checkbox value + bool Checked() const { return (m_commandInt != 0); } - // TRUE if the listbox event was a selection. - inline bool IsSelection() const { return (m_extraLong != 0); } + // TRUE if the listbox event was a selection. + bool IsSelection() const { return (m_extraLong != 0); } - inline void SetExtraLong(long extraLong) { m_extraLong = extraLong; } - inline long GetExtraLong(void) const { return m_extraLong ; } + void SetExtraLong(long extraLong) { m_extraLong = extraLong; } + long GetExtraLong() const { return m_extraLong ; } - inline void SetInt(int i) { m_commandInt = i; } - inline long GetInt(void) const { return m_commandInt ; } + void SetInt(int i) { m_commandInt = i; } + long GetInt() const { return m_commandInt ; } - public: - char* m_commandString; // String event argument - int m_commandInt; - long m_extraLong; // Additional information (e.g. select/deselect) - void* m_clientData; // Arbitrary client data - wxClientData* m_clientObject; // Arbitrary client object +public: + char* m_commandString; // String event argument + int m_commandInt; + long m_extraLong; // Additional information (e.g. select/deselect) + void* m_clientData; // Arbitrary client data + wxClientData* m_clientObject; // Arbitrary client object }; // this class adds a possibility to react (from the user) code to a control // notification: allow or veto the operation being reported. -class WXDLLEXPORT wxNotifyEvent : public wxCommandEvent +class WXDLLEXPORT wxNotifyEvent : public wxCommandEvent { public: wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int id = 0) @@ -390,23 +392,24 @@ private: wxEVT_SCROLL_THUMBTRACK */ -class WXDLLEXPORT wxScrollEvent: public wxCommandEvent +class WXDLLEXPORT wxScrollEvent : public wxCommandEvent { - DECLARE_DYNAMIC_CLASS(wxScrollEvent) - - public: - wxScrollEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int pos = 0, int orient = 0); - inline ~wxScrollEvent(void) {} + DECLARE_DYNAMIC_CLASS(wxScrollEvent) - /* - * Accessors - * - */ - - inline int GetOrientation(void) const { return (int) m_extraLong ; } - inline int GetPosition(void) const { return m_commandInt ; } - inline void SetOrientation(int orient) { m_extraLong = (long) orient; } - inline void SetPosition(int pos) { m_commandInt = pos; } +public: + wxScrollEvent(wxEventType commandType = wxEVT_NULL, + int id = 0, int pos = 0, int orient = 0); + ~wxScrollEvent() {} + + /* + * Accessors + * + */ + + int GetOrientation() const { return (int) m_extraLong ; } + int GetPosition() const { return m_commandInt ; } + void SetOrientation(int orient) { m_extraLong = (long) orient; } + void SetPosition(int pos) { m_commandInt = pos; } }; // Mouse event class @@ -439,98 +442,106 @@ class WXDLLEXPORT wxScrollEvent: public wxCommandEvent */ class WXDLLEXPORT wxDC; -class WXDLLEXPORT wxMouseEvent: public wxEvent +class WXDLLEXPORT wxMouseEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxMouseEvent) + DECLARE_DYNAMIC_CLASS(wxMouseEvent) - public: - wxMouseEvent(wxEventType mouseType = wxEVT_NULL); +public: + wxMouseEvent(wxEventType mouseType = wxEVT_NULL); - // Was it a button event? (*doesn't* mean: is any button *down*?) - inline bool IsButton(void) const { return Button(-1); } + // Was it a button event? (*doesn't* mean: is any button *down*?) + bool IsButton() const { return Button(-1); } - // Was it a down event from button 1, 2 or 3 or any? - bool ButtonDown(int but = -1) const; + // Was it a down event from button 1, 2 or 3 or any? + bool ButtonDown(int but = -1) const; - // Was it a dclick event from button 1, 2 or 3 or any? - bool ButtonDClick(int but = -1) const; + // Was it a dclick event from button 1, 2 or 3 or any? + bool ButtonDClick(int but = -1) const; - // Was it a up event from button 1, 2 or 3 or any? - bool ButtonUp(int but = -1) const; + // Was it a up event from button 1, 2 or 3 or any? + bool ButtonUp(int but = -1) const; - // Was the given button 1,2,3 or any changing state? - bool Button(int but) const; + // Was the given button 1,2,3 or any changing state? + bool Button(int but) const; - // Was the given button 1,2,3 or any in Down state? - bool ButtonIsDown(int but) const; + // Was the given button 1,2,3 or any in Down state? + bool ButtonIsDown(int but) const; - // Find state of shift/control keys - inline bool ControlDown(void) const { return m_controlDown; } - inline bool MetaDown(void) const { return m_metaDown; } - inline bool AltDown(void) const { return m_altDown; } - inline bool ShiftDown(void) const { return m_shiftDown; } + // Find state of shift/control keys + bool ControlDown() const { return m_controlDown; } + bool MetaDown() const { return m_metaDown; } + bool AltDown() const { return m_altDown; } + bool ShiftDown() const { return m_shiftDown; } - // Find which event was just generated - inline bool LeftDown(void) const { return (m_eventType == wxEVT_LEFT_DOWN); } - inline bool MiddleDown(void) const { return (m_eventType == wxEVT_MIDDLE_DOWN); } - inline bool RightDown(void) const { return (m_eventType == wxEVT_RIGHT_DOWN); } + // Find which event was just generated + bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); } + bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); } + bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); } - inline bool LeftUp(void) const { return (m_eventType == wxEVT_LEFT_UP); } - inline bool MiddleUp(void) const { return (m_eventType == wxEVT_MIDDLE_UP); } - inline bool RightUp(void) const { return (m_eventType == wxEVT_RIGHT_UP); } + bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); } + bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); } + bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); } - inline bool LeftDClick(void) const { return (m_eventType == wxEVT_LEFT_DCLICK); } - inline bool MiddleDClick(void) const { return (m_eventType == wxEVT_MIDDLE_DCLICK); } - inline bool RightDClick(void) const { return (m_eventType == wxEVT_RIGHT_DCLICK); } + bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); } + bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); } + bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); } - // Find the current state of the mouse buttons (regardless - // of current event type) - inline bool LeftIsDown(void) const { return m_leftDown; } - inline bool MiddleIsDown(void) const { return m_middleDown; } - inline bool RightIsDown(void) const { return m_rightDown; } + // Find the current state of the mouse buttons (regardless + // of current event type) + bool LeftIsDown() const { return m_leftDown; } + bool MiddleIsDown() const { return m_middleDown; } + bool RightIsDown() const { return m_rightDown; } - // True if a button is down and the mouse is moving - inline bool Dragging(void) const { return ((m_eventType == wxEVT_MOTION) && (LeftIsDown() || MiddleIsDown() || RightIsDown())); } + // True if a button is down and the mouse is moving + bool Dragging() const + { + return ((m_eventType == wxEVT_MOTION) && + (LeftIsDown() || MiddleIsDown() || RightIsDown())); + } - // True if the mouse is moving, and no button is down - inline bool Moving(void) const { return (m_eventType == wxEVT_MOTION); } + // True if the mouse is moving, and no button is down + bool Moving() const { return (m_eventType == wxEVT_MOTION); } - // True if the mouse is just entering the window - inline bool Entering(void) const { return (m_eventType == wxEVT_ENTER_WINDOW); } + // True if the mouse is just entering the window + bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); } - // True if the mouse is just leaving the window - inline bool Leaving(void) const { return (m_eventType == wxEVT_LEAVE_WINDOW); } + // True if the mouse is just leaving the window + bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); } - // Find the position of the event - inline void Position(long *xpos, long *ypos) const { *xpos = m_x; *ypos = m_y; } + // Find the position of the event + void Position(long *xpos, long *ypos) const { *xpos = m_x; *ypos = m_y; } - // Find the position of the event - inline wxPoint GetPosition() const { return wxPoint(m_x, m_y); } + // Find the position of the event + wxPoint GetPosition() const { return wxPoint(m_x, m_y); } - // Find the logical position of the event given the DC - wxPoint GetLogicalPosition(const wxDC& dc) const ; + // Find the logical position of the event given the DC + wxPoint GetLogicalPosition(const wxDC& dc) const ; - // Compatibility - inline void Position(float *xpos, float *ypos) const { *xpos = (float) m_x; *ypos = (float) m_y; } + // Compatibility +#if WXWIN_COMPATIBILITY + void Position(float *xpos, float *ypos) const + { + *xpos = (float) m_x; *ypos = (float) m_y; + } +#endif // WXWIN_COMPATIBILITY - // Get X position - inline long GetX(void) const { return m_x; } + // Get X position + long GetX() const { return m_x; } - // Get Y position - inline long GetY(void) const { return m_y; } + // Get Y position + long GetY() const { return m_y; } public: - long m_x; - long m_y; - bool m_leftDown; - bool m_middleDown; - bool m_rightDown; - - bool m_controlDown; - bool m_shiftDown; - bool m_altDown; - bool m_metaDown; - + long m_x; + long m_y; + bool m_leftDown; + bool m_middleDown; + bool m_rightDown; + + bool m_controlDown; + bool m_shiftDown; + bool m_altDown; + bool m_metaDown; }; // Keyboard input event class @@ -542,38 +553,41 @@ public: wxEVT_KEY_UP */ -class WXDLLEXPORT wxKeyEvent: public wxEvent +class WXDLLEXPORT wxKeyEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxKeyEvent) + DECLARE_DYNAMIC_CLASS(wxKeyEvent) public: - wxKeyEvent(wxEventType keyType = wxEVT_NULL); + wxKeyEvent(wxEventType keyType = wxEVT_NULL); - // Find state of shift/control keys - inline bool ControlDown(void) const { return m_controlDown; } - inline bool MetaDown(void) const { return m_metaDown; } - inline bool AltDown(void) const { return m_altDown; } - inline bool ShiftDown(void) const { return m_shiftDown; } - inline long KeyCode(void) const { return m_keyCode; } + // Find state of shift/control keys + bool ControlDown() const { return m_controlDown; } + bool MetaDown() const { return m_metaDown; } + bool AltDown() const { return m_altDown; } + bool ShiftDown() const { return m_shiftDown; } + long KeyCode() const { return m_keyCode; } - // Find the position of the event - inline void Position(float *xpos, float *ypos) const { *xpos = m_x; *ypos = m_y; } +#if WXWIN_COMPATIBILITY + // Find the position of the event + void Position(float *xpos, float *ypos) const + { *xpos = (float)m_x; *ypos = (float)m_y; } - // Get X position - inline float GetX(void) const { return m_x; } + // Get X position + float GetX() const { return (float)m_x; } - // Get Y position - inline float GetY(void) const { return m_y; } + // Get Y position + float GetY() const { return (float)m_y; } -public: - float m_x ; - float m_y ; - long m_keyCode; - bool m_controlDown; - bool m_shiftDown; - bool m_altDown; - bool m_metaDown; +#endif // WXWIN_COMPATIBILITY +public: + long m_x; + long m_y; + long m_keyCode; + bool m_controlDown; + bool m_shiftDown; + bool m_altDown; + bool m_metaDown; }; // Size event class @@ -581,18 +595,19 @@ public: wxEVT_SIZE */ -class WXDLLEXPORT wxSizeEvent: public wxEvent +class WXDLLEXPORT wxSizeEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxSizeEvent) + DECLARE_DYNAMIC_CLASS(wxSizeEvent) - public: - wxSize m_size; +public: + wxSize m_size; - inline wxSizeEvent(void) { m_eventType = wxEVT_SIZE; } - inline wxSizeEvent(const wxSize& sz, int id = 0) - { m_eventType = wxEVT_SIZE; m_size.x = sz.x; m_size.y = sz.y; m_id = id; } + wxSizeEvent() { m_eventType = wxEVT_SIZE; } + wxSizeEvent(const wxSize& sz, int id = 0) + : m_size(sz) + { m_eventType = wxEVT_SIZE; m_id = id; } - inline wxSize GetSize(void) const { return m_size; } + wxSize GetSize() const { return m_size; } }; // Move event class @@ -601,18 +616,19 @@ class WXDLLEXPORT wxSizeEvent: public wxEvent wxEVT_MOVE */ -class WXDLLEXPORT wxMoveEvent: public wxEvent +class WXDLLEXPORT wxMoveEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxMoveEvent) + DECLARE_DYNAMIC_CLASS(wxMoveEvent) - public: - wxPoint m_pos; +public: + wxPoint m_pos; - inline wxMoveEvent(void) { m_eventType = wxEVT_MOVE; } - inline wxMoveEvent(const wxPoint& pos, int id = 0) - { m_eventType = wxEVT_MOVE; m_pos.x = pos.x; m_pos.y = pos.y; m_id = id; } + wxMoveEvent() { m_eventType = wxEVT_MOVE; } + wxMoveEvent(const wxPoint& pos, int id = 0) + : m_pos(pos) + { m_eventType = wxEVT_MOVE; m_id = id; } - inline wxPoint GetPosition(void) const { return m_pos; } + wxPoint GetPosition() const { return m_pos; } }; // Paint event class @@ -622,12 +638,12 @@ class WXDLLEXPORT wxMoveEvent: public wxEvent wxEVT_PAINT_ICON */ -class WXDLLEXPORT wxPaintEvent: public wxEvent +class WXDLLEXPORT wxPaintEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxPaintEvent) + DECLARE_DYNAMIC_CLASS(wxPaintEvent) - public: - inline wxPaintEvent(int Id = 0) { m_eventType = wxEVT_PAINT; m_id = Id; } +public: + wxPaintEvent(int Id = 0) { m_eventType = wxEVT_PAINT; m_id = Id; } }; // Erase background event class @@ -636,13 +652,16 @@ class WXDLLEXPORT wxPaintEvent: public wxEvent */ class WXDLLEXPORT wxDC; -class WXDLLEXPORT wxEraseEvent: public wxEvent +class WXDLLEXPORT wxEraseEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxEraseEvent) - public: - wxDC *m_dc ; - inline wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL) { m_eventType = wxEVT_ERASE_BACKGROUND; m_id = Id; m_dc = dc; } - inline wxDC *GetDC() const { return m_dc; } + DECLARE_DYNAMIC_CLASS(wxEraseEvent) + +public: + wxDC *m_dc; + + wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL) + { m_eventType = wxEVT_ERASE_BACKGROUND; m_id = Id; m_dc = dc; } + wxDC *GetDC() const { return m_dc; } }; // Focus event class @@ -651,12 +670,13 @@ class WXDLLEXPORT wxEraseEvent: public wxEvent wxEVT_KILL_FOCUS */ -class WXDLLEXPORT wxFocusEvent: public wxEvent +class WXDLLEXPORT wxFocusEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxFocusEvent) + DECLARE_DYNAMIC_CLASS(wxFocusEvent) - public: - inline wxFocusEvent(wxEventType type = wxEVT_NULL, int Id = 0) { m_eventType = type; m_id = Id; } +public: + wxFocusEvent(wxEventType type = wxEVT_NULL, int Id = 0) + { m_eventType = type; m_id = Id; } }; // Activate event class @@ -665,14 +685,17 @@ class WXDLLEXPORT wxFocusEvent: public wxEvent wxEVT_ACTIVATE_APP */ -class WXDLLEXPORT wxActivateEvent: public wxEvent +class WXDLLEXPORT wxActivateEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxActivateEvent) + DECLARE_DYNAMIC_CLASS(wxActivateEvent) + +public: + wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = TRUE, int Id = 0) + { m_eventType = type; m_active = active; m_id = Id; } + bool GetActive() const { return m_active; } - public: - bool m_active; - inline wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = TRUE, int Id = 0) { m_eventType = type; m_active = active; m_id = Id; } - inline bool GetActive(void) const { return m_active; } +private: + bool m_active; }; // InitDialog event class @@ -680,12 +703,13 @@ class WXDLLEXPORT wxActivateEvent: public wxEvent wxEVT_INIT_DIALOG */ -class WXDLLEXPORT wxInitDialogEvent: public wxEvent +class WXDLLEXPORT wxInitDialogEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxInitDialogEvent) + DECLARE_DYNAMIC_CLASS(wxInitDialogEvent) - public: - inline wxInitDialogEvent(int Id = 0) { m_eventType = wxEVT_INIT_DIALOG; m_id = Id; } +public: + wxInitDialogEvent(int Id = 0) + { m_eventType = wxEVT_INIT_DIALOG; m_id = Id; } }; // Miscellaneous menu event class @@ -697,16 +721,18 @@ class WXDLLEXPORT wxInitDialogEvent: public wxEvent wxEVT_CONTEXT_MENU, */ -class WXDLLEXPORT wxMenuEvent: public wxEvent +class WXDLLEXPORT wxMenuEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxMenuEvent) + DECLARE_DYNAMIC_CLASS(wxMenuEvent) public: - int m_menuId; + wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0) + { m_eventType = type; m_menuId = id; } - inline wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0) { m_eventType = type; m_menuId = id; } + int GetMenuId() const { return m_menuId; } - inline int GetMenuId(void) const { return m_menuId; } +private: + int m_menuId; }; // Window close or session close event class @@ -716,78 +742,92 @@ public: wxEVT_QUERY_END_SESSION */ -class WXDLLEXPORT wxCloseEvent: public wxEvent +class WXDLLEXPORT wxCloseEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxCloseEvent) + DECLARE_DYNAMIC_CLASS(wxCloseEvent) + public: + wxCloseEvent(wxEventType type = wxEVT_NULL, int id = 0) + { + m_eventType = type; + m_loggingOff = TRUE; + m_veto = FALSE; // should be FALSE by default + m_id = id; +#if WXWIN_COMPATIBILITY + m_force = FALSE; +#endif // WXWIN_COMPATIBILITY + m_canVeto = TRUE; + } + + void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } + bool GetLoggingOff() const { return m_loggingOff; } + + void Veto(bool veto = TRUE) { wxASSERT( m_canVeto ); m_veto = veto; } + void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } + bool CanVeto() const { return m_canVeto; } + bool GetVeto() const { wxASSERT( m_canVeto ); return m_veto; } - inline wxCloseEvent(wxEventType type = wxEVT_NULL, int id = 0) - { m_eventType = type; m_loggingOff = TRUE; m_veto = FALSE; - m_id = id; m_force = FALSE; m_canVeto = FALSE; } - - inline void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } - inline bool GetLoggingOff(void) const { return m_loggingOff; } - inline void Veto(bool veto = TRUE) { m_veto = veto; } - inline void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } - inline bool CanVeto() const { return m_canVeto; } - inline bool GetVeto(void) const { return m_veto; } - - // This is probably obsolete now, since we use CanVeto instead, in - // both OnCloseWindow and OnQueryEndSession. - // m_force == ! m_canVeto i.e., can't veto means we must force it to close. - inline void SetForce(bool force) { m_force = force; } - inline bool GetForce(void) const { return m_force; } - - protected: - bool m_loggingOff; - bool m_veto; - bool m_force; - bool m_canVeto; +#if WXWIN_COMPATIBILITY + // This is probably obsolete now, since we use CanVeto instead, in + // both OnCloseWindow and OnQueryEndSession. + // m_force == ! m_canVeto i.e., can't veto means we must force it to close. + void SetForce(bool force) { m_force = force; } + bool GetForce() const { return m_force; } +#endif + +protected: + bool m_loggingOff; + bool m_veto, m_canVeto; + +#if WXWIN_COMPATIBILITY + bool m_force; +#endif }; /* wxEVT_SHOW */ -class WXDLLEXPORT wxShowEvent: public wxEvent +class WXDLLEXPORT wxShowEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxShowEvent) + DECLARE_DYNAMIC_CLASS(wxShowEvent) + public: - inline wxShowEvent(int id = 0, bool show = FALSE) - { m_eventType = wxEVT_SHOW; m_id = id; m_show = show; } + wxShowEvent(int id = 0, bool show = FALSE) + { m_eventType = wxEVT_SHOW; m_id = id; m_show = show; } - inline void SetShow(bool show) { m_show = show; } - inline bool GetShow(void) const { return m_show; } + void SetShow(bool show) { m_show = show; } + bool GetShow() const { return m_show; } protected: - bool m_show; + bool m_show; }; /* wxEVT_ICONIZE */ -class WXDLLEXPORT wxIconizeEvent: public wxEvent +class WXDLLEXPORT wxIconizeEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxIconizeEvent) -public: + DECLARE_DYNAMIC_CLASS(wxIconizeEvent) - inline wxIconizeEvent(int id = 0) - { m_eventType = wxEVT_ICONIZE; m_id = id; } +public: + wxIconizeEvent(int id = 0) + { m_eventType = wxEVT_ICONIZE; m_id = id; } }; /* wxEVT_MAXIMIZE */ -class WXDLLEXPORT wxMaximizeEvent: public wxEvent +class WXDLLEXPORT wxMaximizeEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxMaximizeEvent) -public: + DECLARE_DYNAMIC_CLASS(wxMaximizeEvent) - inline wxMaximizeEvent(int id = 0) - { m_eventType = wxEVT_MAXIMIZE; m_id = id; } +public: + wxMaximizeEvent(int id = 0) + { m_eventType = wxEVT_MAXIMIZE; m_id = id; } }; // Joystick event class @@ -809,57 +849,66 @@ public: #define wxJOY_BUTTON4 8 #define wxJOY_BUTTON_ANY -1 -class WXDLLEXPORT wxJoystickEvent: public wxEvent +class WXDLLEXPORT wxJoystickEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxJoystickEvent) - - public: - wxPoint m_pos; - int m_zPosition; - int m_buttonChange; // Which button changed? - int m_buttonState; // Which buttons are down? - int m_joyStick; // Which joystick? - - inline wxJoystickEvent(wxEventType type = wxEVT_NULL, int state = 0, int joystick = wxJOYSTICK1, int change = 0) - { m_eventType = type; m_buttonState = state; m_pos = wxPoint(0,0); m_zPosition = 0; - m_joyStick = joystick; m_buttonChange = change; } - - inline wxPoint GetPosition(void) const { return m_pos; } - inline int GetZPosition(void) const { return m_zPosition; } - inline int GetButtonState(void) const { return m_buttonState; } - inline int GetButtonChange(void) const { return m_buttonChange; } - inline int GetJoystick(void) const { return m_joyStick; } - - inline void SetJoystick(int stick) { m_joyStick = stick; } - inline void SetButtonState(int state) { m_buttonState = state; } - inline void SetButtonChange(int change) { m_buttonChange = change; } - inline void SetPosition(const wxPoint& pos) { m_pos = pos; } - inline void SetZPosition(int zPos) { m_zPosition = zPos; } - - // Was it a button event? (*doesn't* mean: is any button *down*?) - inline bool IsButton(void) const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) || - (GetEventType() == wxEVT_JOY_BUTTON_DOWN)); } - - // Was it a move event? - inline bool IsMove(void) const { return (GetEventType() == wxEVT_JOY_MOVE) ; } - - // Was it a zmove event? - inline bool IsZMove(void) const { return (GetEventType() == wxEVT_JOY_ZMOVE) ; } - - // Was it a down event from button 1, 2, 3, 4 or any? - inline bool ButtonDown(int but = wxJOY_BUTTON_ANY) const + DECLARE_DYNAMIC_CLASS(wxJoystickEvent) + +public: + wxPoint m_pos; + int m_zPosition; + int m_buttonChange; // Which button changed? + int m_buttonState; // Which buttons are down? + int m_joyStick; // Which joystick? + + wxJoystickEvent(wxEventType type = wxEVT_NULL, + int state = 0, + int joystick = wxJOYSTICK1, + int change = 0) + { + m_eventType = type; + m_buttonState = state; + m_pos = wxPoint(0,0); + m_zPosition = 0; + m_joyStick = joystick; + m_buttonChange = change; + } + + wxPoint GetPosition() const { return m_pos; } + int GetZPosition() const { return m_zPosition; } + int GetButtonState() const { return m_buttonState; } + int GetButtonChange() const { return m_buttonChange; } + int GetJoystick() const { return m_joyStick; } + + void SetJoystick(int stick) { m_joyStick = stick; } + void SetButtonState(int state) { m_buttonState = state; } + void SetButtonChange(int change) { m_buttonChange = change; } + void SetPosition(const wxPoint& pos) { m_pos = pos; } + void SetZPosition(int zPos) { m_zPosition = zPos; } + + // Was it a button event? (*doesn't* mean: is any button *down*?) + bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) || + (GetEventType() == wxEVT_JOY_BUTTON_DOWN)); } + + // Was it a move event? + bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE) ; } + + // Was it a zmove event? + bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE) ; } + + // Was it a down event from button 1, 2, 3, 4 or any? + bool ButtonDown(int but = wxJOY_BUTTON_ANY) const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) && - ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } + ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } - // Was it a up event from button 1, 2, 3 or any? - inline bool ButtonUp(int but = wxJOY_BUTTON_ANY) const + // Was it a up event from button 1, 2, 3 or any? + bool ButtonUp(int but = wxJOY_BUTTON_ANY) const { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) && - ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } + ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); } - // Was the given button 1,2,3,4 or any in Down state? - inline bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const + // Was the given button 1,2,3,4 or any in Down state? + bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) || - ((m_buttonState & but) == but)); } + ((m_buttonState & but) == but)); } }; // Drop files event class @@ -867,21 +916,23 @@ class WXDLLEXPORT wxJoystickEvent: public wxEvent wxEVT_DROP_FILES */ -class WXDLLEXPORT wxDropFilesEvent: public wxEvent +class WXDLLEXPORT wxDropFilesEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxDropFilesEvent) - - public: - int m_noFiles; - wxPoint m_pos; - wxString* m_files; // Memory (de)allocated by code calling ProcessEvent - - inline wxDropFilesEvent(wxEventType type = wxEVT_NULL, int noFiles = 0, wxString *files = (wxString *) NULL) - { m_eventType = type; m_noFiles = noFiles; m_files = files; } + DECLARE_DYNAMIC_CLASS(wxDropFilesEvent) - inline wxPoint GetPosition(void) const { return m_pos; } - inline int GetNumberOfFiles(void) const { return m_noFiles; } - inline wxString *GetFiles(void) const { return m_files; } +public: + int m_noFiles; + wxPoint m_pos; + wxString* m_files; // Memory (de)allocated by code calling ProcessEvent + + wxDropFilesEvent(wxEventType type = wxEVT_NULL, + int noFiles = 0, + wxString *files = (wxString *) NULL) + { m_eventType = type; m_noFiles = noFiles; m_files = files; } + + wxPoint GetPosition() const { return m_pos; } + int GetNumberOfFiles() const { return m_noFiles; } + wxString *GetFiles() const { return m_files; } }; // Idle event @@ -889,19 +940,19 @@ class WXDLLEXPORT wxDropFilesEvent: public wxEvent wxEVT_IDLE */ -class WXDLLEXPORT wxIdleEvent: public wxEvent +class WXDLLEXPORT wxIdleEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxIdleEvent) + DECLARE_DYNAMIC_CLASS(wxIdleEvent) public: - inline wxIdleEvent(void) - { m_eventType = wxEVT_IDLE; m_requestMore = FALSE; } + wxIdleEvent() + { m_eventType = wxEVT_IDLE; m_requestMore = FALSE; } - inline void RequestMore(bool needMore = TRUE) { m_requestMore = needMore; } - inline bool MoreRequested(void) const { return m_requestMore; } + void RequestMore(bool needMore = TRUE) { m_requestMore = needMore; } + bool MoreRequested() const { return m_requestMore; } protected: - bool m_requestMore; + bool m_requestMore; }; // Update UI event @@ -912,35 +963,41 @@ protected: class WXDLLEXPORT wxMenu; class WXDLLEXPORT wxWindow; -class WXDLLEXPORT wxUpdateUIEvent: public wxCommandEvent +class WXDLLEXPORT wxUpdateUIEvent : public wxCommandEvent { - DECLARE_DYNAMIC_CLASS(wxUpdateUIEvent) - - inline wxUpdateUIEvent(wxWindowID commandId = 0) - { m_eventType = wxEVT_UPDATE_UI; m_id = commandId; - m_checked = FALSE; m_setChecked = FALSE; m_enabled = FALSE; m_setEnabled = FALSE; - m_setText = FALSE; m_text = ""; } + DECLARE_DYNAMIC_CLASS(wxUpdateUIEvent) - inline bool GetChecked(void) const { return m_checked; } - inline bool GetEnabled(void) const { return m_enabled; } - inline wxString GetText(void) const { return m_text; } - inline bool GetSetText(void) const { return m_setText; } - inline bool GetSetChecked(void) const { return m_setChecked; } - inline bool GetSetEnabled(void) const { return m_setEnabled; } - - inline void Check(bool check) { m_checked = check; m_setChecked = TRUE; } - inline void Enable(bool enable) { m_enabled = enable; m_setEnabled = TRUE; } - inline void SetText(const wxString& text) { m_text = text; m_setText = TRUE; } - - protected: - - bool m_checked; - bool m_enabled; - bool m_setEnabled; - bool m_setText; - bool m_setChecked; - wxString m_text; +public: + wxUpdateUIEvent(wxWindowID commandId = 0) + { + m_eventType = wxEVT_UPDATE_UI; + m_id = commandId; + m_checked = FALSE; + m_setChecked = FALSE; + m_enabled = FALSE; + m_setEnabled = FALSE; + m_setText = FALSE; + m_text = ""; + } + + bool GetChecked() const { return m_checked; } + bool GetEnabled() const { return m_enabled; } + wxString GetText() const { return m_text; } + bool GetSetText() const { return m_setText; } + bool GetSetChecked() const { return m_setChecked; } + bool GetSetEnabled() const { return m_setEnabled; } + + void Check(bool check) { m_checked = check; m_setChecked = TRUE; } + void Enable(bool enable) { m_enabled = enable; m_setEnabled = TRUE; } + void SetText(const wxString& text) { m_text = text; m_setText = TRUE; } +protected: + bool m_checked; + bool m_enabled; + bool m_setEnabled; + bool m_setText; + bool m_setChecked; + wxString m_text; }; /* @@ -948,32 +1005,35 @@ class WXDLLEXPORT wxUpdateUIEvent: public wxCommandEvent */ // TODO: shouldn't all events record the window ID? -class WXDLLEXPORT wxSysColourChangedEvent: public wxEvent +class WXDLLEXPORT wxSysColourChangedEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent) + DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent) - public: - inline wxSysColourChangedEvent(void) - { m_eventType = wxEVT_SYS_COLOUR_CHANGED; } +public: + wxSysColourChangedEvent() + { m_eventType = wxEVT_SYS_COLOUR_CHANGED; } }; /* wxEVT_PALETTE_CHANGED */ -class WXDLLEXPORT wxPaletteChangedEvent: public wxEvent +class WXDLLEXPORT wxPaletteChangedEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxPaletteChangedEvent) + DECLARE_DYNAMIC_CLASS(wxPaletteChangedEvent) public: - inline wxPaletteChangedEvent(wxWindowID id = 0): wxEvent(id) - { m_eventType = wxEVT_PALETTE_CHANGED; m_changedWindow = (wxWindow *) NULL; } + wxPaletteChangedEvent(wxWindowID id = 0) : wxEvent(id) + { + m_eventType = wxEVT_PALETTE_CHANGED; + m_changedWindow = (wxWindow *) NULL; + } - inline void SetChangedWindow(wxWindow* win) { m_changedWindow = win; } - inline wxWindow* GetChangedWindow() const { return m_changedWindow; } + void SetChangedWindow(wxWindow* win) { m_changedWindow = win; } + wxWindow* GetChangedWindow() const { return m_changedWindow; } protected: - wxWindow* m_changedWindow; + wxWindow* m_changedWindow; }; /* @@ -981,20 +1041,20 @@ protected: Indicates the window is getting keyboard focus and should re-do its palette. */ -class WXDLLEXPORT wxQueryNewPaletteEvent: public wxEvent +class WXDLLEXPORT wxQueryNewPaletteEvent : public wxEvent { - DECLARE_DYNAMIC_CLASS(wxQueryNewPaletteEvent) + DECLARE_DYNAMIC_CLASS(wxQueryNewPaletteEvent) public: - inline wxQueryNewPaletteEvent(wxWindowID id = 0): wxEvent(id) - { m_eventType = wxEVT_QUERY_NEW_PALETTE; m_paletteRealized = FALSE; } + wxQueryNewPaletteEvent(wxWindowID id = 0): wxEvent(id) + { m_eventType = wxEVT_QUERY_NEW_PALETTE; m_paletteRealized = FALSE; } - // App sets this if it changes the palette. - inline void SetPaletteRealized(bool realized) { m_paletteRealized = realized; } - inline bool GetPaletteRealized() const { return m_paletteRealized; } + // App sets this if it changes the palette. + void SetPaletteRealized(bool realized) { m_paletteRealized = realized; } + bool GetPaletteRealized() const { return m_paletteRealized; } protected: - bool m_paletteRealized; + bool m_paletteRealized; }; /* @@ -1002,26 +1062,26 @@ protected: wxEVT_NAVIGATION_KEY */ // must derive from command event to be propagated to the parent -class WXDLLEXPORT wxNavigationKeyEvent : public wxCommandEvent +class WXDLLEXPORT wxNavigationKeyEvent : public wxCommandEvent { - DECLARE_DYNAMIC_CLASS(wxNavigationKeyEvent) + DECLARE_DYNAMIC_CLASS(wxNavigationKeyEvent) public: - wxNavigationKeyEvent() : wxCommandEvent(wxEVT_NAVIGATION_KEY) { } + wxNavigationKeyEvent() : wxCommandEvent(wxEVT_NAVIGATION_KEY) { } - // direction: forward (true) or backward (false) - bool GetDirection() const { return m_commandInt == 1; } - void SetDirection(bool bForward) { m_commandInt = bForward; } + // direction: forward (true) or backward (false) + bool GetDirection() const { return m_commandInt == 1; } + void SetDirection(bool bForward) { m_commandInt = bForward; } - // it may be a window change event (MDI, notebook pages...) or a control - // change event - bool IsWindowChange() const { return m_extraLong == 1; } - void SetWindowChange(bool bIs) { m_extraLong = bIs; } + // it may be a window change event (MDI, notebook pages...) or a control + // change event + bool IsWindowChange() const { return m_extraLong == 1; } + void SetWindowChange(bool bIs) { m_extraLong = bIs; } - // the child which has the focus currently (may be NULL - use - // wxWindow::FindFocus then) - wxWindow* GetCurrentFocus() const { return (wxWindow *)m_clientData; } - void SetCurrentFocus(wxWindow *win) { m_clientData = (void *)win; } + // the child which has the focus currently (may be NULL - use + // wxWindow::FindFocus then) + wxWindow* GetCurrentFocus() const { return (wxWindow *)m_clientData; } + void SetCurrentFocus(wxWindow *win) { m_clientData = (void *)win; } }; /* TODO @@ -1047,69 +1107,78 @@ typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); struct WXDLLEXPORT wxEventTableEntry { // For some reason, this can't be wxEventType, or VC++ complains. - int m_eventType; // main event type - int m_id; // control/menu/toolbar id - int m_lastId; // used for ranges of ids - wxObjectEventFunction m_fn; // function to call: not wxEventFunction, because - // of dependency problems - wxObject* m_callbackUserData; + int m_eventType; // main event type + int m_id; // control/menu/toolbar id + int m_lastId; // used for ranges of ids + wxObjectEventFunction m_fn; // function to call: not wxEventFunction, + // because of dependency problems + + wxObject* m_callbackUserData; }; struct WXDLLEXPORT wxEventTable { - const wxEventTable *baseTable; // Points to base event table (next in chain) - const wxEventTableEntry *entries; // Points to bottom of entry array + const wxEventTable *baseTable; // Points to base event table (next in chain) + const wxEventTableEntry *entries; // Points to bottom of entry array }; -class WXDLLEXPORT wxEvtHandler: public wxObject +class WXDLLEXPORT wxEvtHandler : public wxObject { - DECLARE_DYNAMIC_CLASS(wxEvtHandler) - public: - wxEvtHandler(void); - ~wxEvtHandler(void); - - inline wxEvtHandler *GetNextHandler(void) const { return m_nextHandler; } - inline wxEvtHandler *GetPreviousHandler(void) const { return m_previousHandler; } - inline void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } - inline void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } - - inline void SetEvtHandlerEnabled(bool en) { m_enabled = en; } - inline bool GetEvtHandlerEnabled(void) const { return m_enabled; } - - inline virtual void OnCommand(wxWindow& WXUNUSED(win), wxCommandEvent& WXUNUSED(event)) {}; - // Called if child control has no - // callback function - // Default behaviour - virtual long Default(void) { if (GetNextHandler()) return GetNextHandler()->Default(); else return 0; }; - - virtual bool OnClose(void); - - virtual bool ProcessEvent(wxEvent& event); - virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); - - // Dynamic association of a member function handler with the event handler, id and event type - void Connect( int id, int lastId, wxEventType eventType, - wxObjectEventFunction func, - wxObject *userData = (wxObject *) NULL ); - - // Convenience function: take just one id - inline void Connect( int id, wxEventType eventType, - wxObjectEventFunction func, - wxObject *userData = (wxObject *) NULL ) { Connect(id, -1, eventType, func, userData); } - - bool SearchDynamicEventTable( wxEvent& event ); + DECLARE_DYNAMIC_CLASS(wxEvtHandler) + +public: + wxEvtHandler(); + ~wxEvtHandler(); + + wxEvtHandler *GetNextHandler() const { return m_nextHandler; } + wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; } + void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; } + void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; } + + void SetEvtHandlerEnabled(bool en) { m_enabled = en; } + bool GetEvtHandlerEnabled() const { return m_enabled; } + + virtual void OnCommand(wxWindow& WXUNUSED(win), + wxCommandEvent& WXUNUSED(event)) + { + } + + // Called if child control has no + // callback function + // Default behaviour + virtual long Default() + { return GetNextHandler() ? GetNextHandler()->Default() : 0; }; + + virtual bool OnClose(); + + virtual bool ProcessEvent(wxEvent& event); + virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); + + // Dynamic association of a member function handler with the event handler, + // id and event type + void Connect( int id, int lastId, wxEventType eventType, + wxObjectEventFunction func, + wxObject *userData = (wxObject *) NULL ); + + // Convenience function: take just one id + void Connect( int id, wxEventType eventType, + wxObjectEventFunction func, + wxObject *userData = (wxObject *) NULL ) + { Connect(id, -1, eventType, func, userData); } + + bool SearchDynamicEventTable( wxEvent& event ); private: - static const wxEventTableEntry sm_eventTableEntries[]; + static const wxEventTableEntry sm_eventTableEntries[]; + protected: - static const wxEventTable sm_eventTable; - virtual const wxEventTable* GetEventTable() const; + static const wxEventTable sm_eventTable; + virtual const wxEventTable* GetEventTable() const; protected: wxEvtHandler* m_nextHandler; wxEvtHandler* m_previousHandler; bool m_enabled; // Is event handler enabled? wxList* m_dynamicEvents; - }; typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); @@ -1143,20 +1212,20 @@ typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEv #define DECLARE_EVENT_TABLE() \ private:\ - static const wxEventTableEntry sm_eventTableEntries[];\ + static const wxEventTableEntry sm_eventTableEntries[];\ protected:\ - static const wxEventTable sm_eventTable;\ - virtual const wxEventTable* GetEventTable() const; + static const wxEventTable sm_eventTable;\ + virtual const wxEventTable* GetEventTable() const; #define BEGIN_EVENT_TABLE(theClass, baseClass) \ const wxEventTable *theClass::GetEventTable() const { return &theClass::sm_eventTable; }\ const wxEventTable theClass::sm_eventTable =\ - { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };\ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };\ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ #define END_EVENT_TABLE() \ { 0, 0, 0, 0, 0 } }; - + /* * Event table macros */ @@ -1323,4 +1392,4 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ { wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL },\ #endif - // _WX_EVENTH__ + // _WX_EVENTH__ diff --git a/include/wx/gtk/dialog.h b/include/wx/gtk/dialog.h index 25cfa99c37..d896ea47dd 100644 --- a/include/wx/gtk/dialog.h +++ b/include/wx/gtk/dialog.h @@ -5,7 +5,7 @@ // Created: // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __GTKDIALOGH__ @@ -41,24 +41,23 @@ class wxDialog: public wxPanel public: wxDialog(); - wxDialog( wxWindow *parent, wxWindowID id, + wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); - bool Create( wxWindow *parent, wxWindowID id, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString &name = wxDialogNameStr ); + bool Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString &name = wxDialogNameStr ); ~wxDialog(); - + void SetTitle(const wxString& title); wxString GetTitle() const; - - bool OnClose(); + void OnApply( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event ); void OnOK( wxCommandEvent &event ); @@ -67,39 +66,39 @@ public: /* void OnCharHook( wxKeyEvent& event ); */ - + bool Destroy(); void OnCloseWindow( wxCloseEvent& event ); - + virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); virtual void SetSize( int width, int height ); - + virtual bool Show( bool show ); virtual int ShowModal(); virtual void EndModal( int retCode ); virtual bool IsModal() const; void SetModal( bool modal ); - + virtual void InitDialog(void); - + virtual void Centre( int direction = wxHORIZONTAL ); - + virtual void SetIcon( const wxIcon &icon ); virtual void Iconize( bool WXUNUSED(iconize)) { } virtual bool IsIconized() const { return FALSE; } bool Iconized() const { return IsIconized(); } virtual void Maximize() { } virtual void Restore() { } - + // implementation - + virtual void GtkOnSize( int x, int y, int width, int height ); - + bool m_modalShowing; wxString m_title; wxIcon m_icon; - + DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk/minifram.h b/include/wx/gtk/minifram.h index 9f1ebaa345..3747e49ffc 100644 --- a/include/wx/gtk/minifram.h +++ b/include/wx/gtk/minifram.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __GTKMINIFRAMEH__ @@ -28,41 +28,41 @@ class wxMiniFrame; // wxMiniFrame //----------------------------------------------------------------------------- -class wxMiniFrame: public wxFrame +class wxMiniFrame: public wxFrame { - DECLARE_DYNAMIC_CLASS(wxMiniFrame) + DECLARE_DYNAMIC_CLASS(wxMiniFrame) public: - inline wxMiniFrame(void) {} - inline wxMiniFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr) - { - Create(parent, id, title, pos, size, style, name); - } - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr); - - // implementation - - bool m_isDragging; - int m_oldX,m_oldY; - int m_diffX,m_diffY; - - void DrawFrame( int x, int y ); - void OnPaint( wxPaintEvent &event ); - void OnMouse( wxMouseEvent &event ); + wxMiniFrame() {} + wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } - DECLARE_EVENT_TABLE() + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr); + + // implementation + bool m_isDragging; + int m_oldX,m_oldY; + int m_diffX,m_diffY; + + void DrawFrame( int x, int y ); + void OnPaint( wxPaintEvent &event ); + void OnMouse( wxMouseEvent &event ); + + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 1f1985b579..6d460d0530 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -184,7 +184,6 @@ public: virtual void MakeModal( bool modal ); virtual bool IsEnabled() const { return m_isEnabled; } inline bool Enabled() const { return IsEnabled(); } - virtual bool OnClose(); virtual void SetFocus(); static wxWindow *FindFocus(); @@ -195,6 +194,7 @@ public: virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); + wxWindow *GetParent() const { return m_parent; } wxWindow *GetGrandParent() const @@ -260,10 +260,10 @@ public: virtual wxFont& GetFont() { return m_font; } // 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() { return GetFont(); }; - inline virtual wxFont& GetButtonFont() { return GetFont(); }; + virtual void SetButtonFont(const wxFont& font) { SetFont(font); } + virtual void SetLabelFont(const wxFont& font) { SetFont(font); } + virtual wxFont& GetLabelFont() { return GetFont(); }; + virtual wxFont& GetButtonFont() { return GetFont(); }; virtual void SetWindowStyleFlag( long flag ); virtual long GetWindowStyleFlag() const; @@ -277,7 +277,7 @@ public: virtual wxString GetName() const; virtual wxString GetLabel() const; - void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {}; + void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) { } void OnKeyDown( wxKeyEvent &event ); virtual bool IsShown() const; @@ -289,8 +289,8 @@ public: virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( const wxString& name ); - void AllowDoubleClick( bool WXUNUSED(allow) ) {}; - void SetDoubleClick( bool WXUNUSED(allow) ) {}; + void AllowDoubleClick( bool WXUNUSED(allow) ) { } + void SetDoubleClick( bool WXUNUSED(allow) ) { } virtual void ClientToScreen( int *x, int *y ); virtual void ScreenToClient( int *x, int *y ); diff --git a/include/wx/gtk1/dialog.h b/include/wx/gtk1/dialog.h index 25cfa99c37..d896ea47dd 100644 --- a/include/wx/gtk1/dialog.h +++ b/include/wx/gtk1/dialog.h @@ -5,7 +5,7 @@ // Created: // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __GTKDIALOGH__ @@ -41,24 +41,23 @@ class wxDialog: public wxPanel public: wxDialog(); - wxDialog( wxWindow *parent, wxWindowID id, + wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); - bool Create( wxWindow *parent, wxWindowID id, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString &name = wxDialogNameStr ); + bool Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString &name = wxDialogNameStr ); ~wxDialog(); - + void SetTitle(const wxString& title); wxString GetTitle() const; - - bool OnClose(); + void OnApply( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event ); void OnOK( wxCommandEvent &event ); @@ -67,39 +66,39 @@ public: /* void OnCharHook( wxKeyEvent& event ); */ - + bool Destroy(); void OnCloseWindow( wxCloseEvent& event ); - + virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); virtual void SetSize( int width, int height ); - + virtual bool Show( bool show ); virtual int ShowModal(); virtual void EndModal( int retCode ); virtual bool IsModal() const; void SetModal( bool modal ); - + virtual void InitDialog(void); - + virtual void Centre( int direction = wxHORIZONTAL ); - + virtual void SetIcon( const wxIcon &icon ); virtual void Iconize( bool WXUNUSED(iconize)) { } virtual bool IsIconized() const { return FALSE; } bool Iconized() const { return IsIconized(); } virtual void Maximize() { } virtual void Restore() { } - + // implementation - + virtual void GtkOnSize( int x, int y, int width, int height ); - + bool m_modalShowing; wxString m_title; wxIcon m_icon; - + DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk1/minifram.h b/include/wx/gtk1/minifram.h index 9f1ebaa345..3747e49ffc 100644 --- a/include/wx/gtk1/minifram.h +++ b/include/wx/gtk1/minifram.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __GTKMINIFRAMEH__ @@ -28,41 +28,41 @@ class wxMiniFrame; // wxMiniFrame //----------------------------------------------------------------------------- -class wxMiniFrame: public wxFrame +class wxMiniFrame: public wxFrame { - DECLARE_DYNAMIC_CLASS(wxMiniFrame) + DECLARE_DYNAMIC_CLASS(wxMiniFrame) public: - inline wxMiniFrame(void) {} - inline wxMiniFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr) - { - Create(parent, id, title, pos, size, style, name); - } - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr); - - // implementation - - bool m_isDragging; - int m_oldX,m_oldY; - int m_diffX,m_diffY; - - void DrawFrame( int x, int y ); - void OnPaint( wxPaintEvent &event ); - void OnMouse( wxMouseEvent &event ); + wxMiniFrame() {} + wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } - DECLARE_EVENT_TABLE() + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr); + + // implementation + bool m_isDragging; + int m_oldX,m_oldY; + int m_diffX,m_diffY; + + void DrawFrame( int x, int y ); + void OnPaint( wxPaintEvent &event ); + void OnMouse( wxMouseEvent &event ); + + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 1f1985b579..6d460d0530 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -184,7 +184,6 @@ public: virtual void MakeModal( bool modal ); virtual bool IsEnabled() const { return m_isEnabled; } inline bool Enabled() const { return IsEnabled(); } - virtual bool OnClose(); virtual void SetFocus(); static wxWindow *FindFocus(); @@ -195,6 +194,7 @@ public: virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); + wxWindow *GetParent() const { return m_parent; } wxWindow *GetGrandParent() const @@ -260,10 +260,10 @@ public: virtual wxFont& GetFont() { return m_font; } // 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() { return GetFont(); }; - inline virtual wxFont& GetButtonFont() { return GetFont(); }; + virtual void SetButtonFont(const wxFont& font) { SetFont(font); } + virtual void SetLabelFont(const wxFont& font) { SetFont(font); } + virtual wxFont& GetLabelFont() { return GetFont(); }; + virtual wxFont& GetButtonFont() { return GetFont(); }; virtual void SetWindowStyleFlag( long flag ); virtual long GetWindowStyleFlag() const; @@ -277,7 +277,7 @@ public: virtual wxString GetName() const; virtual wxString GetLabel() const; - void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {}; + void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) { } void OnKeyDown( wxKeyEvent &event ); virtual bool IsShown() const; @@ -289,8 +289,8 @@ public: virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( const wxString& name ); - void AllowDoubleClick( bool WXUNUSED(allow) ) {}; - void SetDoubleClick( bool WXUNUSED(allow) ) {}; + void AllowDoubleClick( bool WXUNUSED(allow) ) { } + void SetDoubleClick( bool WXUNUSED(allow) ) { } virtual void ClientToScreen( int *x, int *y ); virtual void ScreenToClient( int *x, int *y ); diff --git a/src/generic/tabg.cpp b/src/generic/tabg.cpp index 297d93d55e..7da066a106 100644 --- a/src/generic/tabg.cpp +++ b/src/generic/tabg.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -55,18 +55,18 @@ wxTabControl::wxTabControl(wxTabView *v) wxTabControl::~wxTabControl(void) { } - + void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) { // Old, but in some ways better (drawing opaque tabs) #ifndef wxUSE_NEW_METHOD if (!m_view) return; - + // Top-left of tab view area int viewX = m_view->GetViewRect().x; int viewY = m_view->GetViewRect().y; - + // Top-left of tab control int tabX = GetX() + viewX; int tabY = GetY() + viewY; @@ -76,7 +76,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); tabY -= tabHeightInc; } - + dc.SetPen(*wxTRANSPARENT_PEN); // Draw grey background @@ -91,7 +91,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); #endif } - + // Draw highlight and shadow dc.SetPen(*m_view->GetHighlightPen()); @@ -146,7 +146,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) if (lastInRow) { // 25/5/97 UNLESS it's less than the max number of positions in this row - + int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); int maxPositions = ((wxTabLayer *)m_view->GetLayers().Nth(0)->Data())->Number(); @@ -191,7 +191,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) (tabY + GetHeight() + tabHeightInc - subtractThis)); } } - + // Draw centered text int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; @@ -229,258 +229,258 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) #else // New HEL version with rounder tabs - if (!m_view) return; - - int tabInc = 0; - if (m_isSelected) - { - tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); - } - int tabLeft = GetX() + m_view->GetViewRect().x; - int tabTop = GetY() + m_view->GetViewRect().y - tabInc; - int tabRight = tabLeft + m_view->GetTabWidth(); - int left = m_view->GetViewRect().x; - int top = tabTop + m_view->GetTabHeight() + tabInc; - int right = left + m_view->GetViewRect().width; - int bottom = top + m_view->GetViewRect().height; - - if (m_isSelected) - { - // TAB is selected - draw TAB and the View's full outline - - dc.SetPen(*(m_view->GetHighlightPen())); - wxPoint pnts[10]; - int n = 0; - pnts[n].x = left; pnts[n++].y = bottom; - pnts[n].x = left; pnts[n++].y = top; - pnts[n].x = tabLeft; pnts[n++].y = top; - pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; - pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; - pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; - dc.DrawLines(n, pnts); - if (!lastInRow) - { - dc.DrawLine( - (tabRight + 2), - top, - right, - top - ); - } - - dc.SetPen(*(m_view->GetShadowPen())); - dc.DrawLine( - tabRight, - tabTop + 2, - tabRight, - top - ); - dc.DrawLine( - right, - top, - right, - bottom - ); - dc.DrawLine( - right, - bottom, - left, - bottom - ); - - dc.SetPen(*wxBLACK_PEN); - dc.DrawPoint( - tabRight, - tabTop + 1 - ); - dc.DrawPoint( - tabRight + 1, - tabTop + 2 - ); - if (lastInRow) - { - dc.DrawLine( - tabRight + 1, - bottom, - tabRight + 1, - tabTop + 1 - ); - } - else - { - dc.DrawLine( - tabRight + 1, - tabTop + 2, - tabRight + 1, - top - ); - dc.DrawLine( - right + 1, - top, - right + 1, - bottom + 1 - ); - } - dc.DrawLine( - right + 1, - bottom + 1, - left + 1, - bottom + 1 - ); - } - else - { - // TAB is not selected - just draw TAB outline and RH edge - // if the TAB is the last in the row - - int maxPositions = ((wxTabLayer*)m_view->GetLayers().Nth(0)->Data())->Number(); - wxTabControl* tabBelow = 0; - wxTabControl* tabBelowRight = 0; - if (GetColPosition() > 0) - { - tabBelow = m_view->FindTabControlForPosition( - GetColPosition() - 1, - GetRowPosition() - ); - } - if (!lastInRow && GetColPosition() > 0) - { - tabBelowRight = m_view->FindTabControlForPosition( - GetColPosition() - 1, - GetRowPosition() + 1 - ); - } - - float raisedTop = top - m_view->GetTabSelectionHeight() + - m_view->GetTabHeight(); - - dc.SetPen(*(m_view->GetHighlightPen())); - wxPoint pnts[10]; - int n = 0; - - pnts[n].x = tabLeft; - - if (tabBelow && tabBelow->IsSelected()) - { - pnts[n++].y = (long)raisedTop; - } - else - { - pnts[n++].y = top; - } - pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; - pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; - pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; - dc.DrawLines(n, pnts); - - dc.SetPen(*(m_view->GetShadowPen())); - if (GetRowPosition() >= maxPositions - 1) - { - dc.DrawLine( - tabRight, - (tabTop + 2), - tabRight, - bottom - ); - dc.DrawLine( - tabRight, - bottom, - (tabRight - m_view->GetHorizontalTabOffset()), - bottom - ); - } - else - { - if (tabBelowRight && tabBelowRight->IsSelected()) - { - dc.DrawLine( - tabRight, - (long)raisedTop, - tabRight, - tabTop + 1 - ); - } - else - { - dc.DrawLine( - tabRight, - top - 1, - tabRight, - tabTop + 1 - ); - } - } - - dc.SetPen(*wxBLACK_PEN); - dc.DrawPoint( - tabRight, - tabTop + 1 - ); - dc.DrawPoint( - tabRight + 1, - tabTop + 2 - ); - if (GetRowPosition() >= maxPositions - 1) - { - // draw right hand edge to bottom of view - dc.DrawLine( - tabRight + 1, - bottom + 1, - tabRight + 1, - tabTop + 2 - ); - dc.DrawLine( - tabRight + 1, - bottom + 1, - (tabRight - m_view->GetHorizontalTabOffset()), - bottom + 1 - ); - } - else - { - // draw right hand edge of TAB - if (tabBelowRight && tabBelowRight->IsSelected()) - { - dc.DrawLine( - tabRight + 1, - (long)(raisedTop - 1), - tabRight + 1, - tabTop + 2 - ); - } - else - { - dc.DrawLine( - tabRight + 1, - top - 1, - tabRight + 1, - tabTop + 2 - ); - } - } - } - - // Draw centered text - dc.SetPen(*wxBLACK_PEN); - if (m_isSelected) - { - dc.SetFont(*(m_view->GetSelectedTabFont())); - } - else - { - dc.SetFont(*(GetFont())); - } - - wxColour col(m_view->GetTextColour()); - dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); - long textWidth, textHeight; - dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); - - float textX = (tabLeft + tabRight - textWidth) / 2; - float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); - - dc.DrawText(GetLabel(), (long)textX, (long)textY); + if (!m_view) return; + + int tabInc = 0; + if (m_isSelected) + { + tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); + } + int tabLeft = GetX() + m_view->GetViewRect().x; + int tabTop = GetY() + m_view->GetViewRect().y - tabInc; + int tabRight = tabLeft + m_view->GetTabWidth(); + int left = m_view->GetViewRect().x; + int top = tabTop + m_view->GetTabHeight() + tabInc; + int right = left + m_view->GetViewRect().width; + int bottom = top + m_view->GetViewRect().height; + + if (m_isSelected) + { + // TAB is selected - draw TAB and the View's full outline + + dc.SetPen(*(m_view->GetHighlightPen())); + wxPoint pnts[10]; + int n = 0; + pnts[n].x = left; pnts[n++].y = bottom; + pnts[n].x = left; pnts[n++].y = top; + pnts[n].x = tabLeft; pnts[n++].y = top; + pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; + pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; + pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; + dc.DrawLines(n, pnts); + if (!lastInRow) + { + dc.DrawLine( + (tabRight + 2), + top, + right, + top + ); + } + + dc.SetPen(*(m_view->GetShadowPen())); + dc.DrawLine( + tabRight, + tabTop + 2, + tabRight, + top + ); + dc.DrawLine( + right, + top, + right, + bottom + ); + dc.DrawLine( + right, + bottom, + left, + bottom + ); + + dc.SetPen(*wxBLACK_PEN); + dc.DrawPoint( + tabRight, + tabTop + 1 + ); + dc.DrawPoint( + tabRight + 1, + tabTop + 2 + ); + if (lastInRow) + { + dc.DrawLine( + tabRight + 1, + bottom, + tabRight + 1, + tabTop + 1 + ); + } + else + { + dc.DrawLine( + tabRight + 1, + tabTop + 2, + tabRight + 1, + top + ); + dc.DrawLine( + right + 1, + top, + right + 1, + bottom + 1 + ); + } + dc.DrawLine( + right + 1, + bottom + 1, + left + 1, + bottom + 1 + ); + } + else + { + // TAB is not selected - just draw TAB outline and RH edge + // if the TAB is the last in the row + + int maxPositions = ((wxTabLayer*)m_view->GetLayers().Nth(0)->Data())->Number(); + wxTabControl* tabBelow = 0; + wxTabControl* tabBelowRight = 0; + if (GetColPosition() > 0) + { + tabBelow = m_view->FindTabControlForPosition( + GetColPosition() - 1, + GetRowPosition() + ); + } + if (!lastInRow && GetColPosition() > 0) + { + tabBelowRight = m_view->FindTabControlForPosition( + GetColPosition() - 1, + GetRowPosition() + 1 + ); + } + + float raisedTop = top - m_view->GetTabSelectionHeight() + + m_view->GetTabHeight(); + + dc.SetPen(*(m_view->GetHighlightPen())); + wxPoint pnts[10]; + int n = 0; + + pnts[n].x = tabLeft; + + if (tabBelow && tabBelow->IsSelected()) + { + pnts[n++].y = (long)raisedTop; + } + else + { + pnts[n++].y = top; + } + pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; + pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; + pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; + dc.DrawLines(n, pnts); + + dc.SetPen(*(m_view->GetShadowPen())); + if (GetRowPosition() >= maxPositions - 1) + { + dc.DrawLine( + tabRight, + (tabTop + 2), + tabRight, + bottom + ); + dc.DrawLine( + tabRight, + bottom, + (tabRight - m_view->GetHorizontalTabOffset()), + bottom + ); + } + else + { + if (tabBelowRight && tabBelowRight->IsSelected()) + { + dc.DrawLine( + tabRight, + (long)raisedTop, + tabRight, + tabTop + 1 + ); + } + else + { + dc.DrawLine( + tabRight, + top - 1, + tabRight, + tabTop + 1 + ); + } + } + + dc.SetPen(*wxBLACK_PEN); + dc.DrawPoint( + tabRight, + tabTop + 1 + ); + dc.DrawPoint( + tabRight + 1, + tabTop + 2 + ); + if (GetRowPosition() >= maxPositions - 1) + { + // draw right hand edge to bottom of view + dc.DrawLine( + tabRight + 1, + bottom + 1, + tabRight + 1, + tabTop + 2 + ); + dc.DrawLine( + tabRight + 1, + bottom + 1, + (tabRight - m_view->GetHorizontalTabOffset()), + bottom + 1 + ); + } + else + { + // draw right hand edge of TAB + if (tabBelowRight && tabBelowRight->IsSelected()) + { + dc.DrawLine( + tabRight + 1, + (long)(raisedTop - 1), + tabRight + 1, + tabTop + 2 + ); + } + else + { + dc.DrawLine( + tabRight + 1, + top - 1, + tabRight + 1, + tabTop + 2 + ); + } + } + } + + // Draw centered text + dc.SetPen(*wxBLACK_PEN); + if (m_isSelected) + { + dc.SetFont(*(m_view->GetSelectedTabFont())); + } + else + { + dc.SetFont(*(GetFont())); + } + + wxColour col(m_view->GetTextColour()); + dc.SetTextForeground(col); + dc.SetBackgroundMode(wxTRANSPARENT); + long textWidth, textHeight; + dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); + + float textX = (tabLeft + tabRight - textWidth) / 2; + float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); + + dc.DrawText(GetLabel(), (long)textX, (long)textY); #endif } @@ -493,7 +493,7 @@ bool wxTabControl::HitTest(int x, int y) const // Bottom-right int tabX2 = tabX1 + GetWidth(); int tabY2 = tabY1 + GetHeight(); - + if (x >= tabX1 && y >= tabY1 && x <= tabX2 && y <= tabY2) return TRUE; else @@ -535,7 +535,7 @@ wxTabView::~wxTabView() { ClearTabs(TRUE); } - + // Automatically positions tabs // TODO: this should just add the tab to a list, and then // a layout function (e.g. Realize) should be called when all tabs have been added. @@ -571,17 +571,17 @@ wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *exi } } int layer = m_layers.Number() - 1; - + wxTabControl *tabControl = existingTab; if (!existingTab) tabControl = OnCreateTabControl(); tabControl->SetRowPosition(tabLayer->Number()); tabControl->SetColPosition(layer); - + wxTabControl *lastTab = (wxTabControl *) NULL; if (lastTabNode) lastTab = (wxTabControl *)lastTabNode->Data(); - + // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left @@ -590,16 +590,16 @@ wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *exi horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); - + tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); tabControl->SetId(id); tabControl->SetLabel(label); tabControl->SetFont(* GetTabFont()); - + tabLayer->Append(tabControl); m_noTabs ++; - + return tabControl; } @@ -650,7 +650,7 @@ wxString wxTabView::GetTabText(int id) const else return control->GetLabel(); } - + // Returns the total height of the tabs component -- this may be several // times the height of a tab, if there are several tab layers (rows). int wxTabView::GetTotalTabHeight() @@ -726,12 +726,12 @@ void wxTabView::Layout(void) delete layerNode; layerNode = nextLayerNode; } - + wxTabControl *lastTab = (wxTabControl *) NULL; - + wxTabLayer *currentLayer = new wxTabLayer; m_layers.Append(currentLayer); - + wxNode *node = controls.First(); while (node) { @@ -752,12 +752,12 @@ void wxTabView::Layout(void) lastTab = (wxTabControl *) NULL; } } - + int layer = m_layers.Number() - 1; tabControl->SetRowPosition(currentLayer->Number()); tabControl->SetColPosition(layer); - + // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left @@ -766,7 +766,7 @@ void wxTabView::Layout(void) horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); - + tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); @@ -790,96 +790,96 @@ void wxTabView::Draw(wxDC& dc) if (GetNumberOfTabs() == 0) return; - // Draw top margin area (beneath tabs and above view area) - if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) - { - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(*GetBackgroundBrush()); - - // Add 1 because the pen is transparent. Under Motif, may be different. - dc.DrawRectangle( - m_tabViewRect.x, - (m_tabViewRect.y - m_topMargin), - (m_tabViewRect.width + 1), - (m_topMargin + 1) - ); - } - - // Draw layers in reverse order - wxNode *node = m_layers.Last(); - while (node) - { - wxTabLayer *layer = (wxTabLayer *)node->Data(); - wxNode *node2 = layer->First(); - while (node2) - { - wxTabControl *control = (wxTabControl *)node2->Data(); - control->OnDraw(dc, (node2->Next() == NULL)); - node2 = node2->Next(); - } - - node = node->Previous(); - } + // Draw top margin area (beneath tabs and above view area) + if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) + { + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(*GetBackgroundBrush()); + + // Add 1 because the pen is transparent. Under Motif, may be different. + dc.DrawRectangle( + m_tabViewRect.x, + (m_tabViewRect.y - m_topMargin), + (m_tabViewRect.width + 1), + (m_topMargin + 1) + ); + } + + // Draw layers in reverse order + wxNode *node = m_layers.Last(); + while (node) + { + wxTabLayer *layer = (wxTabLayer *)node->Data(); + wxNode *node2 = layer->First(); + while (node2) + { + wxTabControl *control = (wxTabControl *)node2->Data(); + control->OnDraw(dc, (node2->Next() == NULL)); + node2 = node2->Next(); + } + + node = node->Previous(); + } #ifndef wxUSE_NEW_METHOD - if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX) - { - dc.SetPen(* GetShadowPen()); - - // Draw bottom line - dc.DrawLine( - (GetViewRect().x + 1), - (GetViewRect().y + GetViewRect().height), - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y + GetViewRect().height) - ); - - // Draw right line - dc.DrawLine( - (GetViewRect().x + GetViewRect().width), - (GetViewRect().y - GetTopMargin() + 1), - (GetViewRect().x + GetViewRect().width), - (GetViewRect().y + GetViewRect().height) - ); - - dc.SetPen(* wxBLACK_PEN); - - // Draw bottom line - dc.DrawLine( - (GetViewRect().x), - (GetViewRect().y + GetViewRect().height + 1), + if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX) + { + dc.SetPen(* GetShadowPen()); + + // Draw bottom line + dc.DrawLine( + (GetViewRect().x + 1), + (GetViewRect().y + GetViewRect().height), + (GetViewRect().x + GetViewRect().width + 1), + (GetViewRect().y + GetViewRect().height) + ); + + // Draw right line + dc.DrawLine( + (GetViewRect().x + GetViewRect().width), + (GetViewRect().y - GetTopMargin() + 1), + (GetViewRect().x + GetViewRect().width), + (GetViewRect().y + GetViewRect().height) + ); + + dc.SetPen(* wxBLACK_PEN); + + // Draw bottom line + dc.DrawLine( + (GetViewRect().x), + (GetViewRect().y + GetViewRect().height + 1), #if defined(__WXMOTIF__) - (GetViewRect().x + GetViewRect().width + 1), + (GetViewRect().x + GetViewRect().width + 1), #else - (GetViewRect().x + GetViewRect().width + 2), + (GetViewRect().x + GetViewRect().width + 2), #endif - (GetViewRect().y + GetViewRect().height + 1) - ); - - // Draw right line - dc.DrawLine( - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y - GetTopMargin()), - (GetViewRect().x + GetViewRect().width + 1), - (GetViewRect().y + GetViewRect().height + 1) - ); - } + (GetViewRect().y + GetViewRect().height + 1) + ); + + // Draw right line + dc.DrawLine( + (GetViewRect().x + GetViewRect().width + 1), + (GetViewRect().y - GetTopMargin()), + (GetViewRect().x + GetViewRect().width + 1), + (GetViewRect().y + GetViewRect().height + 1) + ); + } #endif } - + // Process mouse event, return FALSE if we didn't process it bool wxTabView::OnEvent(wxMouseEvent& event) { if (!event.LeftDown()) return FALSE; - - float x, y; + + long x, y; event.Position(&x, &y); - + wxTabControl *hitControl = (wxTabControl *) NULL; - + wxNode *node = m_layers.First(); while (node) { @@ -897,21 +897,21 @@ bool wxTabView::OnEvent(wxMouseEvent& event) else node2 = node2->Next(); } - + if (node) node = node->Next(); } - + if (!hitControl) return FALSE; - + wxTabControl *currentTab = FindTabControlForId(m_tabSelection); - + if (hitControl == currentTab) return FALSE; - + ChangeTab(hitControl); - + return TRUE; } @@ -921,13 +921,13 @@ bool wxTabView::ChangeTab(wxTabControl *control) int oldTab = -1; if (currentTab) oldTab = currentTab->GetId(); - + if (control == currentTab) return TRUE; - + if (m_layers.Number() == 0) return FALSE; - + if (!OnTabPreActivate(control->GetId(), oldTab)) return FALSE; @@ -936,12 +936,12 @@ bool wxTabView::ChangeTab(wxTabControl *control) if (currentTab) currentTab->SetSelected(FALSE); - + control->SetSelected(TRUE); m_tabSelection = control->GetId(); OnTabActivate(control->GetId(), oldTab); - + // Leave window refresh for the implementing window return TRUE; @@ -953,9 +953,9 @@ bool wxTabView::MoveSelectionTab(wxTabControl *control) { if (m_layers.Number() == 0) return FALSE; - + wxTabLayer *firstLayer = (wxTabLayer *)m_layers.First()->Data(); - + // Find what column this tab is at, so we can swap with the one at the bottom. // If we're on the bottom layer, then no need to swap. if (!firstLayer->Member(control)) @@ -968,29 +968,29 @@ bool wxTabView::MoveSelectionTab(wxTabControl *control) wxNode *otherNode = firstLayer->Nth(col); if (!otherNode) return FALSE; - + // If this is already in the bottom layer, return now if (otherNode == thisNode) return TRUE; - + wxTabControl *otherTab = (wxTabControl *)otherNode->Data(); - + // We now have pointers to the tab to be changed to, // and the tab on the first layer. Swap tab structures and // position details. - + int thisX = control->GetX(); int thisY = control->GetY(); int thisColPos = control->GetColPosition(); int otherX = otherTab->GetX(); int otherY = otherTab->GetY(); int otherColPos = otherTab->GetColPosition(); - + control->SetPosition(otherX, otherY); control->SetColPosition(otherColPos); otherTab->SetPosition(thisX, thisY); otherTab->SetColPosition(thisColPos); - + // Swap the data for the nodes thisNode->SetData(otherTab); otherNode->SetData(control); @@ -1002,7 +1002,7 @@ bool wxTabView::MoveSelectionTab(wxTabControl *control) void wxTabView::OnTabActivate(int /*activateId*/, int /*deactivateId*/) { } - + void wxTabView::SetHighlightColour(const wxColour& col) { m_highlightColour = col; @@ -1030,7 +1030,7 @@ void wxTabView::SetTabSelection(int sel, bool activateTool) if (!OnTabPreActivate(sel, oldSel)) return; - + if (control) control->SetSelected((sel != -1)); // TODO ?? else if (sel != -1) @@ -1041,12 +1041,12 @@ void wxTabView::SetTabSelection(int sel, bool activateTool) if (oldControl) oldControl->SetSelected(FALSE); - + m_tabSelection = sel; if (control) MoveSelectionTab(control); - + if (activateTool) OnTabActivate(sel, oldSel); } @@ -1122,7 +1122,7 @@ int wxTabView::CalculateTabWidth(int noTabs, bool adjustView) /* * wxTabbedDialog */ - + IMPLEMENT_CLASS(wxTabbedDialog, wxDialog) BEGIN_EVENT_TABLE(wxTabbedDialog, wxDialog) @@ -1145,7 +1145,7 @@ wxTabbedDialog::~wxTabbedDialog(void) if (m_tabView) delete m_tabView; } - + void wxTabbedDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) ) { Destroy(); @@ -1167,7 +1167,7 @@ void wxTabbedDialog::OnPaint(wxPaintEvent& WXUNUSED(event) ) /* * wxTabbedPanel */ - + IMPLEMENT_CLASS(wxTabbedPanel, wxPanel) BEGIN_EVENT_TABLE(wxTabbedPanel, wxPanel) @@ -1186,7 +1186,7 @@ wxTabbedPanel::~wxTabbedPanel(void) { delete m_tabView; } - + void wxTabbedPanel::OnMouseEvent(wxMouseEvent& event) { if (m_tabView) @@ -1203,9 +1203,9 @@ void wxTabbedPanel::OnPaint(wxPaintEvent& WXUNUSED(event) ) /* * wxPanelTabView */ - + IMPLEMENT_CLASS(wxPanelTabView, wxTabView) - + wxPanelTabView::wxPanelTabView(wxPanel *pan, long style): wxTabView(style), m_tabWindows(wxKEY_INTEGER) { m_panel = pan; @@ -1229,7 +1229,7 @@ void wxPanelTabView::OnTabActivate(int activateId, int deactivateId) { if (!m_panel) return; - + wxWindow *oldWindow = ((deactivateId == -1) ? 0 : GetTabWindow(deactivateId)); wxWindow *newWindow = GetTabWindow(activateId); @@ -1237,11 +1237,11 @@ void wxPanelTabView::OnTabActivate(int activateId, int deactivateId) oldWindow->Show(FALSE); if (newWindow) newWindow->Show(TRUE); - + m_panel->Refresh(); } - + void wxPanelTabView::AddTabWindow(int id, wxWindow *window) { m_tabWindows.Append((long)id, window); @@ -1253,7 +1253,7 @@ wxWindow *wxPanelTabView::GetTabWindow(int id) const wxNode *node = m_tabWindows.Find((long)id); if (!node) return (wxWindow *) NULL; - return (wxWindow *)node->Data(); + return (wxWindow *)node->Data(); } void wxPanelTabView::ClearWindows(bool deleteWindows) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index e1da79d411..16bd99d503 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -28,14 +28,14 @@ extern wxList wxPendingDelete; //----------------------------------------------------------------------------- bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ +{ /* printf( "OnDelete from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - + win->Close(); return TRUE; @@ -97,9 +97,9 @@ wxDialog::wxDialog() m_modalShowing = FALSE; } -wxDialog::wxDialog( wxWindow *parent, +wxDialog::wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, + const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { m_modalShowing = FALSE; @@ -108,60 +108,60 @@ wxDialog::wxDialog( wxWindow *parent, bool wxDialog::Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, + const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { wxTopLevelWindows.Append( this ); - + m_needParent = FALSE; - + PreCreation( parent, id, pos, size, style, name ); - + m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - + gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL); - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", + + gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); - + m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - + gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - + SetTitle( title ); - + if ((m_x != -1) || (m_y != -1)) gtk_widget_set_uposition( m_widget, m_x, m_y ); - + gtk_widget_set_usize( m_widget, m_width, m_height ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); - + gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this ); if (m_parent) m_parent->AddChild( this ); - + PostCreation(); - + return TRUE; } wxDialog::~wxDialog() { wxTopLevelWindows.DeleteObject( this ); - + if (wxTheApp->GetTopWindow() == this) { wxTheApp->SetTopWindow( (wxWindow*) NULL ); } - + if (wxTopLevelWindows.Number() == 0) - { + { wxTheApp->ExitMainLoop(); } } @@ -200,7 +200,7 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { if ( Validate() && TransferDataFromWindow()) { - if (IsModal()) + if (IsModal()) { EndModal(wxID_OK); } @@ -214,23 +214,25 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) { - // yes + // yes } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { static wxList closing; - if (closing.Member(this)) return FALSE; // no loops - + if (closing.Member(this)) + return; // no loops + closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); closing.DeleteObject(this); - - return FALSE; + + if ( event.CanVeto() ) + event.Veto(); } bool wxDialog::Destroy() @@ -240,14 +242,6 @@ bool wxDialog::Destroy() return TRUE; } -void wxDialog::OnCloseWindow( wxCloseEvent& event ) -{ - if (GetEventHandler()->OnClose() || event.GetForce()) - { - this->Destroy(); - } -} - void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { // due to a bug in gtk, x,y are always 0 @@ -257,10 +251,10 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh if ((m_height == height) && (m_width == width) && (m_sizeSet)) return; if (!m_wxwindow) return; - + m_width = width; m_height = height; - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; @@ -269,7 +263,7 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh gtk_widget_set_usize( m_widget, m_width, m_height ); m_sizeSet = TRUE; - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); @@ -278,16 +272,16 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); - + if (GetAutoLayout()) { Layout(); } - else + else { // no child: go out ! if (!GetChildren().First()) return; - + // do we have exactly one child? wxWindow *child = (wxWindow *) NULL; for(wxNode *node = GetChildren().First(); node; node = node->Next()) @@ -295,7 +289,7 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) wxWindow *win = (wxWindow *)node->Data(); if (!wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog)) { - // it's the second one: do nothing + // it's the second one: do nothing if (child) return; child = win; } @@ -311,7 +305,7 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - + // Don't do anything for children of wxMDIChildFrame if (!m_wxwindow) return; @@ -322,7 +316,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) int old_y = m_y; int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -347,7 +341,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; @@ -355,15 +349,15 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_x != -1) || (m_y != -1)) { - if ((m_x != old_x) || (m_y != old_y)) + if ((m_x != old_x) || (m_y != old_y)) gtk_widget_set_uposition( m_widget, m_x, m_y ); } - + if ((m_width != old_width) || (m_height != old_height)) { gtk_widget_set_usize( m_widget, m_width, m_height ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); @@ -381,13 +375,13 @@ void wxDialog::SetSize( int width, int height ) void wxDialog::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int x = 0; int y = 0; - + if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - + Move( x, y ); } @@ -399,9 +393,9 @@ bool wxDialog::Show( bool show ) } wxWindow::Show( show ); - + if (show) InitDialog(); - + return TRUE; } @@ -430,30 +424,30 @@ int wxDialog::ShowModal() } Show( TRUE ); - + m_modalShowing = TRUE; - + gtk_grab_add( m_widget ); gtk_main(); gtk_grab_remove( m_widget ); - + return GetReturnCode(); } void wxDialog::EndModal( int retCode ) { SetReturnCode( retCode ); - + if (!IsModal()) { wxFAIL_MSG( "wxDialog:EndModal called twice" ); return; } - + m_modalShowing = FALSE; - + gtk_main_quit(); - + Show( FALSE ); } @@ -466,10 +460,10 @@ void wxDialog::SetIcon( const wxIcon &icon ) { m_icon = icon; if (!icon.Ok()) return; - + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); - + gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index af7887cf2c..b96f0a96b2 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -104,7 +104,6 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC BEGIN_EVENT_TABLE(wxFrame, wxWindow) EVT_SIZE(wxFrame::OnSize) - EVT_CLOSE(wxFrame::OnCloseWindow) EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) END_EVENT_TABLE() @@ -197,14 +196,14 @@ wxFrame::~wxFrame() if (m_frameToolBar) delete m_frameToolBar; wxTopLevelWindows.DeleteObject( this ); - + if (wxTheApp->GetTopWindow() == this) { wxTheApp->SetTopWindow( (wxWindow*) NULL ); } - + if (wxTopLevelWindows.Number() == 0) - { + { wxTheApp->ExitMainLoop(); } } @@ -226,11 +225,6 @@ bool wxFrame::Show( bool show ) return wxWindow::Show( show ); } -void wxFrame::OnCloseWindow( wxCloseEvent &event ) -{ - if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); -} - bool wxFrame::Destroy() { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 90bf2685d1..787c96e000 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1716,9 +1716,15 @@ bool wxWindow::Close( bool force ) wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); - event.SetForce(force); + event.SetCanVeto(!force); - return GetEventHandler()->ProcessEvent(event); + (void)GetEventHandler()->ProcessEvent(event); + + // when we're forced to close we do it anyhow, otherwise only if the + // application didn't forbid it (if the event wasn't processed, GetVeto() + // will return FALSE too) + if ( force || !event.GetVeto() ) + Destroy(); } bool wxWindow::Destroy() @@ -2235,11 +2241,6 @@ bool wxWindow::AcceptsFocus() const return IsEnabled() && IsShown() && m_acceptsFocus; } -bool wxWindow::OnClose() -{ - return TRUE; -} - void wxWindow::AddChild( wxWindow *child ) { wxCHECK_RET( (m_widget != NULL), "invalid window" ); diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index e1da79d411..16bd99d503 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -28,14 +28,14 @@ extern wxList wxPendingDelete; //----------------------------------------------------------------------------- bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ +{ /* printf( "OnDelete from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - + win->Close(); return TRUE; @@ -97,9 +97,9 @@ wxDialog::wxDialog() m_modalShowing = FALSE; } -wxDialog::wxDialog( wxWindow *parent, +wxDialog::wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, + const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { m_modalShowing = FALSE; @@ -108,60 +108,60 @@ wxDialog::wxDialog( wxWindow *parent, bool wxDialog::Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, + const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { wxTopLevelWindows.Append( this ); - + m_needParent = FALSE; - + PreCreation( parent, id, pos, size, style, name ); - + m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - + gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL); - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", + + gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); - + m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - + gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - + SetTitle( title ); - + if ((m_x != -1) || (m_y != -1)) gtk_widget_set_uposition( m_widget, m_x, m_y ); - + gtk_widget_set_usize( m_widget, m_width, m_height ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); - + gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this ); if (m_parent) m_parent->AddChild( this ); - + PostCreation(); - + return TRUE; } wxDialog::~wxDialog() { wxTopLevelWindows.DeleteObject( this ); - + if (wxTheApp->GetTopWindow() == this) { wxTheApp->SetTopWindow( (wxWindow*) NULL ); } - + if (wxTopLevelWindows.Number() == 0) - { + { wxTheApp->ExitMainLoop(); } } @@ -200,7 +200,7 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { if ( Validate() && TransferDataFromWindow()) { - if (IsModal()) + if (IsModal()) { EndModal(wxID_OK); } @@ -214,23 +214,25 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) { - // yes + // yes } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { static wxList closing; - if (closing.Member(this)) return FALSE; // no loops - + if (closing.Member(this)) + return; // no loops + closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); closing.DeleteObject(this); - - return FALSE; + + if ( event.CanVeto() ) + event.Veto(); } bool wxDialog::Destroy() @@ -240,14 +242,6 @@ bool wxDialog::Destroy() return TRUE; } -void wxDialog::OnCloseWindow( wxCloseEvent& event ) -{ - if (GetEventHandler()->OnClose() || event.GetForce()) - { - this->Destroy(); - } -} - void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { // due to a bug in gtk, x,y are always 0 @@ -257,10 +251,10 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh if ((m_height == height) && (m_width == width) && (m_sizeSet)) return; if (!m_wxwindow) return; - + m_width = width; m_height = height; - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; @@ -269,7 +263,7 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh gtk_widget_set_usize( m_widget, m_width, m_height ); m_sizeSet = TRUE; - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); @@ -278,16 +272,16 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); - + if (GetAutoLayout()) { Layout(); } - else + else { // no child: go out ! if (!GetChildren().First()) return; - + // do we have exactly one child? wxWindow *child = (wxWindow *) NULL; for(wxNode *node = GetChildren().First(); node; node = node->Next()) @@ -295,7 +289,7 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) wxWindow *win = (wxWindow *)node->Data(); if (!wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog)) { - // it's the second one: do nothing + // it's the second one: do nothing if (child) return; child = win; } @@ -311,7 +305,7 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - + // Don't do anything for children of wxMDIChildFrame if (!m_wxwindow) return; @@ -322,7 +316,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) int old_y = m_y; int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -347,7 +341,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; @@ -355,15 +349,15 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_x != -1) || (m_y != -1)) { - if ((m_x != old_x) || (m_y != old_y)) + if ((m_x != old_x) || (m_y != old_y)) gtk_widget_set_uposition( m_widget, m_x, m_y ); } - + if ((m_width != old_width) || (m_height != old_height)) { gtk_widget_set_usize( m_widget, m_width, m_height ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); @@ -381,13 +375,13 @@ void wxDialog::SetSize( int width, int height ) void wxDialog::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int x = 0; int y = 0; - + if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - + Move( x, y ); } @@ -399,9 +393,9 @@ bool wxDialog::Show( bool show ) } wxWindow::Show( show ); - + if (show) InitDialog(); - + return TRUE; } @@ -430,30 +424,30 @@ int wxDialog::ShowModal() } Show( TRUE ); - + m_modalShowing = TRUE; - + gtk_grab_add( m_widget ); gtk_main(); gtk_grab_remove( m_widget ); - + return GetReturnCode(); } void wxDialog::EndModal( int retCode ) { SetReturnCode( retCode ); - + if (!IsModal()) { wxFAIL_MSG( "wxDialog:EndModal called twice" ); return; } - + m_modalShowing = FALSE; - + gtk_main_quit(); - + Show( FALSE ); } @@ -466,10 +460,10 @@ void wxDialog::SetIcon( const wxIcon &icon ) { m_icon = icon; if (!icon.Ok()) return; - + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); - + gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index af7887cf2c..b96f0a96b2 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -104,7 +104,6 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC BEGIN_EVENT_TABLE(wxFrame, wxWindow) EVT_SIZE(wxFrame::OnSize) - EVT_CLOSE(wxFrame::OnCloseWindow) EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) END_EVENT_TABLE() @@ -197,14 +196,14 @@ wxFrame::~wxFrame() if (m_frameToolBar) delete m_frameToolBar; wxTopLevelWindows.DeleteObject( this ); - + if (wxTheApp->GetTopWindow() == this) { wxTheApp->SetTopWindow( (wxWindow*) NULL ); } - + if (wxTopLevelWindows.Number() == 0) - { + { wxTheApp->ExitMainLoop(); } } @@ -226,11 +225,6 @@ bool wxFrame::Show( bool show ) return wxWindow::Show( show ); } -void wxFrame::OnCloseWindow( wxCloseEvent &event ) -{ - if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); -} - bool wxFrame::Destroy() { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 90bf2685d1..787c96e000 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1716,9 +1716,15 @@ bool wxWindow::Close( bool force ) wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); - event.SetForce(force); + event.SetCanVeto(!force); - return GetEventHandler()->ProcessEvent(event); + (void)GetEventHandler()->ProcessEvent(event); + + // when we're forced to close we do it anyhow, otherwise only if the + // application didn't forbid it (if the event wasn't processed, GetVeto() + // will return FALSE too) + if ( force || !event.GetVeto() ) + Destroy(); } bool wxWindow::Destroy() @@ -2235,11 +2241,6 @@ bool wxWindow::AcceptsFocus() const return IsEnabled() && IsShown() && m_acceptsFocus; } -bool wxWindow::OnClose() -{ - return TRUE; -} - void wxWindow::AddChild( wxWindow *child ) { wxCHECK_RET( (m_widget != NULL), "invalid window" ); -- 2.45.2