From: Robert Roebling Date: Wed, 12 Aug 1998 21:24:51 +0000 (+0000) Subject: Added PushEventHandler, Pop... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/86b29a6122ae09d47995bc8f8919cb96a6ca18c7 Added PushEventHandler, Pop... Corrected spelling of SetEventhandler Fixed two bugs in wxGenericPrintDlg Tried in vain to make printing of icons work. It now prints black on black, mostly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/dc.h b/include/wx/gtk/dc.h index 9678e6d693..35b9424414 100644 --- a/include/wx/gtk/dc.h +++ b/include/wx/gtk/dc.h @@ -94,7 +94,9 @@ class wxDC: public wxObject virtual void DrawSpline( int n, wxPoint points[] ); virtual bool CanDrawBitmap(void) const = 0; - virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask=FALSE ); + virtual void DrawIcon( const wxIcon &icon, long x, long y ) + { DrawIcon( icon, x, y, TRUE ); } + virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask ); void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE ) { DrawIcon( *((wxIcon*)(&bmp)), x, y, useMask ); } virtual bool Blit( long xdest, long ydest, long width, long height, diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 8d36786733..0f1d410cf7 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -102,7 +102,9 @@ public: wxWindow *GetParent(); wxEvtHandler *GetEventHandler(); - void SetEventhandler( wxEvtHandler *handler ); + void SetEventHandler( wxEvtHandler *handler ); + void PushEventHandler( wxEvtHandler *handler ); + wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); virtual wxValidator *GetValidator(); virtual void SetValidator( wxValidator *validator ); diff --git a/include/wx/gtk1/dc.h b/include/wx/gtk1/dc.h index 9678e6d693..35b9424414 100644 --- a/include/wx/gtk1/dc.h +++ b/include/wx/gtk1/dc.h @@ -94,7 +94,9 @@ class wxDC: public wxObject virtual void DrawSpline( int n, wxPoint points[] ); virtual bool CanDrawBitmap(void) const = 0; - virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask=FALSE ); + virtual void DrawIcon( const wxIcon &icon, long x, long y ) + { DrawIcon( icon, x, y, TRUE ); } + virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask ); void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE ) { DrawIcon( *((wxIcon*)(&bmp)), x, y, useMask ); } virtual bool Blit( long xdest, long ydest, long width, long height, diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 8d36786733..0f1d410cf7 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -102,7 +102,9 @@ public: wxWindow *GetParent(); wxEvtHandler *GetEventHandler(); - void SetEventhandler( wxEvtHandler *handler ); + void SetEventHandler( wxEvtHandler *handler ); + void PushEventHandler( wxEvtHandler *handler ); + wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); virtual wxValidator *GetValidator(); virtual void SetValidator( wxValidator *validator ); diff --git a/include/wx/postscrp.h b/include/wx/postscrp.h index fb6cc90850..f9536aa0e8 100644 --- a/include/wx/postscrp.h +++ b/include/wx/postscrp.h @@ -76,6 +76,10 @@ class WXDLLEXPORT wxPostScriptDC: public wxDC void DrawOpenSpline(wxList *points); void DrawIcon(const wxIcon& icon, long x, long y); +#ifdef __WXGTK__ + void DrawIcon(const wxIcon& icon, long x, long y, bool WXUNUSED(usemask) ) + { DrawIcon( icon, x, y ); } +#endif void DrawText(const wxString& text, long x, long y, bool use16 = FALSE); void Clear(void); diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index bd0a78877b..2017286a37 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -56,6 +56,11 @@ float zoom_factor = 1.0; #include "aiai.xbm" #endif +#ifdef __WXGTK__ +#include "folder.xpm" +#endif + + // Writes a header on a page. Margin units are in millimetres. bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogical); @@ -319,6 +324,9 @@ void MyFrame::Draw(wxDC& dc) dc.SetPen(wxBLACK_PEN); dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); + + wxIcon my_icon( folder_xpm ); + dc.DrawIcon( my_icon, 100, 100, TRUE ); } void MyFrame::OnSize(wxSizeEvent& event ) diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index 033d18ba8d..47c415dbf0 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -93,7 +93,9 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data): wxString choices[2]; choices[0] = _("All"); choices[1] = _("Pages"); - + + fromText = (wxTextCtrl*)NULL; + rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"), wxPoint(5, yPos), wxSize(-1, -1), 2, choices, 2); rangeRadioBox->SetSelection(1); @@ -186,12 +188,14 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event)) void wxGenericPrintDialog::OnRange(wxCommandEvent& event) { - if (event.GetInt() == 0) + if (!fromText) return; + + if (event.GetInt() == 1) { fromText->Enable(FALSE); toText->Enable(FALSE); } - else if (event.GetInt() == 1) + else if (event.GetInt() == 0) { fromText->Enable(TRUE); toText->Enable(TRUE); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a59b3b29f9..9839c6b049 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1544,11 +1544,37 @@ wxEvtHandler *wxWindow::GetEventHandler(void) return m_eventHandler; } -void wxWindow::SetEventhandler( wxEvtHandler *handler ) +void wxWindow::SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; } +void wxWindow::PushEventHandler(wxEvtHandler *handler) +{ + handler->SetNextHandler(GetEventHandler()); + SetEventHandler(handler); +} + +wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) +{ + if ( GetEventHandler() ) + { + wxEvtHandler *handlerA = GetEventHandler(); + wxEvtHandler *handlerB = handlerA->GetNextHandler(); + handlerA->SetNextHandler(NULL); + SetEventHandler(handlerB); + if ( deleteHandler ) + { + delete handlerA; + return NULL; + } + else + return handlerA; + } + else + return NULL; +} + wxValidator *wxWindow::GetValidator(void) { return m_windowValidator; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index a59b3b29f9..9839c6b049 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1544,11 +1544,37 @@ wxEvtHandler *wxWindow::GetEventHandler(void) return m_eventHandler; } -void wxWindow::SetEventhandler( wxEvtHandler *handler ) +void wxWindow::SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; } +void wxWindow::PushEventHandler(wxEvtHandler *handler) +{ + handler->SetNextHandler(GetEventHandler()); + SetEventHandler(handler); +} + +wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) +{ + if ( GetEventHandler() ) + { + wxEvtHandler *handlerA = GetEventHandler(); + wxEvtHandler *handlerB = handlerA->GetNextHandler(); + handlerA->SetNextHandler(NULL); + SetEventHandler(handlerB); + if ( deleteHandler ) + { + delete handlerA; + return NULL; + } + else + return handlerA; + } + else + return NULL; +} + wxValidator *wxWindow::GetValidator(void) { return m_windowValidator;