From 1a56f55c02d718e9da7574807cb01e4d2cf6a1fa Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 28 May 1998 22:05:55 +0000 Subject: [PATCH] GTK moved main() to app.cpp added wxGauge added wxStaticBitmap git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/gauge.h | 49 ++++++++++++++++++++++++ include/wx/gtk/statbmp.h | 28 +++++++++++++- include/wx/gtk1/gauge.h | 49 ++++++++++++++++++++++++ include/wx/gtk1/statbmp.h | 28 +++++++++++++- src/Makefile.in | 2 + src/gtk/app.cpp | 16 ++++++++ src/gtk/bmpbuttn.cpp | 2 - src/gtk/gauge.cpp | 71 +++++++++++++++++++++++++++++++++++ src/gtk/statbmp.cpp | 79 +++++++++++++++++++++++++++++++++++++++ src/gtk1/app.cpp | 16 ++++++++ src/gtk1/bmpbuttn.cpp | 2 - src/gtk1/gauge.cpp | 71 +++++++++++++++++++++++++++++++++++ src/gtk1/statbmp.cpp | 79 +++++++++++++++++++++++++++++++++++++++ user/wxTest/Makefile.in | 4 +- 14 files changed, 488 insertions(+), 8 deletions(-) create mode 100644 src/gtk/gauge.cpp create mode 100644 src/gtk/statbmp.cpp create mode 100644 src/gtk1/gauge.cpp create mode 100644 src/gtk1/statbmp.cpp diff --git a/include/wx/gtk/gauge.h b/include/wx/gtk/gauge.h index 49e031fea2..802e60fff7 100644 --- a/include/wx/gtk/gauge.h +++ b/include/wx/gtk/gauge.h @@ -27,8 +27,57 @@ class wxGauge; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxGaugeNameStr; + //----------------------------------------------------------------------------- // wxGaugeBox //----------------------------------------------------------------------------- +class wxGauge: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxGauge) + + public: + inline wxGauge(void) { m_rangeMax = 0; m_gaugePos = 0; m_useProgressBar = TRUE; } + + inline wxGauge(wxWindow *parent, const wxWindowID id, + const int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const long style = wxGA_HORIZONTAL, + const wxString& name = wxGaugeNameStr) + { + Create(parent, id, range, pos, size, style, name); + }; + + bool Create(wxWindow *parent, const wxWindowID id, + const int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const long style = wxGA_HORIZONTAL, + const wxString& name = wxGaugeNameStr ); + + void SetShadowWidth( const int WXUNUSED(w) ) {}; + void SetBezelFace( const int WXUNUSED(w) ) {}; + void SetRange( const int r ); + void SetValue( const int pos ); + int GetShadowWidth(void) const { return 0; }; + int GetBezelFace(void) const { return 0; }; + int GetRange(void) const; + int GetValue(void) const; + + // Are we a Win95/GTK progress bar, or a normal gauge? + inline bool GetProgressBar(void) const { return m_useProgressBar; } + + protected: + + int m_rangeMax; + int m_gaugePos; + bool m_useProgressBar; +}; + #endif // __GTKGAUGEH__ diff --git a/include/wx/gtk/statbmp.h b/include/wx/gtk/statbmp.h index d6731e42d6..ec24d42dea 100644 --- a/include/wx/gtk/statbmp.h +++ b/include/wx/gtk/statbmp.h @@ -18,7 +18,6 @@ #include "wx/defs.h" #include "wx/object.h" -#include "wx/list.h" #include "wx/control.h" //----------------------------------------------------------------------------- @@ -27,8 +26,35 @@ class wxStaticBitmap; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxStaticBitmapNameStr; + //----------------------------------------------------------------------------- // wxStaticBitmap //----------------------------------------------------------------------------- +class wxStaticBitmap: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxStaticBitmap) + + public: + + wxStaticBitmap(void); + wxStaticBitmap( wxWindow *parent, const wxWindowID id, const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + const long style = 0, const wxString& name = wxStaticBitmapNameStr ); + bool Create( wxWindow *parent, const wxWindowID id, const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + const long style = 0, const wxString& name = wxStaticBitmapNameStr); + virtual void SetBitmap( const wxBitmap& bitmap ); + wxBitmap& GetBitmap(void) const { return (wxBitmap&)m_bitmap; } + + private: + + wxBitmap m_bitmap; +}; + #endif // __GTKSTATICBITMAPH__ diff --git a/include/wx/gtk1/gauge.h b/include/wx/gtk1/gauge.h index 49e031fea2..802e60fff7 100644 --- a/include/wx/gtk1/gauge.h +++ b/include/wx/gtk1/gauge.h @@ -27,8 +27,57 @@ class wxGauge; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxGaugeNameStr; + //----------------------------------------------------------------------------- // wxGaugeBox //----------------------------------------------------------------------------- +class wxGauge: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxGauge) + + public: + inline wxGauge(void) { m_rangeMax = 0; m_gaugePos = 0; m_useProgressBar = TRUE; } + + inline wxGauge(wxWindow *parent, const wxWindowID id, + const int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const long style = wxGA_HORIZONTAL, + const wxString& name = wxGaugeNameStr) + { + Create(parent, id, range, pos, size, style, name); + }; + + bool Create(wxWindow *parent, const wxWindowID id, + const int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const long style = wxGA_HORIZONTAL, + const wxString& name = wxGaugeNameStr ); + + void SetShadowWidth( const int WXUNUSED(w) ) {}; + void SetBezelFace( const int WXUNUSED(w) ) {}; + void SetRange( const int r ); + void SetValue( const int pos ); + int GetShadowWidth(void) const { return 0; }; + int GetBezelFace(void) const { return 0; }; + int GetRange(void) const; + int GetValue(void) const; + + // Are we a Win95/GTK progress bar, or a normal gauge? + inline bool GetProgressBar(void) const { return m_useProgressBar; } + + protected: + + int m_rangeMax; + int m_gaugePos; + bool m_useProgressBar; +}; + #endif // __GTKGAUGEH__ diff --git a/include/wx/gtk1/statbmp.h b/include/wx/gtk1/statbmp.h index d6731e42d6..ec24d42dea 100644 --- a/include/wx/gtk1/statbmp.h +++ b/include/wx/gtk1/statbmp.h @@ -18,7 +18,6 @@ #include "wx/defs.h" #include "wx/object.h" -#include "wx/list.h" #include "wx/control.h" //----------------------------------------------------------------------------- @@ -27,8 +26,35 @@ class wxStaticBitmap; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxStaticBitmapNameStr; + //----------------------------------------------------------------------------- // wxStaticBitmap //----------------------------------------------------------------------------- +class wxStaticBitmap: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxStaticBitmap) + + public: + + wxStaticBitmap(void); + wxStaticBitmap( wxWindow *parent, const wxWindowID id, const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + const long style = 0, const wxString& name = wxStaticBitmapNameStr ); + bool Create( wxWindow *parent, const wxWindowID id, const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + const long style = 0, const wxString& name = wxStaticBitmapNameStr); + virtual void SetBitmap( const wxBitmap& bitmap ); + wxBitmap& GetBitmap(void) const { return (wxBitmap&)m_bitmap; } + + private: + + wxBitmap m_bitmap; +}; + #endif // __GTKSTATICBITMAPH__ diff --git a/src/Makefile.in b/src/Makefile.in index c363c13264..876e27bd92 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -76,6 +76,7 @@ LIB_CPP_SRC=\ gtk/filedlg.cpp \ gtk/font.cpp \ gtk/frame.cpp \ + gtk/gauge.cpp \ gtk/gdiobj.cpp \ gtk/icon.cpp \ gtk/listbox.cpp \ @@ -90,6 +91,7 @@ LIB_CPP_SRC=\ gtk/settings.cpp \ gtk/slider.cpp \ gtk/statbox.cpp \ + gtk/statbmp.cpp \ gtk/stattext.cpp \ gtk/tbargtk.cpp \ gtk/textctrl.cpp \ diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 47c1ee0a72..391f5a8d1c 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -277,3 +277,19 @@ int wxEntry( int argc, char *argv[] ) return retValue; }; + +//----------------------------------------------------------------------------- +// main() +//----------------------------------------------------------------------------- + +#if defined(AIX) || defined(AIX4) /* || defined(____HPUX__) */ + + // main in IMPLEMENT_WX_MAIN in IMPLEMENT_APP in app.h + +#else + + int main(int argc, char *argv[]) { return wxEntry(argc, argv); } + +#endif + + diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index 680b11b4e3..23909f6f3f 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -72,8 +72,6 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b 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 ); diff --git a/src/gtk/gauge.cpp b/src/gtk/gauge.cpp new file mode 100644 index 0000000000..bd679ff044 --- /dev/null +++ b/src/gtk/gauge.cpp @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gauge.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 "gauge.h" +#endif + +#include "wx/gauge.h" + +//----------------------------------------------------------------------------- +// wxGauge +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl) + +bool wxGauge::Create( wxWindow *parent, const wxWindowID id, const int range, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_needParent = TRUE; + + wxSize newSize = size; + + PreCreation( parent, id, pos, size, style, name ); + + m_rangeMax = range; + m_gaugePos = 0; + m_useProgressBar = TRUE; + + m_widget = gtk_progress_bar_new(); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxGauge::SetRange( const int r ) +{ + m_rangeMax = r; + if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; + + gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) ); +}; + +void wxGauge::SetValue( const int pos ) +{ + m_gaugePos = pos; + if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; + + gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) ); +}; + +int wxGauge::GetRange(void) const +{ + return m_rangeMax; +}; + +int wxGauge::GetValue(void) const +{ + return m_gaugePos; +}; + diff --git a/src/gtk/statbmp.cpp b/src/gtk/statbmp.cpp new file mode 100644 index 0000000000..9b8d050d61 --- /dev/null +++ b/src/gtk/statbmp.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: statbmp.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 "statbmp.h" +#endif + +#include "wx/statbmp.h" + +//----------------------------------------------------------------------------- +// wxStaticBitmap +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl) + +wxStaticBitmap::wxStaticBitmap(void) +{ +}; + +wxStaticBitmap::wxStaticBitmap( 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 wxStaticBitmap::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, size, style, name ); + + m_bitmap = bitmap; + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); + + if (newSize.x == -1) newSize.x = m_bitmap.GetWidth(); + if (newSize.y == -1) newSize.y = m_bitmap.GetHeight(); + SetSize( newSize.x, newSize.y ); + } + else + { + m_widget = gtk_label_new( "Bitmap" ); + } + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) +{ + m_bitmap = bitmap; + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask ); + } +}; + diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 47c1ee0a72..391f5a8d1c 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -277,3 +277,19 @@ int wxEntry( int argc, char *argv[] ) return retValue; }; + +//----------------------------------------------------------------------------- +// main() +//----------------------------------------------------------------------------- + +#if defined(AIX) || defined(AIX4) /* || defined(____HPUX__) */ + + // main in IMPLEMENT_WX_MAIN in IMPLEMENT_APP in app.h + +#else + + int main(int argc, char *argv[]) { return wxEntry(argc, argv); } + +#endif + + diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index 680b11b4e3..23909f6f3f 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -72,8 +72,6 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b 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 ); diff --git a/src/gtk1/gauge.cpp b/src/gtk1/gauge.cpp new file mode 100644 index 0000000000..bd679ff044 --- /dev/null +++ b/src/gtk1/gauge.cpp @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gauge.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 "gauge.h" +#endif + +#include "wx/gauge.h" + +//----------------------------------------------------------------------------- +// wxGauge +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl) + +bool wxGauge::Create( wxWindow *parent, const wxWindowID id, const int range, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_needParent = TRUE; + + wxSize newSize = size; + + PreCreation( parent, id, pos, size, style, name ); + + m_rangeMax = range; + m_gaugePos = 0; + m_useProgressBar = TRUE; + + m_widget = gtk_progress_bar_new(); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxGauge::SetRange( const int r ) +{ + m_rangeMax = r; + if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; + + gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) ); +}; + +void wxGauge::SetValue( const int pos ) +{ + m_gaugePos = pos; + if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; + + gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) ); +}; + +int wxGauge::GetRange(void) const +{ + return m_rangeMax; +}; + +int wxGauge::GetValue(void) const +{ + return m_gaugePos; +}; + diff --git a/src/gtk1/statbmp.cpp b/src/gtk1/statbmp.cpp new file mode 100644 index 0000000000..9b8d050d61 --- /dev/null +++ b/src/gtk1/statbmp.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: statbmp.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 "statbmp.h" +#endif + +#include "wx/statbmp.h" + +//----------------------------------------------------------------------------- +// wxStaticBitmap +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl) + +wxStaticBitmap::wxStaticBitmap(void) +{ +}; + +wxStaticBitmap::wxStaticBitmap( 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 wxStaticBitmap::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, size, style, name ); + + m_bitmap = bitmap; + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); + + if (newSize.x == -1) newSize.x = m_bitmap.GetWidth(); + if (newSize.y == -1) newSize.y = m_bitmap.GetHeight(); + SetSize( newSize.x, newSize.y ); + } + else + { + m_widget = gtk_label_new( "Bitmap" ); + } + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) +{ + m_bitmap = bitmap; + + if (m_bitmap.Ok()) + { + GdkBitmap *mask = NULL; + if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); + gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask ); + } +}; + diff --git a/user/wxTest/Makefile.in b/user/wxTest/Makefile.in index 5762eaa6cb..a962e10290 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 stream.cpp +wxTest.cpp #define library objects BIN_OBJ=\ -wxTest.o stream.o +wxTest.o # additional things needed to link BIN_LINK= -- 2.45.2