From 43a18898651f71010606d8682fdf88cfc1c02193 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 15 Nov 1998 17:57:55 +0000 Subject: [PATCH] Added new wxBitmapButton implementation Build fixes in base classes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/bmpbuttn.h | 72 +++++--- include/wx/gtk/dialog.h | 99 ++++++----- include/wx/gtk/frame.h | 1 + include/wx/gtk1/bmpbuttn.h | 72 +++++--- include/wx/gtk1/dialog.h | 99 ++++++----- include/wx/gtk1/frame.h | 1 + src/gtk/bmpbuttn.cpp | 256 +++++++++++++++++++++------ src/gtk/dialog.cpp | 28 +-- src/gtk/frame.cpp | 16 +- src/gtk/window.cpp | 346 ++++++++++++++++++------------------- src/gtk1/bmpbuttn.cpp | 256 +++++++++++++++++++++------ src/gtk1/dialog.cpp | 28 +-- src/gtk1/frame.cpp | 16 +- src/gtk1/window.cpp | 346 ++++++++++++++++++------------------- 14 files changed, 1004 insertions(+), 632 deletions(-) diff --git a/include/wx/gtk/bmpbuttn.h b/include/wx/gtk/bmpbuttn.h index bcb31a9e90..827f5f4d32 100644 --- a/include/wx/gtk/bmpbuttn.h +++ b/include/wx/gtk/bmpbuttn.h @@ -40,36 +40,54 @@ class wxBitmapButton: public wxControl { DECLARE_DYNAMIC_CLASS(wxBitmapButton) - public: - - wxBitmapButton(void); - inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - { +public: + wxBitmapButton(); + inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr ) + { Create(parent, id, bitmap, pos, size, style, validator, name); - } - bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - void SetDefault(void); - void SetLabel( const wxString &label ); - wxString GetLabel(void) const; - virtual void SetLabel(const wxBitmap& bitmap) { SetBitmapLabel(bitmap); } - virtual void SetBitmapLabel( const wxBitmap& bitmap ); - wxBitmap& GetBitmapLabel(void) const { return (wxBitmap&) m_bitmap; } + } + bool Create( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr); + void SetDefault(); - // implementation - - void ApplyWidgetStyle(); + void SetLabel( const wxString &label ); + wxString GetLabel() const; + virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); } - public: - - wxBitmap m_bitmap; + wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_disabled; } + wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_focus; } + wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_bitmap; } + wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_selected; } + + void SetBitmapDisabled( const wxBitmap& bitmap ); + void SetBitmapFocus( const wxBitmap& bitmap ); + void SetBitmapLabel( const wxBitmap& bitmap ); + void SetBitmapSelected( const wxBitmap& bitmap ); + virtual void Enable(const bool); + +// implementation + + void HasFocus(); + void NotFocus(); + void StartSelect(); + void EndSelect(); + void SetBitmap(); + void ApplyWidgetStyle(); + + bool m_hasFocus; + bool m_isSelected; + wxBitmap m_bitmap; + wxBitmap m_disabled; + wxBitmap m_focus; + wxBitmap m_selected; }; + #endif // __BMPBUTTONH__ diff --git a/include/wx/gtk/dialog.h b/include/wx/gtk/dialog.h index f2b65f707a..2e3607d09c 100644 --- a/include/wx/gtk/dialog.h +++ b/include/wx/gtk/dialog.h @@ -2,13 +2,12 @@ // Name: dialog.h // Purpose: // Author: Robert Roebling -// Created: 01/02/97 +// Created: // Id: $Id$ // Copyright: (c) 1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifndef __GTKDIALOGH__ #define __GTKDIALOGH__ @@ -20,12 +19,6 @@ #include "wx/panel.h" #include "wx/icon.h" -//----------------------------------------------------------------------------- -// forward decls -//----------------------------------------------------------------------------- - -class wxRadioBox; - //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -46,53 +39,65 @@ class wxDialog: public wxPanel { DECLARE_DYNAMIC_CLASS(wxDialog) - public: - - wxDialog(void); - 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 wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, const wxString &name = wxDialogNameStr ); - ~wxDialog(void); - void SetTitle(const wxString& title); - wxString GetTitle(void) const; - bool OnClose(void); - void OnApply( wxCommandEvent &event ); - void OnCancel( wxCommandEvent &event ); - void OnOK( wxCommandEvent &event ); - void OnPaint(wxPaintEvent& event); - bool Destroy(void); - void OnCloseWindow(wxCloseEvent& event); +public: + wxDialog(); + 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 wxString &title, + 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 ); + void OnPaint(wxPaintEvent& event); /* - void OnCharHook(wxKeyEvent& event); + void OnCharHook( wxKeyEvent& event ); */ - virtual void SetSize( int x, int y, int width, int height, + + bool Destroy(); + void OnCloseWindow( wxCloseEvent& event ); + + virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); - virtual bool Show( bool show ); - virtual int ShowModal(void); - virtual void EndModal(int retCode); - virtual bool IsModal(void) const; - void SetModal( bool modal ); - virtual void InitDialog(void); - virtual void Centre( int direction = wxHORIZONTAL ); + 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(void) const { return FALSE; } - bool Iconized(void) const { return IsIconized(); } - virtual void Maximize(void) { } - virtual void Restore(void) { } + 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 +// implementation - bool m_modalShowing; - wxString m_title; - wxIcon m_icon; + bool m_modalShowing; + wxString m_title; + wxIcon m_icon; DECLARE_EVENT_TABLE() - }; #endif // __GTKDIALOGH__ diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 34494a92b5..c87f59f47c 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -66,6 +66,7 @@ public: virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); + virtual void SetSize( int width, int height ); virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, const wxString& name = "statusBar"); diff --git a/include/wx/gtk1/bmpbuttn.h b/include/wx/gtk1/bmpbuttn.h index bcb31a9e90..827f5f4d32 100644 --- a/include/wx/gtk1/bmpbuttn.h +++ b/include/wx/gtk1/bmpbuttn.h @@ -40,36 +40,54 @@ class wxBitmapButton: public wxControl { DECLARE_DYNAMIC_CLASS(wxBitmapButton) - public: - - wxBitmapButton(void); - inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - { +public: + wxBitmapButton(); + inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr ) + { Create(parent, id, bitmap, pos, size, style, validator, name); - } - bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - void SetDefault(void); - void SetLabel( const wxString &label ); - wxString GetLabel(void) const; - virtual void SetLabel(const wxBitmap& bitmap) { SetBitmapLabel(bitmap); } - virtual void SetBitmapLabel( const wxBitmap& bitmap ); - wxBitmap& GetBitmapLabel(void) const { return (wxBitmap&) m_bitmap; } + } + bool Create( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr); + void SetDefault(); - // implementation - - void ApplyWidgetStyle(); + void SetLabel( const wxString &label ); + wxString GetLabel() const; + virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); } - public: - - wxBitmap m_bitmap; + wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_disabled; } + wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_focus; } + wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_bitmap; } + wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_selected; } + + void SetBitmapDisabled( const wxBitmap& bitmap ); + void SetBitmapFocus( const wxBitmap& bitmap ); + void SetBitmapLabel( const wxBitmap& bitmap ); + void SetBitmapSelected( const wxBitmap& bitmap ); + virtual void Enable(const bool); + +// implementation + + void HasFocus(); + void NotFocus(); + void StartSelect(); + void EndSelect(); + void SetBitmap(); + void ApplyWidgetStyle(); + + bool m_hasFocus; + bool m_isSelected; + wxBitmap m_bitmap; + wxBitmap m_disabled; + wxBitmap m_focus; + wxBitmap m_selected; }; + #endif // __BMPBUTTONH__ diff --git a/include/wx/gtk1/dialog.h b/include/wx/gtk1/dialog.h index f2b65f707a..2e3607d09c 100644 --- a/include/wx/gtk1/dialog.h +++ b/include/wx/gtk1/dialog.h @@ -2,13 +2,12 @@ // Name: dialog.h // Purpose: // Author: Robert Roebling -// Created: 01/02/97 +// Created: // Id: $Id$ // Copyright: (c) 1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifndef __GTKDIALOGH__ #define __GTKDIALOGH__ @@ -20,12 +19,6 @@ #include "wx/panel.h" #include "wx/icon.h" -//----------------------------------------------------------------------------- -// forward decls -//----------------------------------------------------------------------------- - -class wxRadioBox; - //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -46,53 +39,65 @@ class wxDialog: public wxPanel { DECLARE_DYNAMIC_CLASS(wxDialog) - public: - - wxDialog(void); - 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 wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, const wxString &name = wxDialogNameStr ); - ~wxDialog(void); - void SetTitle(const wxString& title); - wxString GetTitle(void) const; - bool OnClose(void); - void OnApply( wxCommandEvent &event ); - void OnCancel( wxCommandEvent &event ); - void OnOK( wxCommandEvent &event ); - void OnPaint(wxPaintEvent& event); - bool Destroy(void); - void OnCloseWindow(wxCloseEvent& event); +public: + wxDialog(); + 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 wxString &title, + 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 ); + void OnPaint(wxPaintEvent& event); /* - void OnCharHook(wxKeyEvent& event); + void OnCharHook( wxKeyEvent& event ); */ - virtual void SetSize( int x, int y, int width, int height, + + bool Destroy(); + void OnCloseWindow( wxCloseEvent& event ); + + virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); - virtual bool Show( bool show ); - virtual int ShowModal(void); - virtual void EndModal(int retCode); - virtual bool IsModal(void) const; - void SetModal( bool modal ); - virtual void InitDialog(void); - virtual void Centre( int direction = wxHORIZONTAL ); + 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(void) const { return FALSE; } - bool Iconized(void) const { return IsIconized(); } - virtual void Maximize(void) { } - virtual void Restore(void) { } + 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 +// implementation - bool m_modalShowing; - wxString m_title; - wxIcon m_icon; + bool m_modalShowing; + wxString m_title; + wxIcon m_icon; DECLARE_EVENT_TABLE() - }; #endif // __GTKDIALOGH__ diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 34494a92b5..c87f59f47c 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -66,6 +66,7 @@ public: virtual void SetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); + virtual void SetSize( int width, int height ); virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, const wxString& name = "statusBar"); diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index c4a757b53a..bf155fb4fc 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -31,12 +31,60 @@ extern bool g_blockEventsOnDrag; static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); - event.SetEventObject(button); - button->GetEventHandler()->ProcessEvent(event); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); + event.SetEventObject(button); + button->GetEventHandler()->ProcessEvent(event); +} + +//----------------------------------------------------------------------------- +// "enter" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->HasFocus(); +} + +//----------------------------------------------------------------------------- +// "leave" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->NotFocus(); +} + +//----------------------------------------------------------------------------- +// "pressed" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->StartSelect(); +} + +//----------------------------------------------------------------------------- +// "released" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_release_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->EndSelect(); } //----------------------------------------------------------------------------- @@ -45,96 +93,198 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -wxBitmapButton::wxBitmapButton(void) +wxBitmapButton::wxBitmapButton() { } -bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, - const wxPoint &pos, const wxSize &size, - long style, const wxValidator& validator, const wxString &name ) +bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + long style, const wxValidator& validator, const wxString &name ) { - m_needParent = TRUE; + m_needParent = TRUE; - wxSize newSize = size; + wxSize newSize = size; - PreCreation( parent, id, pos, newSize, style, name ); + PreCreation( parent, id, pos, newSize, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_bitmap = bitmap; - m_label = ""; + m_bitmap = bitmap; + m_disabled = bitmap; + m_focus = bitmap; + m_selected = bitmap; - m_widget = gtk_button_new(); + m_label = ""; - if (m_bitmap.Ok()) - { - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); - GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); + m_widget = gtk_button_new(); + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = (GdkBitmap *) NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); - gtk_widget_show( pixmap ); - gtk_container_add( GTK_CONTAINER(m_widget), pixmap ); - } + gtk_widget_show( pixmap ); + gtk_container_add( GTK_CONTAINER(m_widget), pixmap ); + } - if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10; - if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10; - SetSize( newSize.x, newSize.y ); + if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10; + if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10; + SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", + GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); - m_parent->AddChild( this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "enter", + GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "leave", + GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "pressed", + GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "released", + GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this ); + + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } -void wxBitmapButton::SetDefault(void) +void wxBitmapButton::SetDefault() { /* - GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); - gtk_widget_grab_default( m_widget ); + GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); + gtk_widget_grab_default( m_widget ); */ } void wxBitmapButton::SetLabel( const wxString &label ) { - wxCHECK_RET( m_widget != NULL, "invalid button" ); + wxCHECK_RET( m_widget != NULL, "invalid button" ); - wxControl::SetLabel( label ); + wxControl::SetLabel( label ); } -wxString wxBitmapButton::GetLabel(void) const +wxString wxBitmapButton::GetLabel() const { - wxCHECK_MSG( m_widget != NULL, "", "invalid button" ); + wxCHECK_MSG( m_widget != NULL, "", "invalid button" ); - return wxControl::GetLabel(); + return wxControl::GetLabel(); } -void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) +void wxBitmapButton::ApplyWidgetStyle() { - wxCHECK_RET( m_widget != NULL, "invalid button" ); +} + +void wxBitmapButton::SetBitmap() +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); - m_bitmap = bitmap; - if (!m_bitmap.Ok()) return; + wxBitmap the_one; - GtkButton *bin = GTK_BUTTON( m_widget ); - GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); + if ( ! m_isEnabled ) + the_one = m_disabled; + else + { + if ( m_isSelected ) + { + the_one = m_selected; + } + else + { + if ( m_hasFocus ) + the_one = m_focus; + else + the_one = m_bitmap; + } + } + + if ( ! the_one.Ok() ) the_one = m_bitmap; + if ( ! the_one.Ok() ) return; - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + GtkButton *bin = GTK_BUTTON( m_widget ); + GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); - gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask ); + GdkBitmap *mask = (GdkBitmap *) NULL; + if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap(); + + gtk_pixmap_set( g_pixmap, the_one.GetPixmap(), mask ); } -void wxBitmapButton::ApplyWidgetStyle() +void wxBitmapButton::SetBitmapDisabled( const wxBitmap& bitmap ) { + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_disabled.Ok() ) return; + m_disabled = bitmap; + + SetBitmap(); } +void wxBitmapButton::SetBitmapFocus( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_focus.Ok() ) return; + m_focus = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if (!m_bitmap.Ok()) return; + m_bitmap = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::SetBitmapSelected( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_selected.Ok() ) return; + m_selected = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::Enable( const bool enable ) +{ + wxWindow::Enable(enable); + + SetBitmap(); +} + +void wxBitmapButton::HasFocus() +{ + m_hasFocus = TRUE; + SetBitmap(); +} + +void wxBitmapButton::NotFocus() +{ + m_hasFocus = FALSE; + SetBitmap(); +} + +void wxBitmapButton::StartSelect() +{ + m_isSelected = TRUE; + SetBitmap(); +} + +void wxBitmapButton::EndSelect() +{ + m_isSelected = FALSE; + SetBitmap(); +} diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index f4a4883c61..5df777a91e 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -51,7 +51,7 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) -wxDialog::wxDialog(void) +wxDialog::wxDialog() { m_title = ""; m_modalShowing = FALSE; @@ -106,20 +106,20 @@ bool wxDialog::Create( wxWindow *parent, return TRUE; } -wxDialog::~wxDialog(void) +wxDialog::~wxDialog() { wxTopLevelWindows.DeleteObject( this ); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); } -void wxDialog::SetTitle(const wxString& title ) +void wxDialog::SetTitle( const wxString& title ) { m_title = title; if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); } -wxString wxDialog::GetTitle(void) const +wxString wxDialog::GetTitle() const { return (wxString&)m_title; } @@ -163,7 +163,7 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) // yes } -bool wxDialog::OnClose(void) +bool wxDialog::OnClose() { static wxList closing; @@ -179,14 +179,14 @@ bool wxDialog::OnClose(void) return FALSE; } -bool wxDialog::Destroy(void) +bool wxDialog::Destroy() { if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); return TRUE; } -void wxDialog::OnCloseWindow(wxCloseEvent& event) +void wxDialog::OnCloseWindow( wxCloseEvent& event ) { if (GetEventHandler()->OnClose() || event.GetForce()) { @@ -259,11 +259,17 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } +void wxDialog::SetSize( int width, int height ) +{ + SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); +} + void wxDialog::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - int x,y; + 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; @@ -285,7 +291,7 @@ bool wxDialog::Show( bool show ) return TRUE; } -bool wxDialog::IsModal(void) const +bool wxDialog::IsModal() const { return m_modalShowing; } @@ -301,7 +307,7 @@ void wxDialog::SetModal( bool WXUNUSED(flag) ) wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); } -int wxDialog::ShowModal(void) +int wxDialog::ShowModal() { if (IsModal()) { @@ -337,7 +343,7 @@ void wxDialog::EndModal( int retCode ) Show( FALSE ); } -void wxDialog::InitDialog(void) +void wxDialog::InitDialog() { wxWindow::InitDialog(); } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 1729aabb8e..6a593bf782 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -284,11 +284,17 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } +void wxFrame::SetSize( int width, int height ) +{ + SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); +} + void wxFrame::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - int x,y; + 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; @@ -348,10 +354,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - ProcessEvent( event ); - gtk_widget_set_usize( m_widget, m_width, m_height ); // This emulates the new wxMSW behaviour @@ -390,6 +392,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height } m_sizeSet = TRUE; + + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); + event.SetEventObject( this ); + ProcessEvent( event ); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 7ad7747467..6da95fff04 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1092,248 +1092,248 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, wxWindow::~wxWindow() { - m_hasVMT = FALSE; + m_hasVMT = FALSE; - if (m_dropTarget) delete m_dropTarget; + if (m_dropTarget) delete m_dropTarget; - if (m_parent) m_parent->RemoveChild( this ); - if (m_widget) Show( FALSE ); + if (m_parent) m_parent->RemoveChild( this ); + if (m_widget) Show( FALSE ); - DestroyChildren(); + DestroyChildren(); - if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); + if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - if (m_scrollGC) gdk_gc_unref( m_scrollGC ); + if (m_scrollGC) gdk_gc_unref( m_scrollGC ); - if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); + if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); - if (m_widget) gtk_widget_destroy( m_widget ); + if (m_widget) gtk_widget_destroy( m_widget ); - wxDELETE(m_cursor); + if (m_cursor) delete m_cursor; - DeleteRelatedConstraints(); - if (m_constraints) - { - // This removes any dangling pointers to this window - // in other windows' constraintsInvolvedIn lists. - UnsetConstraints(m_constraints); - delete m_constraints; - m_constraints = (wxLayoutConstraints *) NULL; - } - if (m_windowSizer) - { - delete m_windowSizer; - m_windowSizer = (wxSizer *) NULL; - } - // If this is a child of a sizer, remove self from parent - if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this); + DeleteRelatedConstraints(); + if (m_constraints) + { + // This removes any dangling pointers to this window + // in other windows' constraintsInvolvedIn lists. + UnsetConstraints(m_constraints); + delete m_constraints; + m_constraints = (wxLayoutConstraints *) NULL; + } + if (m_windowSizer) + { + delete m_windowSizer; + m_windowSizer = (wxSizer *) NULL; + } + // If this is a child of a sizer, remove self from parent + if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this); - // Just in case the window has been Closed, but - // we're then deleting immediately: don't leave - // dangling pointers. - wxPendingDelete.DeleteObject(this); + // Just in case the window has been Closed, but + // we're then deleting immediately: don't leave + // dangling pointers. + wxPendingDelete.DeleteObject(this); - // Just in case we've loaded a top-level window via - // wxWindow::LoadNativeDialog but we weren't a dialog - // class - wxTopLevelWindows.DeleteObject(this); + // Just in case we've loaded a top-level window via + // wxWindow::LoadNativeDialog but we weren't a dialog + // class + wxTopLevelWindows.DeleteObject(this); - if (m_windowValidator) delete m_windowValidator; + if (m_windowValidator) delete m_windowValidator; - if (m_clientObject) delete m_clientObject; + if (m_clientObject) delete m_clientObject; } void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { - if (m_needParent && (parent == NULL)) - wxFatalError( "Need complete parent.", name ); + if (m_needParent && (parent == NULL)) + wxFatalError( "Need complete parent.", name ); - m_widget = (GtkWidget*) NULL; - m_wxwindow = (GtkWidget*) NULL; - m_hasVMT = FALSE; - m_parent = parent; - m_children.DeleteContents( FALSE ); + m_widget = (GtkWidget*) NULL; + m_wxwindow = (GtkWidget*) NULL; + m_hasVMT = FALSE; + m_parent = parent; + m_children.DeleteContents( FALSE ); - m_width = size.x; - if (m_width == -1) m_width = 20; - m_height = size.y; - if (m_height == -1) m_height = 20; + m_width = size.x; + if (m_width == -1) m_width = 20; + m_height = size.y; + if (m_height == -1) m_height = 20; - m_x = (int)pos.x; - m_y = (int)pos.y; + m_x = (int)pos.x; + m_y = (int)pos.y; - if (!m_needParent) // some reasonable defaults - { - if (m_x == -1) + if (!m_needParent) // some reasonable defaults { - m_x = (gdk_screen_width () - m_width) / 2; - if (m_x < 10) m_x = 10; - } - if (m_y == -1) - { - m_y = (gdk_screen_height () - m_height) / 2; - if (m_y < 10) m_y = 10; + if (m_x == -1) + { + m_x = (gdk_screen_width () - m_width) / 2; + if (m_x < 10) m_x = 10; + } + if (m_y == -1) + { + m_y = (gdk_screen_height () - m_height) / 2; + if (m_y < 10) m_y = 10; + } } - } - m_minWidth = -1; - m_minHeight = -1; - m_maxWidth = -1; - m_maxHeight = -1; + m_minWidth = -1; + m_minHeight = -1; + m_maxWidth = -1; + m_maxHeight = -1; - m_retCode = 0; + m_retCode = 0; - m_eventHandler = this; + m_eventHandler = this; - m_windowId = id; + m_windowId = id; - m_sizeSet = FALSE; + m_sizeSet = FALSE; - m_cursor = new wxCursor( wxCURSOR_ARROW ); - m_font = *wxSWISS_FONT; + m_cursor = new wxCursor( wxCURSOR_ARROW ); + m_font = *wxSWISS_FONT; // m_backgroundColour = wxWHITE; // m_foregroundColour = wxBLACK; - m_windowStyle = style; - m_windowName = name; + m_windowStyle = style; + m_windowName = name; - m_constraints = (wxLayoutConstraints *) NULL; - m_constraintsInvolvedIn = (wxList *) NULL; - m_windowSizer = (wxSizer *) NULL; - m_sizerParent = (wxWindow *) NULL; - m_autoLayout = FALSE; + m_constraints = (wxLayoutConstraints *) NULL; + m_constraintsInvolvedIn = (wxList *) NULL; + m_windowSizer = (wxSizer *) NULL; + m_sizerParent = (wxWindow *) NULL; + m_autoLayout = FALSE; - m_hasScrolling = FALSE; - m_isScrolling = FALSE; - m_hAdjust = (GtkAdjustment *) NULL; - m_vAdjust = (GtkAdjustment *) NULL; - m_oldHorizontalPos = 0.0; - m_oldVerticalPos = 0.0; + m_hasScrolling = FALSE; + m_isScrolling = FALSE; + m_hAdjust = (GtkAdjustment *) NULL; + m_vAdjust = (GtkAdjustment *) NULL; + m_oldHorizontalPos = 0.0; + m_oldVerticalPos = 0.0; - m_isShown = FALSE; - m_isEnabled = TRUE; + m_isShown = FALSE; + m_isEnabled = TRUE; - m_dropTarget = (wxDropTarget *) NULL; - m_resizing = FALSE; - m_windowValidator = (wxValidator *) NULL; - m_scrollGC = (GdkGC*) NULL; - m_widgetStyle = (GtkStyle*) NULL; + m_dropTarget = (wxDropTarget *) NULL; + m_resizing = FALSE; + m_windowValidator = (wxValidator *) NULL; + m_scrollGC = (GdkGC*) NULL; + m_widgetStyle = (GtkStyle*) NULL; - m_clientObject = (wxClientData*)NULL; - m_clientData = NULL; + m_clientObject = (wxClientData*)NULL; + m_clientData = NULL; } void wxWindow::PostCreation() { - if (m_wxwindow) - { - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); + if (m_wxwindow) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", + GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", - GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); - } + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", + GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); + } - ConnectWidget( GetConnectWidget() ); + ConnectWidget( GetConnectWidget() ); - if (m_widget && m_parent) gtk_widget_realize( m_widget ); + if (m_widget && m_parent) gtk_widget_realize( m_widget ); - if (m_wxwindow) gtk_widget_realize( m_wxwindow ); + if (m_wxwindow) gtk_widget_realize( m_wxwindow ); - SetCursor( *wxSTANDARD_CURSOR ); + SetCursor( *wxSTANDARD_CURSOR ); - m_hasVMT = TRUE; + m_hasVMT = TRUE; } void wxWindow::ConnectWidget( GtkWidget *widget ) { - gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", + GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", - GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", + GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", - GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", + GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", - GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", + GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", + GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", + GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); } bool wxWindow::HasVMT() { - return m_hasVMT; + return m_hasVMT; } bool wxWindow::Close( bool force ) { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); - event.SetEventObject(this); - event.SetForce(force); + wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); + event.SetEventObject(this); + event.SetForce(force); - return GetEventHandler()->ProcessEvent(event); + return GetEventHandler()->ProcessEvent(event); } bool wxWindow::Destroy() { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - m_hasVMT = FALSE; - delete this; - return TRUE; + m_hasVMT = FALSE; + delete this; + return TRUE; } bool wxWindow::DestroyChildren() { - if (GetChildren()) - { - wxNode *node; - while ((node = GetChildren()->First()) != (wxNode *)NULL) + if (GetChildren()) { - wxWindow *child; - if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) - { - delete child; - if (GetChildren()->Member(child)) delete node; - } + wxNode *node; + while ((node = GetChildren()->First()) != (wxNode *)NULL) + { + wxWindow *child; + if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) + { + delete child; + if (GetChildren()->Member(child)) delete node; + } + } } - } - return TRUE; + return TRUE; } void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) ) { - // are we to set fonts here ? + // are we to set fonts here ? } wxPoint wxWindow::GetClientAreaOrigin() const { - return wxPoint(0,0); + return wxPoint(0,0); } void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ) { - if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) - { - wxPoint pt(GetParent()->GetClientAreaOrigin()); - x += pt.x; - y += pt.y; - } + if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + x += pt.x; + y += pt.y; + } } void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) @@ -1537,41 +1537,41 @@ void wxWindow::GetClientSize( int *width, int *height ) const void wxWindow::GetPosition( int *x, int *y ) const { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - if (x) (*x) = m_x; - if (y) (*y) = m_y; + if (x) (*x) = m_x; + if (y) (*y) = m_y; } void wxWindow::ClientToScreen( int *x, int *y ) { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - GdkWindow *source = (GdkWindow *) NULL; - if (m_wxwindow) - source = m_wxwindow->window; - else - source = m_widget->window; + GdkWindow *source = (GdkWindow *) NULL; + if (m_wxwindow) + source = m_wxwindow->window; + else + source = m_widget->window; - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( source, &org_x, &org_y ); + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( source, &org_x, &org_y ); - if (!m_wxwindow) - { - if (GTK_WIDGET_NO_WINDOW (m_widget)) + if (!m_wxwindow) { - org_x += m_widget->allocation.x; - org_y += m_widget->allocation.y; + if (GTK_WIDGET_NO_WINDOW (m_widget)) + { + org_x += m_widget->allocation.x; + org_y += m_widget->allocation.y; + } } - } - wxPoint pt(GetClientAreaOrigin()); - org_x += pt.x; - org_y += pt.y; + wxPoint pt(GetClientAreaOrigin()); + org_x += pt.x; + org_y += pt.y; - if (x) *x += org_x; - if (y) *y += org_y; + if (x) *x += org_x; + if (y) *y += org_y; } void wxWindow::ScreenToClient( int *x, int *y ) diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index c4a757b53a..bf155fb4fc 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -31,12 +31,60 @@ extern bool g_blockEventsOnDrag; static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); - event.SetEventObject(button); - button->GetEventHandler()->ProcessEvent(event); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); + event.SetEventObject(button); + button->GetEventHandler()->ProcessEvent(event); +} + +//----------------------------------------------------------------------------- +// "enter" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->HasFocus(); +} + +//----------------------------------------------------------------------------- +// "leave" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->NotFocus(); +} + +//----------------------------------------------------------------------------- +// "pressed" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->StartSelect(); +} + +//----------------------------------------------------------------------------- +// "released" +//----------------------------------------------------------------------------- + +static void gtk_bmpbutton_release_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +{ + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + button->EndSelect(); } //----------------------------------------------------------------------------- @@ -45,96 +93,198 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -wxBitmapButton::wxBitmapButton(void) +wxBitmapButton::wxBitmapButton() { } -bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, - const wxPoint &pos, const wxSize &size, - long style, const wxValidator& validator, const wxString &name ) +bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + long style, const wxValidator& validator, const wxString &name ) { - m_needParent = TRUE; + m_needParent = TRUE; - wxSize newSize = size; + wxSize newSize = size; - PreCreation( parent, id, pos, newSize, style, name ); + PreCreation( parent, id, pos, newSize, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_bitmap = bitmap; - m_label = ""; + m_bitmap = bitmap; + m_disabled = bitmap; + m_focus = bitmap; + m_selected = bitmap; - m_widget = gtk_button_new(); + m_label = ""; - if (m_bitmap.Ok()) - { - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); - GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); + m_widget = gtk_button_new(); + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = (GdkBitmap *) NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); - gtk_widget_show( pixmap ); - gtk_container_add( GTK_CONTAINER(m_widget), pixmap ); - } + gtk_widget_show( pixmap ); + gtk_container_add( GTK_CONTAINER(m_widget), pixmap ); + } - if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10; - if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10; - SetSize( newSize.x, newSize.y ); + if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10; + if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10; + SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", + GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); - m_parent->AddChild( this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "enter", + GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "leave", + GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "pressed", + GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "released", + GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this ); + + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } -void wxBitmapButton::SetDefault(void) +void wxBitmapButton::SetDefault() { /* - GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); - gtk_widget_grab_default( m_widget ); + GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); + gtk_widget_grab_default( m_widget ); */ } void wxBitmapButton::SetLabel( const wxString &label ) { - wxCHECK_RET( m_widget != NULL, "invalid button" ); + wxCHECK_RET( m_widget != NULL, "invalid button" ); - wxControl::SetLabel( label ); + wxControl::SetLabel( label ); } -wxString wxBitmapButton::GetLabel(void) const +wxString wxBitmapButton::GetLabel() const { - wxCHECK_MSG( m_widget != NULL, "", "invalid button" ); + wxCHECK_MSG( m_widget != NULL, "", "invalid button" ); - return wxControl::GetLabel(); + return wxControl::GetLabel(); } -void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) +void wxBitmapButton::ApplyWidgetStyle() { - wxCHECK_RET( m_widget != NULL, "invalid button" ); +} + +void wxBitmapButton::SetBitmap() +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); - m_bitmap = bitmap; - if (!m_bitmap.Ok()) return; + wxBitmap the_one; - GtkButton *bin = GTK_BUTTON( m_widget ); - GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); + if ( ! m_isEnabled ) + the_one = m_disabled; + else + { + if ( m_isSelected ) + { + the_one = m_selected; + } + else + { + if ( m_hasFocus ) + the_one = m_focus; + else + the_one = m_bitmap; + } + } + + if ( ! the_one.Ok() ) the_one = m_bitmap; + if ( ! the_one.Ok() ) return; - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + GtkButton *bin = GTK_BUTTON( m_widget ); + GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); - gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask ); + GdkBitmap *mask = (GdkBitmap *) NULL; + if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap(); + + gtk_pixmap_set( g_pixmap, the_one.GetPixmap(), mask ); } -void wxBitmapButton::ApplyWidgetStyle() +void wxBitmapButton::SetBitmapDisabled( const wxBitmap& bitmap ) { + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_disabled.Ok() ) return; + m_disabled = bitmap; + + SetBitmap(); } +void wxBitmapButton::SetBitmapFocus( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_focus.Ok() ) return; + m_focus = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if (!m_bitmap.Ok()) return; + m_bitmap = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::SetBitmapSelected( const wxBitmap& bitmap ) +{ + wxCHECK_RET( m_widget != NULL, "invalid button" ); + + if ( ! m_selected.Ok() ) return; + m_selected = bitmap; + + SetBitmap(); +} + +void wxBitmapButton::Enable( const bool enable ) +{ + wxWindow::Enable(enable); + + SetBitmap(); +} + +void wxBitmapButton::HasFocus() +{ + m_hasFocus = TRUE; + SetBitmap(); +} + +void wxBitmapButton::NotFocus() +{ + m_hasFocus = FALSE; + SetBitmap(); +} + +void wxBitmapButton::StartSelect() +{ + m_isSelected = TRUE; + SetBitmap(); +} + +void wxBitmapButton::EndSelect() +{ + m_isSelected = FALSE; + SetBitmap(); +} diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index f4a4883c61..5df777a91e 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -51,7 +51,7 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) -wxDialog::wxDialog(void) +wxDialog::wxDialog() { m_title = ""; m_modalShowing = FALSE; @@ -106,20 +106,20 @@ bool wxDialog::Create( wxWindow *parent, return TRUE; } -wxDialog::~wxDialog(void) +wxDialog::~wxDialog() { wxTopLevelWindows.DeleteObject( this ); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); } -void wxDialog::SetTitle(const wxString& title ) +void wxDialog::SetTitle( const wxString& title ) { m_title = title; if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); } -wxString wxDialog::GetTitle(void) const +wxString wxDialog::GetTitle() const { return (wxString&)m_title; } @@ -163,7 +163,7 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) // yes } -bool wxDialog::OnClose(void) +bool wxDialog::OnClose() { static wxList closing; @@ -179,14 +179,14 @@ bool wxDialog::OnClose(void) return FALSE; } -bool wxDialog::Destroy(void) +bool wxDialog::Destroy() { if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); return TRUE; } -void wxDialog::OnCloseWindow(wxCloseEvent& event) +void wxDialog::OnCloseWindow( wxCloseEvent& event ) { if (GetEventHandler()->OnClose() || event.GetForce()) { @@ -259,11 +259,17 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } +void wxDialog::SetSize( int width, int height ) +{ + SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); +} + void wxDialog::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - int x,y; + 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; @@ -285,7 +291,7 @@ bool wxDialog::Show( bool show ) return TRUE; } -bool wxDialog::IsModal(void) const +bool wxDialog::IsModal() const { return m_modalShowing; } @@ -301,7 +307,7 @@ void wxDialog::SetModal( bool WXUNUSED(flag) ) wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); } -int wxDialog::ShowModal(void) +int wxDialog::ShowModal() { if (IsModal()) { @@ -337,7 +343,7 @@ void wxDialog::EndModal( int retCode ) Show( FALSE ); } -void wxDialog::InitDialog(void) +void wxDialog::InitDialog() { wxWindow::InitDialog(); } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 1729aabb8e..6a593bf782 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -284,11 +284,17 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } +void wxFrame::SetSize( int width, int height ) +{ + SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); +} + void wxFrame::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - int x,y; + 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; @@ -348,10 +354,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - ProcessEvent( event ); - gtk_widget_set_usize( m_widget, m_width, m_height ); // This emulates the new wxMSW behaviour @@ -390,6 +392,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height } m_sizeSet = TRUE; + + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); + event.SetEventObject( this ); + ProcessEvent( event ); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 7ad7747467..6da95fff04 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1092,248 +1092,248 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, wxWindow::~wxWindow() { - m_hasVMT = FALSE; + m_hasVMT = FALSE; - if (m_dropTarget) delete m_dropTarget; + if (m_dropTarget) delete m_dropTarget; - if (m_parent) m_parent->RemoveChild( this ); - if (m_widget) Show( FALSE ); + if (m_parent) m_parent->RemoveChild( this ); + if (m_widget) Show( FALSE ); - DestroyChildren(); + DestroyChildren(); - if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); + if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - if (m_scrollGC) gdk_gc_unref( m_scrollGC ); + if (m_scrollGC) gdk_gc_unref( m_scrollGC ); - if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); + if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); - if (m_widget) gtk_widget_destroy( m_widget ); + if (m_widget) gtk_widget_destroy( m_widget ); - wxDELETE(m_cursor); + if (m_cursor) delete m_cursor; - DeleteRelatedConstraints(); - if (m_constraints) - { - // This removes any dangling pointers to this window - // in other windows' constraintsInvolvedIn lists. - UnsetConstraints(m_constraints); - delete m_constraints; - m_constraints = (wxLayoutConstraints *) NULL; - } - if (m_windowSizer) - { - delete m_windowSizer; - m_windowSizer = (wxSizer *) NULL; - } - // If this is a child of a sizer, remove self from parent - if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this); + DeleteRelatedConstraints(); + if (m_constraints) + { + // This removes any dangling pointers to this window + // in other windows' constraintsInvolvedIn lists. + UnsetConstraints(m_constraints); + delete m_constraints; + m_constraints = (wxLayoutConstraints *) NULL; + } + if (m_windowSizer) + { + delete m_windowSizer; + m_windowSizer = (wxSizer *) NULL; + } + // If this is a child of a sizer, remove self from parent + if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this); - // Just in case the window has been Closed, but - // we're then deleting immediately: don't leave - // dangling pointers. - wxPendingDelete.DeleteObject(this); + // Just in case the window has been Closed, but + // we're then deleting immediately: don't leave + // dangling pointers. + wxPendingDelete.DeleteObject(this); - // Just in case we've loaded a top-level window via - // wxWindow::LoadNativeDialog but we weren't a dialog - // class - wxTopLevelWindows.DeleteObject(this); + // Just in case we've loaded a top-level window via + // wxWindow::LoadNativeDialog but we weren't a dialog + // class + wxTopLevelWindows.DeleteObject(this); - if (m_windowValidator) delete m_windowValidator; + if (m_windowValidator) delete m_windowValidator; - if (m_clientObject) delete m_clientObject; + if (m_clientObject) delete m_clientObject; } void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { - if (m_needParent && (parent == NULL)) - wxFatalError( "Need complete parent.", name ); + if (m_needParent && (parent == NULL)) + wxFatalError( "Need complete parent.", name ); - m_widget = (GtkWidget*) NULL; - m_wxwindow = (GtkWidget*) NULL; - m_hasVMT = FALSE; - m_parent = parent; - m_children.DeleteContents( FALSE ); + m_widget = (GtkWidget*) NULL; + m_wxwindow = (GtkWidget*) NULL; + m_hasVMT = FALSE; + m_parent = parent; + m_children.DeleteContents( FALSE ); - m_width = size.x; - if (m_width == -1) m_width = 20; - m_height = size.y; - if (m_height == -1) m_height = 20; + m_width = size.x; + if (m_width == -1) m_width = 20; + m_height = size.y; + if (m_height == -1) m_height = 20; - m_x = (int)pos.x; - m_y = (int)pos.y; + m_x = (int)pos.x; + m_y = (int)pos.y; - if (!m_needParent) // some reasonable defaults - { - if (m_x == -1) + if (!m_needParent) // some reasonable defaults { - m_x = (gdk_screen_width () - m_width) / 2; - if (m_x < 10) m_x = 10; - } - if (m_y == -1) - { - m_y = (gdk_screen_height () - m_height) / 2; - if (m_y < 10) m_y = 10; + if (m_x == -1) + { + m_x = (gdk_screen_width () - m_width) / 2; + if (m_x < 10) m_x = 10; + } + if (m_y == -1) + { + m_y = (gdk_screen_height () - m_height) / 2; + if (m_y < 10) m_y = 10; + } } - } - m_minWidth = -1; - m_minHeight = -1; - m_maxWidth = -1; - m_maxHeight = -1; + m_minWidth = -1; + m_minHeight = -1; + m_maxWidth = -1; + m_maxHeight = -1; - m_retCode = 0; + m_retCode = 0; - m_eventHandler = this; + m_eventHandler = this; - m_windowId = id; + m_windowId = id; - m_sizeSet = FALSE; + m_sizeSet = FALSE; - m_cursor = new wxCursor( wxCURSOR_ARROW ); - m_font = *wxSWISS_FONT; + m_cursor = new wxCursor( wxCURSOR_ARROW ); + m_font = *wxSWISS_FONT; // m_backgroundColour = wxWHITE; // m_foregroundColour = wxBLACK; - m_windowStyle = style; - m_windowName = name; + m_windowStyle = style; + m_windowName = name; - m_constraints = (wxLayoutConstraints *) NULL; - m_constraintsInvolvedIn = (wxList *) NULL; - m_windowSizer = (wxSizer *) NULL; - m_sizerParent = (wxWindow *) NULL; - m_autoLayout = FALSE; + m_constraints = (wxLayoutConstraints *) NULL; + m_constraintsInvolvedIn = (wxList *) NULL; + m_windowSizer = (wxSizer *) NULL; + m_sizerParent = (wxWindow *) NULL; + m_autoLayout = FALSE; - m_hasScrolling = FALSE; - m_isScrolling = FALSE; - m_hAdjust = (GtkAdjustment *) NULL; - m_vAdjust = (GtkAdjustment *) NULL; - m_oldHorizontalPos = 0.0; - m_oldVerticalPos = 0.0; + m_hasScrolling = FALSE; + m_isScrolling = FALSE; + m_hAdjust = (GtkAdjustment *) NULL; + m_vAdjust = (GtkAdjustment *) NULL; + m_oldHorizontalPos = 0.0; + m_oldVerticalPos = 0.0; - m_isShown = FALSE; - m_isEnabled = TRUE; + m_isShown = FALSE; + m_isEnabled = TRUE; - m_dropTarget = (wxDropTarget *) NULL; - m_resizing = FALSE; - m_windowValidator = (wxValidator *) NULL; - m_scrollGC = (GdkGC*) NULL; - m_widgetStyle = (GtkStyle*) NULL; + m_dropTarget = (wxDropTarget *) NULL; + m_resizing = FALSE; + m_windowValidator = (wxValidator *) NULL; + m_scrollGC = (GdkGC*) NULL; + m_widgetStyle = (GtkStyle*) NULL; - m_clientObject = (wxClientData*)NULL; - m_clientData = NULL; + m_clientObject = (wxClientData*)NULL; + m_clientData = NULL; } void wxWindow::PostCreation() { - if (m_wxwindow) - { - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); + if (m_wxwindow) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", + GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", - GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); - } + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", + GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); + } - ConnectWidget( GetConnectWidget() ); + ConnectWidget( GetConnectWidget() ); - if (m_widget && m_parent) gtk_widget_realize( m_widget ); + if (m_widget && m_parent) gtk_widget_realize( m_widget ); - if (m_wxwindow) gtk_widget_realize( m_wxwindow ); + if (m_wxwindow) gtk_widget_realize( m_wxwindow ); - SetCursor( *wxSTANDARD_CURSOR ); + SetCursor( *wxSTANDARD_CURSOR ); - m_hasVMT = TRUE; + m_hasVMT = TRUE; } void wxWindow::ConnectWidget( GtkWidget *widget ) { - gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", + GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", - GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", + GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", - GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", + GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", - GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", + GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", + GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", + GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); } bool wxWindow::HasVMT() { - return m_hasVMT; + return m_hasVMT; } bool wxWindow::Close( bool force ) { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); - event.SetEventObject(this); - event.SetForce(force); + wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); + event.SetEventObject(this); + event.SetForce(force); - return GetEventHandler()->ProcessEvent(event); + return GetEventHandler()->ProcessEvent(event); } bool wxWindow::Destroy() { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - m_hasVMT = FALSE; - delete this; - return TRUE; + m_hasVMT = FALSE; + delete this; + return TRUE; } bool wxWindow::DestroyChildren() { - if (GetChildren()) - { - wxNode *node; - while ((node = GetChildren()->First()) != (wxNode *)NULL) + if (GetChildren()) { - wxWindow *child; - if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) - { - delete child; - if (GetChildren()->Member(child)) delete node; - } + wxNode *node; + while ((node = GetChildren()->First()) != (wxNode *)NULL) + { + wxWindow *child; + if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) + { + delete child; + if (GetChildren()->Member(child)) delete node; + } + } } - } - return TRUE; + return TRUE; } void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) ) { - // are we to set fonts here ? + // are we to set fonts here ? } wxPoint wxWindow::GetClientAreaOrigin() const { - return wxPoint(0,0); + return wxPoint(0,0); } void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ) { - if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) - { - wxPoint pt(GetParent()->GetClientAreaOrigin()); - x += pt.x; - y += pt.y; - } + if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + x += pt.x; + y += pt.y; + } } void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) @@ -1537,41 +1537,41 @@ void wxWindow::GetClientSize( int *width, int *height ) const void wxWindow::GetPosition( int *x, int *y ) const { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - if (x) (*x) = m_x; - if (y) (*y) = m_y; + if (x) (*x) = m_x; + if (y) (*y) = m_y; } void wxWindow::ClientToScreen( int *x, int *y ) { - wxASSERT_MSG( (m_widget != NULL), "invalid window" ); + wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - GdkWindow *source = (GdkWindow *) NULL; - if (m_wxwindow) - source = m_wxwindow->window; - else - source = m_widget->window; + GdkWindow *source = (GdkWindow *) NULL; + if (m_wxwindow) + source = m_wxwindow->window; + else + source = m_widget->window; - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( source, &org_x, &org_y ); + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( source, &org_x, &org_y ); - if (!m_wxwindow) - { - if (GTK_WIDGET_NO_WINDOW (m_widget)) + if (!m_wxwindow) { - org_x += m_widget->allocation.x; - org_y += m_widget->allocation.y; + if (GTK_WIDGET_NO_WINDOW (m_widget)) + { + org_x += m_widget->allocation.x; + org_y += m_widget->allocation.y; + } } - } - wxPoint pt(GetClientAreaOrigin()); - org_x += pt.x; - org_y += pt.y; + wxPoint pt(GetClientAreaOrigin()); + org_x += pt.x; + org_y += pt.y; - if (x) *x += org_x; - if (y) *y += org_y; + if (x) *x += org_x; + if (y) *y += org_y; } void wxWindow::ScreenToClient( int *x, int *y ) -- 2.47.2