From: Vadim Zeitlin Date: Tue, 19 Jan 1999 19:36:07 +0000 (+0000) Subject: 1. wxMotif fixes for compilation in "no compatible" mode X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1ccbb61aba5a0bbd93ba036ba8e1194e349064f6 1. wxMotif fixes for compilation in "no compatible" mode 2. Common fixes to be able to link minimal sample without stream classes, tree ctrl, list ctrl &c git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1431 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index 152e8132d6..91b6567d8e 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -114,12 +114,14 @@ public: const wxString& name); // Create toolbar +#if wxUSE_TOOLBAR virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name); // If made known to the frame, the frame will manage it automatically. virtual void SetToolBar(wxToolBar *toolbar) ; virtual wxToolBar *GetToolBar() const ; virtual void PositionToolBar(); +#endif // wxUSE_TOOLBAR // Set status line text virtual void SetStatusText(const wxString& text, int number = 0); @@ -188,7 +190,10 @@ protected: wxIcon m_icon; bool m_iconized; static bool m_useNativeStatusBar; + +#if wxUSE_TOOLBAR wxToolBar * m_frameToolBar ; +#endif // wxUSE_TOOLBAR //// Motif-specific diff --git a/src/common/image.cpp b/src/common/image.cpp index 853182a888..4dea748e12 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -100,10 +100,12 @@ wxImage::wxImage( const wxString& name, long type ) LoadFile( name, type ); } +#if wxUSE_STREAM wxImage::wxImage( wxInputStream& stream, long type ) { LoadFile( stream, type ); } +#endif // wxUSE_STREAM wxImage::wxImage( const wxImage& image ) { @@ -310,6 +312,7 @@ int wxImage::GetHeight() const bool wxImage::LoadFile( const wxString& filename, long type ) { +#if wxUSE_STREAM if (wxFileExists(filename)) { wxFileInputStream stream(filename); @@ -317,12 +320,28 @@ bool wxImage::LoadFile( const wxString& filename, long type ) } else { - wxLogWarning( "Image file does not exist." ); + wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() ); return FALSE; } +#else // !wxUSE_STREAM + return FALSE; +#endif // wxUSE_STREAM +} + +bool wxImage::SaveFile( const wxString& filename, int type ) +{ +#if wxUSE_STREAM + wxFileOutputStream stream(filename); + + if ( stream.LastError() == wxStream_NOERROR ) + return SaveFile(stream, type); + else +#endif // wxUSE_STREAM + return FALSE; } +#if wxUSE_STREAM bool wxImage::LoadFile( wxInputStream& stream, long type ) { UnRef(); @@ -341,16 +360,6 @@ bool wxImage::LoadFile( wxInputStream& stream, long type ) return handler->LoadFile( this, stream ); } -bool wxImage::SaveFile( const wxString& filename, int type ) -{ - wxFileOutputStream stream(filename); - - if ( stream.LastError() == wxStream_NOERROR ) - return SaveFile(stream, type); - else - return FALSE; -} - bool wxImage::SaveFile( wxOutputStream& stream, int type ) { wxCHECK_MSG( Ok(), FALSE, "invalid image" ); @@ -366,6 +375,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) return handler->SaveFile( this, stream ); } +#endif // wxUSE_STREAM void wxImage::AddHandler( wxImageHandler *handler ) { @@ -463,6 +473,7 @@ void wxImage::CleanUpHandlers() IMPLEMENT_DYNAMIC_CLASS(wxImageHandler,wxObject) #endif +#if wxUSE_STREAM bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream) ) { return FALSE; @@ -472,6 +483,7 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE { return FALSE; } +#endif // wxUSE_STREAM //----------------------------------------------------------------------------- // wxPNGHandler @@ -484,6 +496,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #endif +#if wxUSE_STREAM static void _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) { ((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length); @@ -736,6 +749,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) } return TRUE; } +#endif // wxUSE_STREAM #endif @@ -749,6 +763,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler) #endif +#if wxUSE_STREAM bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) { unsigned char *data, *ptr; @@ -1098,6 +1113,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) return TRUE; } +#endif // wxUSE_STREAM #ifdef __WXMSW__ diff --git a/src/common/log.cpp b/src/common/log.cpp index e83c4bc1e1..679df1715e 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -693,7 +693,14 @@ void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event)) // ------------------------- int nLines = m_pTextCtrl->GetNumberOfLines(); for ( int nLine = 0; bOk && nLine < nLines; nLine++ ) { - bOk = file.Write(m_pTextCtrl->GetLineText(nLine) + wxTextFile::GetEOL()); + bOk = file.Write(m_pTextCtrl->GetLineText(nLine) + +// we're not going to pull in the whole wxTextFile if all we need is this... +#if wxUSE_TEXTFILE + wxTextFile::GetEOL() +#else // !wxUSE_TEXTFILE + '\n' +#endif // wxUSE_TEXTFILE + ); } if ( bOk ) diff --git a/src/common/object.cpp b/src/common/object.cpp index 0eda4f7880..4ac78acc23 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -22,7 +22,7 @@ #ifndef WX_PRECOMP #include "wx/hash.h" - #ifdef wxUSE_SERIAL + #if wxUSE_SERIAL #include "wx/objstrm.h" #include "wx/serbase.h" @@ -64,7 +64,7 @@ wxHashTable* wxClassInfo::sm_classTable = (wxHashTable*) NULL; wxObject::wxObject(void) { m_refData = (wxObjectRefData *) NULL; -#ifdef wxUSE_SERIAL +#if wxUSE_SERIAL m_serialObj = (wxObject_Serialize *)NULL; #endif } @@ -72,7 +72,7 @@ wxObject::wxObject(void) wxObject::~wxObject(void) { UnRef(); -#ifdef wxUSE_SERIAL +#if wxUSE_SERIAL if (m_serialObj) delete m_serialObj; #endif @@ -269,7 +269,7 @@ wxObject *wxCreateDynamicObject(const char *name) return (wxObject*) NULL; } -#ifdef wxUSE_SERIAL +#if wxUSE_SERIAL #include "wx/serbase.h" #include "wx/dynlib.h" diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 341329fc28..86da34aa78 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -293,12 +293,17 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; - virtual bool Write(ostream& str) const; + + virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; - virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); + virtual bool Write(ostream& str) const; + +#if wxUSE_STREAM virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream &str) const; +#endif // wxUSE_STREAM + virtual wxString GetType() const { return "long"; }; protected: @@ -333,12 +338,6 @@ bool wxVariantDataLong::Write(ostream& str) const return TRUE; } -bool wxVariantDataLong::Write(wxOutputStream& str) const -{ - str << m_value; - return TRUE; -} - bool wxVariantDataLong::Write(wxString& str) const { str.Printf("%ld", m_value); @@ -351,11 +350,19 @@ bool wxVariantDataLong::Read(istream& str) return TRUE; } +#if wxUSE_STREAM +bool wxVariantDataLong::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataLong::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAM bool wxVariantDataLong::Read(wxString& str) { @@ -379,12 +386,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; + virtual bool Read(wxString& str); virtual bool Write(ostream& str) const; virtual bool Write(wxString& str) const; - virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); +#if wxUSE_STREAM virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream &str) const; +#endif // wxUSE_STREAM virtual wxString GetType() const { return "double"; }; protected: @@ -419,12 +428,6 @@ bool wxVariantDataReal::Write(ostream& str) const return TRUE; } -bool wxVariantDataReal::Write(wxOutputStream& str) const -{ - str << m_value; - return TRUE; -} - bool wxVariantDataReal::Write(wxString& str) const { str.Printf("%.4f", m_value); @@ -437,11 +440,19 @@ bool wxVariantDataReal::Read(istream& str) return TRUE; } +#if wxUSE_STREAM +bool wxVariantDataReal::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataReal::Read(wxInputStream& str) { str >> (float&)m_value; return TRUE; } +#endif // wxUSE_STREAM bool wxVariantDataReal::Read(wxString& str) { @@ -466,11 +477,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; - virtual bool Write(wxOutputStream& str) const; virtual bool Write(wxString& str) const; + virtual bool Read(wxString& str); virtual bool Read(istream& str); +#if wxUSE_STREAM virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAM virtual wxString GetType() const { return "bool"; }; protected: @@ -505,12 +518,6 @@ bool wxVariantDataBool::Write(ostream& str) const return TRUE; } -bool wxVariantDataBool::Write(wxOutputStream& str) const -{ - str << (char)m_value; - return TRUE; -} - bool wxVariantDataBool::Write(wxString& str) const { str.Printf("%d", (int) m_value); @@ -524,11 +531,19 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str)) return FALSE; } +#if wxUSE_STREAM +bool wxVariantDataBool::Write(wxOutputStream& str) const +{ + str << (char)m_value; + return TRUE; +} + bool wxVariantDataBool::Read(wxInputStream& str) { str >> (char&)m_value; return TRUE; } +#endif // wxUSE_STREAM bool wxVariantDataBool::Read(wxString& str) { @@ -552,12 +567,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; + virtual bool Read(istream& str); virtual bool Write(ostream& str) const; - virtual bool Write(wxOutputStream& str) const; + virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; - virtual bool Read(istream& str); +#if wxUSE_STREAM virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAM virtual wxString GetType() const { return "char"; }; protected: @@ -592,12 +609,6 @@ bool wxVariantDataChar::Write(ostream& str) const return TRUE; } -bool wxVariantDataChar::Write(wxOutputStream& str) const -{ - str << m_value; - return TRUE; -} - bool wxVariantDataChar::Write(wxString& str) const { str.Printf("%c", m_value); @@ -611,11 +622,19 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str)) return FALSE; } +#if wxUSE_STREAM +bool wxVariantDataChar::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataChar::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAM bool wxVariantDataChar::Read(wxString& str) { @@ -649,11 +668,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; - virtual bool Write(wxOutputStream& str) const; + virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; virtual bool Read(istream& str); +#if wxUSE_STREAM virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAM virtual wxString GetType() const { return "string"; }; protected: @@ -684,12 +705,6 @@ bool wxVariantDataString::Write(ostream& str) const return TRUE; } -bool wxVariantDataString::Write(wxOutputStream& str) const -{ - str << (const char*) m_value; - return TRUE; -} - bool wxVariantDataString::Write(wxString& str) const { str = m_value; @@ -702,11 +717,19 @@ bool wxVariantDataString::Read(istream& str) return TRUE; } +#if wxUSE_STREAM +bool wxVariantDataString::Write(wxOutputStream& str) const +{ + str << (const char*) m_value; + return TRUE; +} + bool wxVariantDataString::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAM bool wxVariantDataString::Read(wxString& str) { diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index 6f126aae72..4ea8a6716e 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -84,7 +84,10 @@ bool wxFrame::m_useNativeStatusBar = FALSE; wxFrame::wxFrame() { +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif // wxUSE_TOOLBAR + m_frameMenuBar = NULL; m_frameStatusBar = NULL; @@ -115,7 +118,9 @@ bool wxFrame::Create(wxWindow *parent, m_windowStyle = style; m_frameMenuBar = NULL; +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif // wxUSE_TOOLBAR m_frameStatusBar = NULL; //// Motif-specific @@ -363,6 +368,7 @@ void wxFrame::GetClientSize(int *x, int *y) const m_frameStatusBar->GetSize(& sbw, & sbh); yy -= sbh; } +#if wxUSE_TOOLBAR if (m_frameToolBar) { int tbw, tbh; @@ -372,6 +378,7 @@ void wxFrame::GetClientSize(int *x, int *y) const else yy -= tbh; } +#endif // wxUSE_TOOLBAR /* if (GetMenuBar() != (wxMenuBar*) NULL) { @@ -415,6 +422,7 @@ void wxFrame::SetClientSize(int width, int height) m_frameStatusBar->GetSize(& sbw, & sbh); height += sbh; } +#if wxUSE_TOOLBAR if (m_frameToolBar) { int tbw, tbh; @@ -424,6 +432,7 @@ void wxFrame::SetClientSize(int width, int height) else height += tbh; } +#endif // wxUSE_TOOLBAR XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL); } @@ -732,8 +741,11 @@ void wxFrame::OnSize(wxSizeEvent& event) wxWindow *win = (wxWindow *)node->Data(); if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) && - (win != GetStatusBar()) && - (win != GetToolBar()) ) + (win != GetStatusBar()) +#if wxUSE_TOOLBAR + && (win != GetToolBar()) +#endif // wxUSE_TOOLBAR + ) { if ( child ) return; // it's our second subwindow - nothing to do @@ -867,6 +879,7 @@ void wxFrame::ProcessCommand(int id) wxPoint wxFrame::GetClientAreaOrigin() const { wxPoint pt(0, 0); +#if wxUSE_TOOLBAR if (GetToolBar()) { int w, h; @@ -881,6 +894,8 @@ wxPoint wxFrame::GetClientAreaOrigin() const pt.y += h; } } +#endif // wxUSE_TOOLBAR + return pt; } @@ -908,6 +923,7 @@ void wxFrame::ClientToScreen(int *x, int *y) const wxWindow::ClientToScreen(x, y); } +#if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxCHECK_MSG( m_frameToolBar == NULL, FALSE, @@ -931,6 +947,16 @@ wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& n return new wxToolBar(this, id, wxPoint(0, 0), wxSize(100, 24), style, name); } +void wxFrame::SetToolBar(wxToolBar *toolbar) +{ + m_frameToolBar = toolbar; +} + +wxToolBar *wxFrame::GetToolBar() const +{ + return m_frameToolBar; +} + void wxFrame::PositionToolBar() { int cw, ch; @@ -956,6 +982,7 @@ void wxFrame::PositionToolBar() } } } +#endif // wxUSE_TOOLBAR void wxFrame::CaptureMouse() { @@ -1011,12 +1038,6 @@ void wxFrame::Lower(void) XLowerWindow(XtDisplay((Widget) m_frameShell), parent_window); } -void wxFrame::SetToolBar(wxToolBar *toolbar) -{ m_frameToolBar = toolbar; } - -wxToolBar *wxFrame::GetToolBar() const -{ return m_frameToolBar; } - void wxFrameFocusProc(Widget workArea, XtPointer clientData, XmAnyCallbackStruct *cbs) { @@ -1055,7 +1076,9 @@ static void wxFrameMapProc(Widget frameShell, XtPointer clientData, //// Motif-specific bool wxFrame::PreResize() { +#if wxUSE_TOOLBAR PositionToolBar(); +#endif // wxUSE_TOOLBAR PositionStatusBar(); return TRUE; } diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index ee33bfeea4..8b3a4d47a1 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -16,7 +16,7 @@ #include "wx/wx.h" #include "wx/app.h" #include "wx/timer.h" -#include "wx/motif/toolbar.h" +#include "wx/toolbar.h" #include #include @@ -605,7 +605,8 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit else tool->m_y = m_yMargin; - tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight()); + wxSize& size = GetToolSize(); + tool->SetSize(size.x, size.y); m_tools.Append((long)index, tool); return tool;