From c33c405087d33bb001be979c8bca5146f5133d48 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 15 Aug 1998 10:52:09 +0000 Subject: [PATCH] See last changelog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/bitmap.h | 3 ++ include/wx/gtk/dialog.h | 12 +++++ include/wx/gtk/font.h | 2 +- include/wx/gtk/frame.h | 8 ++-- include/wx/gtk/mdi.h | 2 +- include/wx/gtk/menu.h | 13 ++++-- include/wx/gtk/window.h | 25 ++++++++-- include/wx/gtk1/bitmap.h | 3 ++ include/wx/gtk1/dialog.h | 12 +++++ include/wx/gtk1/font.h | 2 +- include/wx/gtk1/frame.h | 8 ++-- include/wx/gtk1/mdi.h | 2 +- include/wx/gtk1/menu.h | 13 ++++-- include/wx/gtk1/window.h | 25 ++++++++-- include/wx/treectrl.h | 2 +- misc/imlib/im_palette.pal | 98 +++++++++++++++++++++++---------------- src/gtk/dcclient.cpp | 17 ++++--- src/gtk/dialog.cpp | 71 +++++++++++++++++++--------- src/gtk/font.cpp | 2 +- src/gtk/frame.cpp | 5 +- src/gtk/menu.cpp | 26 +++++++++-- src/gtk/window.cpp | 30 ++++++++++-- src/gtk1/dcclient.cpp | 17 ++++--- src/gtk1/dialog.cpp | 71 +++++++++++++++++++--------- src/gtk1/font.cpp | 2 +- src/gtk1/frame.cpp | 5 +- src/gtk1/menu.cpp | 26 +++++++++-- src/gtk1/window.cpp | 30 ++++++++++-- 28 files changed, 382 insertions(+), 150 deletions(-) diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index fe5f8eddec..f96d9d4684 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -32,6 +32,7 @@ class wxToolBar; class wxBitmapButton; class wxStaticBitmap; class wxFrame; +class wxDialog; class wxTreeCtrl; class wxMask; @@ -62,6 +63,7 @@ class wxMask: public wxObject friend wxBitmapButton; friend wxStaticBitmap; friend wxFrame; + friend wxDialog; friend wxTreeCtrl; GdkBitmap *GetBitmap() const; @@ -124,6 +126,7 @@ class wxBitmap: public wxObject friend wxBitmapButton; friend wxStaticBitmap; friend wxFrame; + friend wxDialog; friend wxTreeCtrl; GdkPixmap *GetPixmap() const; diff --git a/include/wx/gtk/dialog.h b/include/wx/gtk/dialog.h index 5bd1564976..236b8cc024 100644 --- a/include/wx/gtk/dialog.h +++ b/include/wx/gtk/dialog.h @@ -21,6 +21,7 @@ #include "wx/string.h" #include "wx/event.h" #include "wx/window.h" +#include "wx/icon.h" //----------------------------------------------------------------------------- // forward decls @@ -74,9 +75,19 @@ class wxDialog: public wxWindow virtual int ShowModal(void); virtual void EndModal(int retCode); virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } + void SetModal( bool modal ); virtual void InitDialog(void); virtual void Centre( int direction = wxHORIZONTAL ); + virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); + + 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) { } + private: friend wxWindow; @@ -85,6 +96,7 @@ class wxDialog: public wxWindow bool m_modalShowing; wxString m_title; + wxIcon m_icon; virtual void ImplementSetPosition(); diff --git a/include/wx/gtk/font.h b/include/wx/gtk/font.h index bb928ffa74..a42fc975c0 100644 --- a/include/wx/gtk/font.h +++ b/include/wx/gtk/font.h @@ -81,7 +81,7 @@ class wxFont: public wxGDIObject friend wxPaintDC; friend wxWindow; - GdkFont* GetInternalFont(float scale = 1.0); + GdkFont* GetInternalFont(float scale = 1.0) const; // no data :-) }; diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index d62557e9e9..2464fdfb83 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -89,9 +89,11 @@ public: virtual wxString GetTitle() const { return m_title; } virtual void SetIcon( const wxIcon &icon ); - void Iconize( bool WXUNUSED(iconize)) { } - bool IsIconized(void) const { return FALSE; } - bool Iconized(void) const { return FALSE; } + 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) {} void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index 497f302e60..beda136fb7 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -152,7 +152,7 @@ class wxMDIChildFrame: public wxFrame virtual void Maximize(void) {} virtual void Restore(void) {} - void OnActivate( wxActivateEvent &event ); + void OnActivate( wxActivateEvent &event ); public: diff --git a/include/wx/gtk/menu.h b/include/wx/gtk/menu.h index 5ce6c353cc..6e5232dd50 100644 --- a/include/wx/gtk/menu.h +++ b/include/wx/gtk/menu.h @@ -95,11 +95,12 @@ public: // state void Enable(bool enable = TRUE) { m_isEnabled = enable; } bool IsEnabled() const { return m_isEnabled; } - void Check(bool check = TRUE); + void Check( bool check = TRUE ); bool IsChecked() const; // help string (displayed in the status bar by default) - void SetHelpString(const wxString& str) { m_helpStr = str; } + void SetHelp(const wxString& str) { m_helpStr = str; } + const wxString& GetHelp() const { return m_helpStr; } // implementation void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; } @@ -136,7 +137,8 @@ public: // find item by name/id int FindItem( const wxString itemString ) const; - wxMenuItem *FindItem(int id) const; + wxMenuItem *FindItem( int id ) const; + wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); } // get/set item's state void Enable( int id, bool enable ); @@ -145,7 +147,12 @@ public: bool IsChecked( int id ) const; void SetLabel( int id, const wxString &label ); + wxString GetLabel(int id) const; + // helpstring + virtual void SetHelpString(int id, const wxString& helpString); + virtual wxString GetHelpString(int id) const ; + // accessors wxList& GetItems() { return m_items; } diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 346fb13f40..57b2dc7374 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -96,6 +96,9 @@ public: virtual void GetPosition( int *x, int *y ) const; virtual void Centre( int direction = wxHORIZONTAL ); virtual void Fit(); + // set minimal/maxmimal size for the frame + virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), + int WXUNUSED(maxH), int WXUNUSED(incW) ) { } void OnSize( wxSizeEvent &event ); void OnIdle( wxIdleEvent& event ); @@ -113,7 +116,12 @@ public: virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); - wxWindow *GetParent(); + wxWindow *GetParent() const + { return m_parent; } + wxWindow *GetGrandParent(void) const + { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } + void wxWindow::SetParent( wxWindow *p ) + { m_parent = p; } wxEvtHandler *GetEventHandler(); void SetEventHandler( wxEvtHandler *handler ); @@ -139,15 +147,22 @@ public: virtual void SetBackgroundColour( const wxColour &colour ); virtual wxColour GetForegroundColour() const; virtual void SetForegroundColour( const wxColour &colour ); + + virtual int GetCharHeight(void) const; + virtual int GetCharWidth(void) const; + virtual void GetTextExtent( const wxString& string, int *x, int *y, + int *descent = NULL, + int *externalLeading = NULL, + const wxFont *theFont = NULL, bool use16 = FALSE) const; virtual void SetDefaultBackgroundColour( const wxColour& col ) - { m_defaultBackgroundColour = col; }; + { m_defaultBackgroundColour = col; } virtual wxColour GetDefaultBackgroundColour() const - { return m_defaultBackgroundColour; }; + { return m_defaultBackgroundColour; } virtual void SetDefaultForegroundColour( const wxColour& col ) - { m_defaultForegroundColour = col; }; + { m_defaultForegroundColour = col; } virtual wxColour GetDefaultForegroundColour() const - { return m_defaultForegroundColour; }; + { return m_defaultForegroundColour; } virtual void SetFont( const wxFont &font ); virtual wxFont *GetFont(); diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index fe5f8eddec..f96d9d4684 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -32,6 +32,7 @@ class wxToolBar; class wxBitmapButton; class wxStaticBitmap; class wxFrame; +class wxDialog; class wxTreeCtrl; class wxMask; @@ -62,6 +63,7 @@ class wxMask: public wxObject friend wxBitmapButton; friend wxStaticBitmap; friend wxFrame; + friend wxDialog; friend wxTreeCtrl; GdkBitmap *GetBitmap() const; @@ -124,6 +126,7 @@ class wxBitmap: public wxObject friend wxBitmapButton; friend wxStaticBitmap; friend wxFrame; + friend wxDialog; friend wxTreeCtrl; GdkPixmap *GetPixmap() const; diff --git a/include/wx/gtk1/dialog.h b/include/wx/gtk1/dialog.h index 5bd1564976..236b8cc024 100644 --- a/include/wx/gtk1/dialog.h +++ b/include/wx/gtk1/dialog.h @@ -21,6 +21,7 @@ #include "wx/string.h" #include "wx/event.h" #include "wx/window.h" +#include "wx/icon.h" //----------------------------------------------------------------------------- // forward decls @@ -74,9 +75,19 @@ class wxDialog: public wxWindow virtual int ShowModal(void); virtual void EndModal(int retCode); virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } + void SetModal( bool modal ); virtual void InitDialog(void); virtual void Centre( int direction = wxHORIZONTAL ); + virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); + + 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) { } + private: friend wxWindow; @@ -85,6 +96,7 @@ class wxDialog: public wxWindow bool m_modalShowing; wxString m_title; + wxIcon m_icon; virtual void ImplementSetPosition(); diff --git a/include/wx/gtk1/font.h b/include/wx/gtk1/font.h index bb928ffa74..a42fc975c0 100644 --- a/include/wx/gtk1/font.h +++ b/include/wx/gtk1/font.h @@ -81,7 +81,7 @@ class wxFont: public wxGDIObject friend wxPaintDC; friend wxWindow; - GdkFont* GetInternalFont(float scale = 1.0); + GdkFont* GetInternalFont(float scale = 1.0) const; // no data :-) }; diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index d62557e9e9..2464fdfb83 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -89,9 +89,11 @@ public: virtual wxString GetTitle() const { return m_title; } virtual void SetIcon( const wxIcon &icon ); - void Iconize( bool WXUNUSED(iconize)) { } - bool IsIconized(void) const { return FALSE; } - bool Iconized(void) const { return FALSE; } + 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) {} void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index 497f302e60..beda136fb7 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -152,7 +152,7 @@ class wxMDIChildFrame: public wxFrame virtual void Maximize(void) {} virtual void Restore(void) {} - void OnActivate( wxActivateEvent &event ); + void OnActivate( wxActivateEvent &event ); public: diff --git a/include/wx/gtk1/menu.h b/include/wx/gtk1/menu.h index 5ce6c353cc..6e5232dd50 100644 --- a/include/wx/gtk1/menu.h +++ b/include/wx/gtk1/menu.h @@ -95,11 +95,12 @@ public: // state void Enable(bool enable = TRUE) { m_isEnabled = enable; } bool IsEnabled() const { return m_isEnabled; } - void Check(bool check = TRUE); + void Check( bool check = TRUE ); bool IsChecked() const; // help string (displayed in the status bar by default) - void SetHelpString(const wxString& str) { m_helpStr = str; } + void SetHelp(const wxString& str) { m_helpStr = str; } + const wxString& GetHelp() const { return m_helpStr; } // implementation void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; } @@ -136,7 +137,8 @@ public: // find item by name/id int FindItem( const wxString itemString ) const; - wxMenuItem *FindItem(int id) const; + wxMenuItem *FindItem( int id ) const; + wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); } // get/set item's state void Enable( int id, bool enable ); @@ -145,7 +147,12 @@ public: bool IsChecked( int id ) const; void SetLabel( int id, const wxString &label ); + wxString GetLabel(int id) const; + // helpstring + virtual void SetHelpString(int id, const wxString& helpString); + virtual wxString GetHelpString(int id) const ; + // accessors wxList& GetItems() { return m_items; } diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 346fb13f40..57b2dc7374 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -96,6 +96,9 @@ public: virtual void GetPosition( int *x, int *y ) const; virtual void Centre( int direction = wxHORIZONTAL ); virtual void Fit(); + // set minimal/maxmimal size for the frame + virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), + int WXUNUSED(maxH), int WXUNUSED(incW) ) { } void OnSize( wxSizeEvent &event ); void OnIdle( wxIdleEvent& event ); @@ -113,7 +116,12 @@ public: virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); - wxWindow *GetParent(); + wxWindow *GetParent() const + { return m_parent; } + wxWindow *GetGrandParent(void) const + { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } + void wxWindow::SetParent( wxWindow *p ) + { m_parent = p; } wxEvtHandler *GetEventHandler(); void SetEventHandler( wxEvtHandler *handler ); @@ -139,15 +147,22 @@ public: virtual void SetBackgroundColour( const wxColour &colour ); virtual wxColour GetForegroundColour() const; virtual void SetForegroundColour( const wxColour &colour ); + + virtual int GetCharHeight(void) const; + virtual int GetCharWidth(void) const; + virtual void GetTextExtent( const wxString& string, int *x, int *y, + int *descent = NULL, + int *externalLeading = NULL, + const wxFont *theFont = NULL, bool use16 = FALSE) const; virtual void SetDefaultBackgroundColour( const wxColour& col ) - { m_defaultBackgroundColour = col; }; + { m_defaultBackgroundColour = col; } virtual wxColour GetDefaultBackgroundColour() const - { return m_defaultBackgroundColour; }; + { return m_defaultBackgroundColour; } virtual void SetDefaultForegroundColour( const wxColour& col ) - { m_defaultForegroundColour = col; }; + { m_defaultForegroundColour = col; } virtual wxColour GetDefaultForegroundColour() const - { return m_defaultForegroundColour; }; + { return m_defaultForegroundColour; } virtual void SetFont( const wxFont &font ); virtual wxFont *GetFont(); diff --git a/include/wx/treectrl.h b/include/wx/treectrl.h index 8d6928b669..0fce45a8a2 100644 --- a/include/wx/treectrl.h +++ b/include/wx/treectrl.h @@ -6,7 +6,7 @@ #elif defined(__WXMOTIF__) #include "wx/generic/treectrl.h" #elif defined(__WXGTK__) -#include "wx/gtk/treectrl.h" +#include "wx/generic/treectrl.h" #elif defined(__WXQT__) #include "wx/qt/treectrl.h" #elif defined(__WXMAC__) diff --git a/misc/imlib/im_palette.pal b/misc/imlib/im_palette.pal index 44660998d4..7464319c3f 100644 --- a/misc/imlib/im_palette.pal +++ b/misc/imlib/im_palette.pal @@ -1,4 +1,4 @@ -0x00 0x00 0x00 +0x0 0x0 0x0 0xff 0xff 0xff 0xdd 0xdd 0xdd 0xbb 0xbb 0xbb @@ -6,43 +6,59 @@ 0x77 0x77 0x77 0x55 0x55 0x55 0x33 0x33 0x33 -0x88 0x00 0x00 -0xcc 0x00 0x00 -0xff 0x00 0x00 -0xff 0x44 0x00 -0xff 0x88 0x00 -0xff 0xcc 0x00 -0xff 0xff 0x00 -0xcc 0xcc 0x00 -0x88 0x88 0x00 -0x44 0x44 0x00 -0x00 0x44 0x00 -0x00 0x88 0x00 -0x00 0xcc 0x00 -0x00 0xff 0x00 -0x00 0x44 0x44 -0x00 0x88 0x88 -0x00 0xff 0xff -0x00 0x00 0x44 -0x00 0x00 0x88 -0x00 0x00 0xff -0x88 0x00 0x88 -0xff 0xcc 0x99 -0xcc 0xaa 0x77 -0xaa 0x88 0x55 -0x88 0x66 0x33 -0x66 0x44 0x11 -0x44 0x22 0x00 -0x22 0x00 0x00 -0x00 0x44 0x88 -0x44 0x88 0xcc -0x88 0xcc 0xff -0x00 0xcc 0x44 -0x44 0x88 0x44 -0x88 0xcc 0x00 -0x22 0x44 0x11 -0x33 0x66 0x22 -0x44 0x55 0x33 -0x66 0x88 0x44 -0x33 0x66 0x22 -0x22 0x44 0x11 +0x88 0x0 0x0 +0xcc 0x0 0x0 +0xff 0x0 0x0 +0xff 0x44 0x0 +0xff 0x88 0x0 +0xff 0xcc 0x0 +0xff 0xff 0x0 +0xcc 0xcc 0x0 +0x88 0x88 0x0 +0x60 0x60 0x0 +0x0 0x43 0x0 +0x0 0x7f 0x0 +0x0 0xcc 0x0 +0x0 0xff 0x0 +0x0 0x44 0x44 +0x0 0x88 0x88 +0x0 0xff 0xff +0x0 0x0 0x44 +0x0 0x0 0x88 +0x0 0x0 0xff +0xff 0xcc 0x97 +0xef 0xb1 0x7b +0xdf 0x98 0x5f +0xbf 0x87 0x56 +0x9f 0x6b 0x42 +0x7f 0x57 0x26 +0x5f 0x39 0xc +0x3f 0x1c 0x0 +0x21 0x0 0x0 +0x0 0x43 0x87 +0x2d 0x70 0xaf +0x5a 0x9e 0xd7 +0x87 0xcc 0xff +0xff 0xe0 0xba +0x21 0x43 0xf +0x3d 0x5d 0x25 +0x59 0x78 0x3a +0x75 0x93 0x4f +0x91 0xae 0x64 +0xad 0xc8 0x7a +0xf0 0xa8 0xef +0xd0 0x88 0xd0 +0xaf 0x66 0xaf +0x8e 0x44 0x8e +0x6d 0x22 0x6d +0x4b 0x0 0x4b +0xff 0xc0 0xbc +0xff 0x93 0x91 +0xff 0x66 0x67 +0xd8 0xf2 0xbf +0xff 0xc9 0x68 +0xff 0x96 0x67 +0xa5 0x60 0xff +0x51 0xff 0x99 +0x3f 0xa5 0x63 +0x98 0x90 0x67 diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index e75db15ce0..e8473c5318 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -552,22 +552,25 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us } } - - bool wxPaintDC::CanGetTextExtent(void) const { return TRUE; } void wxPaintDC::GetTextExtent( const wxString &string, long *width, long *height, - long *WXUNUSED(descent), long *WXUNUSED(externalLeading), - wxFont *WXUNUSED(theFont), bool WXUNUSED(use16) ) + long *descent, long *externalLeading, + wxFont *theFont, bool WXUNUSED(use16) ) { if (!Ok()) return; - GdkFont *font = m_font.GetInternalFont( m_scaleY ); + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; + + GdkFont *font = fontToUse.GetInternalFont( m_scaleY ); if (width) (*width) = long(gdk_string_width( font, string ) / m_scaleX); if (height) (*height) = long((font->ascent + font->descent) / m_scaleY); + if (descent) (*descent) = long(font->descent / m_scaleY); + if (externalLeading) (*externalLeading) = 0; // ?? } long wxPaintDC::GetCharWidth(void) @@ -575,7 +578,7 @@ long wxPaintDC::GetCharWidth(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return gdk_string_width( font, "H" ); + return long(gdk_string_width( font, "H" ) / m_scaleX); } long wxPaintDC::GetCharHeight(void) @@ -583,7 +586,7 @@ long wxPaintDC::GetCharHeight(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return font->ascent + font->descent; + return long((font->ascent + font->descent) / m_scaleY); } void wxPaintDC::Clear(void) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 5e7a3a60b6..6ce4890d79 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -36,7 +36,7 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED win->Close(); return TRUE; -}; +} //----------------------------------------------------------------------------- // wxDialog @@ -56,7 +56,7 @@ wxDialog::wxDialog(void) m_title = ""; m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); -}; +} wxDialog::wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, @@ -66,7 +66,7 @@ wxDialog::wxDialog( wxWindow *parent, m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); -}; +} bool wxDialog::Create( wxWindow *parent, wxWindowID id, const wxString &title, @@ -101,30 +101,30 @@ bool wxDialog::Create( wxWindow *parent, PostCreation(); return TRUE; -}; +} wxDialog::~wxDialog(void) { wxTopLevelWindows.DeleteObject( this ); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); -}; +} 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 { return (wxString&)m_title; -}; +} void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) { if (Validate()) TransferDataFromWindow(); -}; +} void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { @@ -136,8 +136,8 @@ void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { SetReturnCode(wxID_CANCEL); this->Show(FALSE); - }; -}; + } +} void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { @@ -151,14 +151,14 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { SetReturnCode(wxID_OK); this->Show(FALSE); - }; - }; -}; + } + } +} void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) { // yes -}; +} bool wxDialog::OnClose(void) { @@ -189,8 +189,8 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) if (GetEventHandler()->OnClose() || event.GetForce()) { this->Destroy(); - }; -}; + } +} void wxDialog::ImplementSetPosition(void) { @@ -210,14 +210,22 @@ bool wxDialog::Show( bool show ) if (!show && IsModal() && m_modalShowing) { EndModal( wxID_CANCEL ); - }; + } wxWindow::Show( show ); if (show) InitDialog(); return TRUE; -}; +} + +void wxDialog::SetModal(bool flag) +{ + if (flag) + m_windowStyle |= wxDIALOG_MODAL; + else + if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; +} int wxDialog::ShowModal(void) { @@ -232,7 +240,7 @@ int wxDialog::ShowModal(void) gtk_grab_remove( m_widget ); return GetReturnCode(); -}; +} void wxDialog::EndModal( int retCode ) { @@ -242,15 +250,34 @@ void wxDialog::EndModal( int retCode ) { wxFAIL_MSG( "wxDialog: called EndModal twice" ); return; - }; + } m_modalShowing = FALSE; gtk_main_quit(); -}; +} void wxDialog::InitDialog(void) { wxWindow::InitDialog(); -}; +} + +void wxDialog::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW) ) +{ + gdk_window_set_hints( m_widget->window, -1, -1, + minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); +} + +void wxDialog::SetIcon( const wxIcon &icon ) +{ + m_icon = icon; + if (!icon.Ok()) return; + + wxMask *mask = icon.GetMask(); + GdkBitmap *bm = NULL; + if (mask) bm = mask->GetBitmap(); + + gdk_window_set_icon( m_widget->window, NULL, icon.GetPixmap(), bm ); +} + diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index ad4f5e9654..a048a12227 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -255,7 +255,7 @@ static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, int style, int weight, bool underlined); -GdkFont *wxFont::GetInternalFont(float scale) +GdkFont *wxFont::GetInternalFont(float scale) const { if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 716e2ee662..d7475b3a8e 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -515,9 +515,8 @@ void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW) ) { - if (m_wxwindow) - gdk_window_set_hints( m_wxwindow->window, -1, -1, - minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); + gdk_window_set_hints( m_widget->window, -1, -1, + minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); } void wxFrame::SetIcon( const wxIcon &icon ) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 35832b897f..6cd28ae420 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -254,7 +254,7 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool wxMenuItem *mitem = new wxMenuItem(); mitem->SetId(id); mitem->SetText(item); - mitem->SetHelpString(helpStr); + mitem->SetHelp(helpStr); mitem->SetCheckable(checkable); const char *text = mitem->GetText(); GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label(text) @@ -277,7 +277,7 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri mitem->SetText(text); GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText()); - mitem->SetHelpString(helpStr); + mitem->SetHelp(helpStr); mitem->SetMenuItem(menuItem); mitem->SetSubMenu(subMenu); @@ -344,10 +344,30 @@ bool wxMenu::IsChecked( int id ) const void wxMenu::SetLabel( int id, const wxString &label ) { wxMenuItem *item = FindItem(id); - if ( item ) + if (item) item->SetText(label); } +wxString wxMenu::GetLabel( int id ) const +{ + wxMenuItem *item = FindItem(id); + if (item) return item->GetText(); + return ""; +} + +void wxMenu::SetHelpString( int id, const wxString& helpString ) +{ + wxMenuItem *item = FindItem(id); + if (item) item->SetHelp( helpString ); +} + +wxString wxMenu::GetHelpString( int id ) const +{ + wxMenuItem *item = FindItem(id); + if (item) return item->GetHelp(); + return ""; +} + int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const { wxNode *node = m_items.First(); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 12a31edeaa..81628667f9 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1393,6 +1393,31 @@ void wxWindow::Enable( bool enable ) if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable ); } +int wxWindow::GetCharHeight(void) const +{ + GdkFont *font = m_font.GetInternalFont( 1.0 ); + return font->ascent + font->descent; +} + +int wxWindow::GetCharWidth(void) const +{ + GdkFont *font = m_font.GetInternalFont( 1.0 ); + return gdk_string_width( font, "H" ); +} + +void wxWindow::GetTextExtent( const wxString& string, int *x, int *y, + int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const +{ + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; + + GdkFont *font = fontToUse.GetInternalFont( 1.0 ); + if (x) (*y) = gdk_string_width( font, string ); + if (y) (*y) = font->ascent + font->descent; + if (descent) (*descent) = font->descent; + if (externalLeading) (*externalLeading) = 0; // ?? +} + void wxWindow::MakeModal( bool modal ) { return; @@ -1516,11 +1541,6 @@ int wxWindow::GetReturnCode(void) return m_retCode; } -wxWindow *wxWindow::GetParent(void) -{ - return m_parent; -} - void wxWindow::Raise(void) { if (m_widget) gdk_window_raise( m_widget->window ); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index e75db15ce0..e8473c5318 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -552,22 +552,25 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us } } - - bool wxPaintDC::CanGetTextExtent(void) const { return TRUE; } void wxPaintDC::GetTextExtent( const wxString &string, long *width, long *height, - long *WXUNUSED(descent), long *WXUNUSED(externalLeading), - wxFont *WXUNUSED(theFont), bool WXUNUSED(use16) ) + long *descent, long *externalLeading, + wxFont *theFont, bool WXUNUSED(use16) ) { if (!Ok()) return; - GdkFont *font = m_font.GetInternalFont( m_scaleY ); + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; + + GdkFont *font = fontToUse.GetInternalFont( m_scaleY ); if (width) (*width) = long(gdk_string_width( font, string ) / m_scaleX); if (height) (*height) = long((font->ascent + font->descent) / m_scaleY); + if (descent) (*descent) = long(font->descent / m_scaleY); + if (externalLeading) (*externalLeading) = 0; // ?? } long wxPaintDC::GetCharWidth(void) @@ -575,7 +578,7 @@ long wxPaintDC::GetCharWidth(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return gdk_string_width( font, "H" ); + return long(gdk_string_width( font, "H" ) / m_scaleX); } long wxPaintDC::GetCharHeight(void) @@ -583,7 +586,7 @@ long wxPaintDC::GetCharHeight(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return font->ascent + font->descent; + return long((font->ascent + font->descent) / m_scaleY); } void wxPaintDC::Clear(void) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 5e7a3a60b6..6ce4890d79 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -36,7 +36,7 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED win->Close(); return TRUE; -}; +} //----------------------------------------------------------------------------- // wxDialog @@ -56,7 +56,7 @@ wxDialog::wxDialog(void) m_title = ""; m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); -}; +} wxDialog::wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, @@ -66,7 +66,7 @@ wxDialog::wxDialog( wxWindow *parent, m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); -}; +} bool wxDialog::Create( wxWindow *parent, wxWindowID id, const wxString &title, @@ -101,30 +101,30 @@ bool wxDialog::Create( wxWindow *parent, PostCreation(); return TRUE; -}; +} wxDialog::~wxDialog(void) { wxTopLevelWindows.DeleteObject( this ); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); -}; +} 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 { return (wxString&)m_title; -}; +} void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) { if (Validate()) TransferDataFromWindow(); -}; +} void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { @@ -136,8 +136,8 @@ void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { SetReturnCode(wxID_CANCEL); this->Show(FALSE); - }; -}; + } +} void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { @@ -151,14 +151,14 @@ void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) { SetReturnCode(wxID_OK); this->Show(FALSE); - }; - }; -}; + } + } +} void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) { // yes -}; +} bool wxDialog::OnClose(void) { @@ -189,8 +189,8 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) if (GetEventHandler()->OnClose() || event.GetForce()) { this->Destroy(); - }; -}; + } +} void wxDialog::ImplementSetPosition(void) { @@ -210,14 +210,22 @@ bool wxDialog::Show( bool show ) if (!show && IsModal() && m_modalShowing) { EndModal( wxID_CANCEL ); - }; + } wxWindow::Show( show ); if (show) InitDialog(); return TRUE; -}; +} + +void wxDialog::SetModal(bool flag) +{ + if (flag) + m_windowStyle |= wxDIALOG_MODAL; + else + if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; +} int wxDialog::ShowModal(void) { @@ -232,7 +240,7 @@ int wxDialog::ShowModal(void) gtk_grab_remove( m_widget ); return GetReturnCode(); -}; +} void wxDialog::EndModal( int retCode ) { @@ -242,15 +250,34 @@ void wxDialog::EndModal( int retCode ) { wxFAIL_MSG( "wxDialog: called EndModal twice" ); return; - }; + } m_modalShowing = FALSE; gtk_main_quit(); -}; +} void wxDialog::InitDialog(void) { wxWindow::InitDialog(); -}; +} + +void wxDialog::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW) ) +{ + gdk_window_set_hints( m_widget->window, -1, -1, + minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); +} + +void wxDialog::SetIcon( const wxIcon &icon ) +{ + m_icon = icon; + if (!icon.Ok()) return; + + wxMask *mask = icon.GetMask(); + GdkBitmap *bm = NULL; + if (mask) bm = mask->GetBitmap(); + + gdk_window_set_icon( m_widget->window, NULL, icon.GetPixmap(), bm ); +} + diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index ad4f5e9654..a048a12227 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -255,7 +255,7 @@ static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, int style, int weight, bool underlined); -GdkFont *wxFont::GetInternalFont(float scale) +GdkFont *wxFont::GetInternalFont(float scale) const { if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 716e2ee662..d7475b3a8e 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -515,9 +515,8 @@ void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW) ) { - if (m_wxwindow) - gdk_window_set_hints( m_wxwindow->window, -1, -1, - minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); + gdk_window_set_hints( m_widget->window, -1, -1, + minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); } void wxFrame::SetIcon( const wxIcon &icon ) diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 35832b897f..6cd28ae420 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -254,7 +254,7 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool wxMenuItem *mitem = new wxMenuItem(); mitem->SetId(id); mitem->SetText(item); - mitem->SetHelpString(helpStr); + mitem->SetHelp(helpStr); mitem->SetCheckable(checkable); const char *text = mitem->GetText(); GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label(text) @@ -277,7 +277,7 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri mitem->SetText(text); GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText()); - mitem->SetHelpString(helpStr); + mitem->SetHelp(helpStr); mitem->SetMenuItem(menuItem); mitem->SetSubMenu(subMenu); @@ -344,10 +344,30 @@ bool wxMenu::IsChecked( int id ) const void wxMenu::SetLabel( int id, const wxString &label ) { wxMenuItem *item = FindItem(id); - if ( item ) + if (item) item->SetText(label); } +wxString wxMenu::GetLabel( int id ) const +{ + wxMenuItem *item = FindItem(id); + if (item) return item->GetText(); + return ""; +} + +void wxMenu::SetHelpString( int id, const wxString& helpString ) +{ + wxMenuItem *item = FindItem(id); + if (item) item->SetHelp( helpString ); +} + +wxString wxMenu::GetHelpString( int id ) const +{ + wxMenuItem *item = FindItem(id); + if (item) return item->GetHelp(); + return ""; +} + int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const { wxNode *node = m_items.First(); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 12a31edeaa..81628667f9 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1393,6 +1393,31 @@ void wxWindow::Enable( bool enable ) if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable ); } +int wxWindow::GetCharHeight(void) const +{ + GdkFont *font = m_font.GetInternalFont( 1.0 ); + return font->ascent + font->descent; +} + +int wxWindow::GetCharWidth(void) const +{ + GdkFont *font = m_font.GetInternalFont( 1.0 ); + return gdk_string_width( font, "H" ); +} + +void wxWindow::GetTextExtent( const wxString& string, int *x, int *y, + int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const +{ + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; + + GdkFont *font = fontToUse.GetInternalFont( 1.0 ); + if (x) (*y) = gdk_string_width( font, string ); + if (y) (*y) = font->ascent + font->descent; + if (descent) (*descent) = font->descent; + if (externalLeading) (*externalLeading) = 0; // ?? +} + void wxWindow::MakeModal( bool modal ) { return; @@ -1516,11 +1541,6 @@ int wxWindow::GetReturnCode(void) return m_retCode; } -wxWindow *wxWindow::GetParent(void) -{ - return m_parent; -} - void wxWindow::Raise(void) { if (m_widget) gdk_window_raise( m_widget->window ); -- 2.45.2