From: Robert Roebling Date: Thu, 28 May 1998 17:44:04 +0000 (+0000) Subject: GTK wxBitmapButton added X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/151ccd11af31917b4bed26f988d4db03ba32f672?ds=inline;hp=ef77f91e5be312b09b5b3cb6114f05b593376db1 GTK wxBitmapButton added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/file.h b/include/wx/file.h index 8f0f734bed..bf58ce69c0 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -21,7 +21,8 @@ // simple types // ---------------------------------------------------------------------------- -#include +#include "wx/string.h" +#include "wx/filefn.h" // define off_t #include diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 1d6260c5fc..3d7e90c69b 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -25,11 +25,6 @@ // classes //----------------------------------------------------------------------------- -class wxDC; -class wxPaintDC; -class wxMemoryDC; -class wxToolBarGTK; - class wxMask; class wxBitmap; @@ -49,13 +44,8 @@ class wxMask: public wxObject wxMask( const wxBitmap& bitmap ); ~wxMask(void); - private: + public: - friend wxBitmap; - friend wxDC; - friend wxPaintDC; - friend wxToolBarGTK; - GdkBitmap *GetBitmap(void) const; protected: @@ -103,12 +93,7 @@ class wxBitmap: public wxObject wxPalette *GetColourMap(void) const { return GetPalette(); }; - private: - - friend wxDC; - friend wxPaintDC; - friend wxMemoryDC; - friend wxToolBarGTK; + public: GdkPixmap *GetPixmap(void) const; diff --git a/include/wx/gtk/bmpbuttn.h b/include/wx/gtk/bmpbuttn.h index c8dbaba78d..57bc2c3873 100644 --- a/include/wx/gtk/bmpbuttn.h +++ b/include/wx/gtk/bmpbuttn.h @@ -27,8 +27,36 @@ class wxBitmapButton; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char *wxButtonNameStr; + //----------------------------------------------------------------------------- // wxBitmapButton //----------------------------------------------------------------------------- +class wxBitmapButton: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxBitmapButton) + + public: + + wxBitmapButton(void); + wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, + const long style = 0, const wxString &name = wxButtonNameStr ); + bool Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, + const long style = 0, const wxString &name = wxButtonNameStr ); + void SetDefault(void); + void SetLabel( const wxString &label ); + wxString GetLabel(void) const; + + public: + + wxBitmap m_bitmap; + +}; #endif // __BMPBUTTONH__ diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 1d6260c5fc..3d7e90c69b 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -25,11 +25,6 @@ // classes //----------------------------------------------------------------------------- -class wxDC; -class wxPaintDC; -class wxMemoryDC; -class wxToolBarGTK; - class wxMask; class wxBitmap; @@ -49,13 +44,8 @@ class wxMask: public wxObject wxMask( const wxBitmap& bitmap ); ~wxMask(void); - private: + public: - friend wxBitmap; - friend wxDC; - friend wxPaintDC; - friend wxToolBarGTK; - GdkBitmap *GetBitmap(void) const; protected: @@ -103,12 +93,7 @@ class wxBitmap: public wxObject wxPalette *GetColourMap(void) const { return GetPalette(); }; - private: - - friend wxDC; - friend wxPaintDC; - friend wxMemoryDC; - friend wxToolBarGTK; + public: GdkPixmap *GetPixmap(void) const; diff --git a/include/wx/gtk1/bmpbuttn.h b/include/wx/gtk1/bmpbuttn.h index c8dbaba78d..57bc2c3873 100644 --- a/include/wx/gtk1/bmpbuttn.h +++ b/include/wx/gtk1/bmpbuttn.h @@ -27,8 +27,36 @@ class wxBitmapButton; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char *wxButtonNameStr; + //----------------------------------------------------------------------------- // wxBitmapButton //----------------------------------------------------------------------------- +class wxBitmapButton: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxBitmapButton) + + public: + + wxBitmapButton(void); + wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, + const long style = 0, const wxString &name = wxButtonNameStr ); + bool Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, + const long style = 0, const wxString &name = wxButtonNameStr ); + void SetDefault(void); + void SetLabel( const wxString &label ); + wxString GetLabel(void) const; + + public: + + wxBitmap m_bitmap; + +}; #endif // __BMPBUTTONH__ diff --git a/install/gtk/configure.in b/install/gtk/configure.in index 119a69dd70..220adc215f 100644 --- a/install/gtk/configure.in +++ b/install/gtk/configure.in @@ -679,7 +679,7 @@ DEFAULT_USE_WXTREE=0 DEFAULT_USE_ENHANCED_DIALOG=0 DEFAULT_USE_FORM=0 -DEFAULT_USE_PROLOGIO=0 +DEFAULT_USE_PROLOGIO=1 DEFAULT_USE_RPC=0 DEFAULT_USE_WX_RESOURCES=1 diff --git a/src/Makefile.in b/src/Makefile.in index 10507f8fb4..c363c13264 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -58,6 +58,7 @@ LIB_CPP_SRC=\ \ gtk/app.cpp \ gtk/bitmap.cpp \ + gtk/bmpbuttn.cpp \ gtk/brush.cpp \ gtk/button.cpp \ gtk/checkbox.cpp \ diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp new file mode 100644 index 0000000000..680b11b4e3 --- /dev/null +++ b/src/gtk/bmpbuttn.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bmpbuttn.cpp +// Purpose: +// Author: Robert Roebling +// Created: 01/02/97 +// Id: +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "bmpbuttn.h" +#endif + +#include "wx/bmpbuttn.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxBitmapButton; + +//----------------------------------------------------------------------------- +// wxBitmapButton +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) + +void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +{ + wxBitmapButton *button = (wxBitmapButton*)data; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); + event.SetEventObject(button); + button->ProcessEvent(event); +}; + +//----------------------------------------------------------------------------- + +wxBitmapButton::wxBitmapButton(void) +{ +}; + +wxBitmapButton::wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + const long style, const wxString &name ) +{ + Create( parent, id, bitmap, pos, size, style, name ); +}; + +bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + const long style, const wxString &name ) +{ + m_needParent = TRUE; + + wxSize newSize = size; + + PreCreation( parent, id, pos, newSize, style, name ); + + m_bitmap = bitmap; + m_label = ""; + + m_widget = gtk_button_new(); + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = 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 ); + }; + + + + 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_button_clicked_callback), (gpointer*)this ); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxBitmapButton::SetDefault(void) +{ +}; + +void wxBitmapButton::SetLabel( const wxString &label ) +{ + wxControl::SetLabel( label ); +}; + +wxString wxBitmapButton::GetLabel(void) const +{ + return wxControl::GetLabel(); +}; diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp new file mode 100644 index 0000000000..680b11b4e3 --- /dev/null +++ b/src/gtk1/bmpbuttn.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bmpbuttn.cpp +// Purpose: +// Author: Robert Roebling +// Created: 01/02/97 +// Id: +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "bmpbuttn.h" +#endif + +#include "wx/bmpbuttn.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxBitmapButton; + +//----------------------------------------------------------------------------- +// wxBitmapButton +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) + +void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +{ + wxBitmapButton *button = (wxBitmapButton*)data; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); + event.SetEventObject(button); + button->ProcessEvent(event); +}; + +//----------------------------------------------------------------------------- + +wxBitmapButton::wxBitmapButton(void) +{ +}; + +wxBitmapButton::wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + const long style, const wxString &name ) +{ + Create( parent, id, bitmap, pos, size, style, name ); +}; + +bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, + const wxPoint &pos, const wxSize &size, + const long style, const wxString &name ) +{ + m_needParent = TRUE; + + wxSize newSize = size; + + PreCreation( parent, id, pos, newSize, style, name ); + + m_bitmap = bitmap; + m_label = ""; + + m_widget = gtk_button_new(); + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = 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 ); + }; + + + + 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_button_clicked_callback), (gpointer*)this ); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxBitmapButton::SetDefault(void) +{ +}; + +void wxBitmapButton::SetLabel( const wxString &label ) +{ + wxControl::SetLabel( label ); +}; + +wxString wxBitmapButton::GetLabel(void) const +{ + return wxControl::GetLabel(); +}; diff --git a/user/wxTest/Makefile.in b/user/wxTest/Makefile.in index a962e10290..5762eaa6cb 100644 --- a/user/wxTest/Makefile.in +++ b/user/wxTest/Makefile.in @@ -10,11 +10,11 @@ RULE=bin BIN_TARGET=wxTest # define library sources BIN_SRC=\ -wxTest.cpp +wxTest.cpp stream.cpp #define library objects BIN_OBJ=\ -wxTest.o +wxTest.o stream.o # additional things needed to link BIN_LINK=