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
This commit is contained in:
Robert Roebling 1998-11-15 17:57:55 +00:00
parent 940c60c813
commit 43a1889865
14 changed files with 1026 additions and 654 deletions

View File

@ -41,8 +41,7 @@ class wxBitmapButton: public wxControl
DECLARE_DYNAMIC_CLASS(wxBitmapButton) DECLARE_DYNAMIC_CLASS(wxBitmapButton)
public: public:
wxBitmapButton();
wxBitmapButton(void);
inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
@ -56,20 +55,39 @@ class wxBitmapButton: public wxControl
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr); const wxString& name = wxButtonNameStr);
void SetDefault(void); void SetDefault();
void SetLabel( const wxString &label ); void SetLabel( const wxString &label );
wxString GetLabel(void) const; wxString GetLabel() const;
virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); } virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); }
virtual void SetBitmapLabel( const wxBitmap& bitmap );
wxBitmap& GetBitmapLabel(void) const { return (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 // implementation
void HasFocus();
void NotFocus();
void StartSelect();
void EndSelect();
void SetBitmap();
void ApplyWidgetStyle(); void ApplyWidgetStyle();
public: bool m_hasFocus;
bool m_isSelected;
wxBitmap m_bitmap; wxBitmap m_bitmap;
wxBitmap m_disabled;
wxBitmap m_focus;
wxBitmap m_selected;
}; };
#endif // __BMPBUTTONH__ #endif // __BMPBUTTONH__

View File

@ -2,13 +2,12 @@
// Name: dialog.h // Name: dialog.h
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Created: 01/02/97 // Created:
// Id: $Id$ // Id: $Id$
// Copyright: (c) 1998 Robert Roebling // Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKDIALOGH__ #ifndef __GTKDIALOGH__
#define __GTKDIALOGH__ #define __GTKDIALOGH__
@ -20,12 +19,6 @@
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/icon.h" #include "wx/icon.h"
//-----------------------------------------------------------------------------
// forward decls
//-----------------------------------------------------------------------------
class wxRadioBox;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -47,43 +40,56 @@ class wxDialog: public wxPanel
DECLARE_DYNAMIC_CLASS(wxDialog) DECLARE_DYNAMIC_CLASS(wxDialog)
public: 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();
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); void SetTitle(const wxString& title);
wxString GetTitle(void) const; wxString GetTitle() const;
bool OnClose(void);
bool OnClose();
void OnApply( wxCommandEvent &event ); void OnApply( wxCommandEvent &event );
void OnCancel( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event );
void OnOK( wxCommandEvent &event ); void OnOK( wxCommandEvent &event );
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
bool Destroy(void);
void OnCloseWindow(wxCloseEvent& event);
/* /*
void OnCharHook( wxKeyEvent& event ); void OnCharHook( wxKeyEvent& event );
*/ */
bool Destroy();
void OnCloseWindow( wxCloseEvent& event );
virtual void SetSize( int x, int y, int width, int height, virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO ); int sizeFlags = wxSIZE_AUTO );
virtual void SetSize( int width, int height );
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual int ShowModal(void); virtual int ShowModal();
virtual void EndModal( int retCode ); virtual void EndModal( int retCode );
virtual bool IsModal(void) const; virtual bool IsModal() const;
void SetModal( bool modal ); void SetModal( bool modal );
virtual void InitDialog(void); virtual void InitDialog(void);
virtual void Centre( int direction = wxHORIZONTAL ); virtual void Centre( int direction = wxHORIZONTAL );
virtual void SetIcon( const wxIcon &icon ); virtual void SetIcon( const wxIcon &icon );
virtual void Iconize( bool WXUNUSED(iconize)) { } virtual void Iconize( bool WXUNUSED(iconize)) { }
virtual bool IsIconized(void) const { return FALSE; } virtual bool IsIconized() const { return FALSE; }
bool Iconized(void) const { return IsIconized(); } bool Iconized() const { return IsIconized(); }
virtual void Maximize(void) { } virtual void Maximize() { }
virtual void Restore(void) { } virtual void Restore() { }
// implementation // implementation
@ -92,7 +98,6 @@ class wxDialog: public wxPanel
wxIcon m_icon; wxIcon m_icon;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // __GTKDIALOGH__ #endif // __GTKDIALOGH__

View File

@ -66,6 +66,7 @@ public:
virtual void SetSize( int x, int y, int width, int height, virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO ); int sizeFlags = wxSIZE_AUTO );
virtual void SetSize( int width, int height );
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
const wxString& name = "statusBar"); const wxString& name = "statusBar");

View File

@ -41,8 +41,7 @@ class wxBitmapButton: public wxControl
DECLARE_DYNAMIC_CLASS(wxBitmapButton) DECLARE_DYNAMIC_CLASS(wxBitmapButton)
public: public:
wxBitmapButton();
wxBitmapButton(void);
inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, inline wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
@ -56,20 +55,39 @@ class wxBitmapButton: public wxControl
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr); const wxString& name = wxButtonNameStr);
void SetDefault(void); void SetDefault();
void SetLabel( const wxString &label ); void SetLabel( const wxString &label );
wxString GetLabel(void) const; wxString GetLabel() const;
virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); } virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); }
virtual void SetBitmapLabel( const wxBitmap& bitmap );
wxBitmap& GetBitmapLabel(void) const { return (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 // implementation
void HasFocus();
void NotFocus();
void StartSelect();
void EndSelect();
void SetBitmap();
void ApplyWidgetStyle(); void ApplyWidgetStyle();
public: bool m_hasFocus;
bool m_isSelected;
wxBitmap m_bitmap; wxBitmap m_bitmap;
wxBitmap m_disabled;
wxBitmap m_focus;
wxBitmap m_selected;
}; };
#endif // __BMPBUTTONH__ #endif // __BMPBUTTONH__

View File

@ -2,13 +2,12 @@
// Name: dialog.h // Name: dialog.h
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Created: 01/02/97 // Created:
// Id: $Id$ // Id: $Id$
// Copyright: (c) 1998 Robert Roebling // Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKDIALOGH__ #ifndef __GTKDIALOGH__
#define __GTKDIALOGH__ #define __GTKDIALOGH__
@ -20,12 +19,6 @@
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/icon.h" #include "wx/icon.h"
//-----------------------------------------------------------------------------
// forward decls
//-----------------------------------------------------------------------------
class wxRadioBox;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -47,43 +40,56 @@ class wxDialog: public wxPanel
DECLARE_DYNAMIC_CLASS(wxDialog) DECLARE_DYNAMIC_CLASS(wxDialog)
public: 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();
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); void SetTitle(const wxString& title);
wxString GetTitle(void) const; wxString GetTitle() const;
bool OnClose(void);
bool OnClose();
void OnApply( wxCommandEvent &event ); void OnApply( wxCommandEvent &event );
void OnCancel( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event );
void OnOK( wxCommandEvent &event ); void OnOK( wxCommandEvent &event );
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
bool Destroy(void);
void OnCloseWindow(wxCloseEvent& event);
/* /*
void OnCharHook( wxKeyEvent& event ); void OnCharHook( wxKeyEvent& event );
*/ */
bool Destroy();
void OnCloseWindow( wxCloseEvent& event );
virtual void SetSize( int x, int y, int width, int height, virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO ); int sizeFlags = wxSIZE_AUTO );
virtual void SetSize( int width, int height );
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual int ShowModal(void); virtual int ShowModal();
virtual void EndModal( int retCode ); virtual void EndModal( int retCode );
virtual bool IsModal(void) const; virtual bool IsModal() const;
void SetModal( bool modal ); void SetModal( bool modal );
virtual void InitDialog(void); virtual void InitDialog(void);
virtual void Centre( int direction = wxHORIZONTAL ); virtual void Centre( int direction = wxHORIZONTAL );
virtual void SetIcon( const wxIcon &icon ); virtual void SetIcon( const wxIcon &icon );
virtual void Iconize( bool WXUNUSED(iconize)) { } virtual void Iconize( bool WXUNUSED(iconize)) { }
virtual bool IsIconized(void) const { return FALSE; } virtual bool IsIconized() const { return FALSE; }
bool Iconized(void) const { return IsIconized(); } bool Iconized() const { return IsIconized(); }
virtual void Maximize(void) { } virtual void Maximize() { }
virtual void Restore(void) { } virtual void Restore() { }
// implementation // implementation
@ -92,7 +98,6 @@ class wxDialog: public wxPanel
wxIcon m_icon; wxIcon m_icon;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // __GTKDIALOGH__ #endif // __GTKDIALOGH__

View File

@ -66,6 +66,7 @@ public:
virtual void SetSize( int x, int y, int width, int height, virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO ); int sizeFlags = wxSIZE_AUTO );
virtual void SetSize( int width, int height );
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
const wxString& name = "statusBar"); const wxString& name = "statusBar");

View File

@ -39,13 +39,61 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma
button->GetEventHandler()->ProcessEvent(event); 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();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxBitmapButton // wxBitmapButton
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl)
wxBitmapButton::wxBitmapButton(void) wxBitmapButton::wxBitmapButton()
{ {
} }
@ -62,6 +110,10 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
SetValidator( validator ); SetValidator( validator );
m_bitmap = bitmap; m_bitmap = bitmap;
m_disabled = bitmap;
m_focus = bitmap;
m_selected = bitmap;
m_label = ""; m_label = "";
m_widget = gtk_button_new(); m_widget = gtk_button_new();
@ -83,6 +135,15 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)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->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
@ -96,7 +157,7 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
return TRUE; return TRUE;
} }
void wxBitmapButton::SetDefault(void) void wxBitmapButton::SetDefault()
{ {
/* /*
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
@ -111,30 +172,119 @@ void wxBitmapButton::SetLabel( const wxString &label )
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()
{
}
void wxBitmapButton::SetBitmap()
{ {
wxCHECK_RET( m_widget != NULL, "invalid button" ); wxCHECK_RET( m_widget != NULL, "invalid button" );
m_bitmap = bitmap; wxBitmap the_one;
if (!m_bitmap.Ok()) return;
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;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child );
GdkBitmap *mask = (GdkBitmap *) NULL; GdkBitmap *mask = (GdkBitmap *) NULL;
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask ); 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();
}

View File

@ -51,7 +51,7 @@ END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
wxDialog::wxDialog(void) wxDialog::wxDialog()
{ {
m_title = ""; m_title = "";
m_modalShowing = FALSE; m_modalShowing = FALSE;
@ -106,7 +106,7 @@ bool wxDialog::Create( wxWindow *parent,
return TRUE; return TRUE;
} }
wxDialog::~wxDialog(void) wxDialog::~wxDialog()
{ {
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
@ -119,7 +119,7 @@ void wxDialog::SetTitle(const wxString& title )
gtk_window_set_title( GTK_WINDOW(m_widget), 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; return (wxString&)m_title;
} }
@ -163,7 +163,7 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
// yes // yes
} }
bool wxDialog::OnClose(void) bool wxDialog::OnClose()
{ {
static wxList closing; static wxList closing;
@ -179,7 +179,7 @@ bool wxDialog::OnClose(void)
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void) bool wxDialog::Destroy()
{ {
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
@ -259,11 +259,17 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
m_resizing = FALSE; m_resizing = FALSE;
} }
void wxDialog::SetSize( int width, int height )
{
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
}
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); 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 & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
@ -285,7 +291,7 @@ bool wxDialog::Show( bool show )
return TRUE; return TRUE;
} }
bool wxDialog::IsModal(void) const bool wxDialog::IsModal() const
{ {
return m_modalShowing; return m_modalShowing;
} }
@ -301,7 +307,7 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); wxFAIL_MSG( "wxDialog:SetModal obsolete now" );
} }
int wxDialog::ShowModal(void) int wxDialog::ShowModal()
{ {
if (IsModal()) if (IsModal())
{ {
@ -337,7 +343,7 @@ void wxDialog::EndModal( int retCode )
Show( FALSE ); Show( FALSE );
} }
void wxDialog::InitDialog(void) void wxDialog::InitDialog()
{ {
wxWindow::InitDialog(); wxWindow::InitDialog();
} }

View File

@ -284,11 +284,17 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
m_resizing = FALSE; m_resizing = FALSE;
} }
void wxFrame::SetSize( int width, int height )
{
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
}
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); 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 & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 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_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; 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 ); gtk_widget_set_usize( m_widget, m_width, m_height );
// This emulates the new wxMSW behaviour // 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; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
} }
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )

View File

@ -1109,7 +1109,7 @@ wxWindow::~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(); DeleteRelatedConstraints();
if (m_constraints) if (m_constraints)

View File

@ -39,13 +39,61 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma
button->GetEventHandler()->ProcessEvent(event); 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();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxBitmapButton // wxBitmapButton
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl)
wxBitmapButton::wxBitmapButton(void) wxBitmapButton::wxBitmapButton()
{ {
} }
@ -62,6 +110,10 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
SetValidator( validator ); SetValidator( validator );
m_bitmap = bitmap; m_bitmap = bitmap;
m_disabled = bitmap;
m_focus = bitmap;
m_selected = bitmap;
m_label = ""; m_label = "";
m_widget = gtk_button_new(); m_widget = gtk_button_new();
@ -83,6 +135,15 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)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->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
@ -96,7 +157,7 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
return TRUE; return TRUE;
} }
void wxBitmapButton::SetDefault(void) void wxBitmapButton::SetDefault()
{ {
/* /*
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
@ -111,30 +172,119 @@ void wxBitmapButton::SetLabel( const wxString &label )
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()
{
}
void wxBitmapButton::SetBitmap()
{ {
wxCHECK_RET( m_widget != NULL, "invalid button" ); wxCHECK_RET( m_widget != NULL, "invalid button" );
m_bitmap = bitmap; wxBitmap the_one;
if (!m_bitmap.Ok()) return;
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;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child );
GdkBitmap *mask = (GdkBitmap *) NULL; GdkBitmap *mask = (GdkBitmap *) NULL;
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask ); 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();
}

View File

@ -51,7 +51,7 @@ END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
wxDialog::wxDialog(void) wxDialog::wxDialog()
{ {
m_title = ""; m_title = "";
m_modalShowing = FALSE; m_modalShowing = FALSE;
@ -106,7 +106,7 @@ bool wxDialog::Create( wxWindow *parent,
return TRUE; return TRUE;
} }
wxDialog::~wxDialog(void) wxDialog::~wxDialog()
{ {
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
@ -119,7 +119,7 @@ void wxDialog::SetTitle(const wxString& title )
gtk_window_set_title( GTK_WINDOW(m_widget), 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; return (wxString&)m_title;
} }
@ -163,7 +163,7 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
// yes // yes
} }
bool wxDialog::OnClose(void) bool wxDialog::OnClose()
{ {
static wxList closing; static wxList closing;
@ -179,7 +179,7 @@ bool wxDialog::OnClose(void)
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void) bool wxDialog::Destroy()
{ {
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
@ -259,11 +259,17 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
m_resizing = FALSE; m_resizing = FALSE;
} }
void wxDialog::SetSize( int width, int height )
{
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
}
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); 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 & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
@ -285,7 +291,7 @@ bool wxDialog::Show( bool show )
return TRUE; return TRUE;
} }
bool wxDialog::IsModal(void) const bool wxDialog::IsModal() const
{ {
return m_modalShowing; return m_modalShowing;
} }
@ -301,7 +307,7 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); wxFAIL_MSG( "wxDialog:SetModal obsolete now" );
} }
int wxDialog::ShowModal(void) int wxDialog::ShowModal()
{ {
if (IsModal()) if (IsModal())
{ {
@ -337,7 +343,7 @@ void wxDialog::EndModal( int retCode )
Show( FALSE ); Show( FALSE );
} }
void wxDialog::InitDialog(void) void wxDialog::InitDialog()
{ {
wxWindow::InitDialog(); wxWindow::InitDialog();
} }

View File

@ -284,11 +284,17 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
m_resizing = FALSE; m_resizing = FALSE;
} }
void wxFrame::SetSize( int width, int height )
{
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
}
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); 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 & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 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_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; 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 ); gtk_widget_set_usize( m_widget, m_width, m_height );
// This emulates the new wxMSW behaviour // 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; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
} }
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )

View File

@ -1109,7 +1109,7 @@ wxWindow::~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(); DeleteRelatedConstraints();
if (m_constraints) if (m_constraints)