From a8ff046ba980a89f11125477e736cf235ebd7186 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Jul 2007 02:05:03 +0000 Subject: [PATCH] fixes for building wxMSW with --disbale-all-features git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private/timer.h | 4 +++ include/wx/msw/region.h | 2 ++ include/wx/sysopt.h | 6 +++- src/common/appcmn.cpp | 4 ++- src/common/containr.cpp | 12 ++++---- src/common/event.cpp | 1 + src/msw/app.cpp | 4 +++ src/msw/basemsw.cpp | 8 +++++ src/msw/dc.cpp | 20 +++++++++++++ src/msw/dib.cpp | 4 +++ src/msw/dir.cpp | 2 +- src/msw/frame.cpp | 55 +++++++++++++++++++--------------- src/msw/imaglist.cpp | 2 +- src/msw/msgdlg.cpp | 4 +++ src/msw/toplevel.cpp | 11 +++++-- src/msw/utils.cpp | 6 ++-- 16 files changed, 107 insertions(+), 38 deletions(-) diff --git a/include/wx/msw/private/timer.h b/include/wx/msw/private/timer.h index 07139ee528..f7044e0754 100644 --- a/include/wx/msw/private/timer.h +++ b/include/wx/msw/private/timer.h @@ -11,6 +11,8 @@ #ifndef _WX_MSW_PRIVATE_TIMER_H_ #define _WX_MSW_PRIVATE_TIMER_H_ +#if wxUSE_TIMER + #include "wx/private/timer.h" class WXDLLIMPEXP_BASE wxMSWTimerImpl : public wxTimerImpl @@ -27,4 +29,6 @@ protected: unsigned long m_id; }; +#endif // wxUSE_TIMER + #endif // _WX_TIMERH_ diff --git a/include/wx/msw/region.h b/include/wx/msw/region.h index e9463fdd13..97203acb3f 100644 --- a/include/wx/msw/region.h +++ b/include/wx/msw/region.h @@ -21,6 +21,7 @@ public: wxRegion(const wxRect& rect); wxRegion(WXHRGN hRegion); // Hangs on to this region wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); +#if wxUSE_IMAGE wxRegion( const wxBitmap& bmp) { Union(bmp); @@ -30,6 +31,7 @@ public: { Union(bmp, transColour, tolerance); } +#endif // wxUSE_IMAGE virtual ~wxRegion(); diff --git a/include/wx/sysopt.h b/include/wx/sysopt.h index 0b8a771666..f0eee94229 100644 --- a/include/wx/sysopt.h +++ b/include/wx/sysopt.h @@ -18,7 +18,11 @@ // Enables an application to influence the wxWidgets implementation // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxSystemOptions : public wxObject +class +#if wxUSE_SYSTEM_OPTIONS +WXDLLIMPEXP_BASE +#endif +wxSystemOptions : public wxObject { public: wxSystemOptions() { } diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 8a33c3f31f..cf61da7e89 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -456,8 +456,10 @@ wxMessageOutput *wxGUIAppTraitsBase::CreateMessageOutput() // wxMessageOutputMessageBox doesn't work under Motif #ifdef __WXMOTIF__ return new wxMessageOutputLog; - #else + #elif wxUSE_MSGDLG return new wxMessageOutputMessageBox; + #else + return new wxMessageOutputStderr; #endif #endif // __UNIX__/!__UNIX__ } diff --git a/src/common/containr.cpp b/src/common/containr.cpp index f2d237a36d..c62e2ebd42 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -149,7 +149,7 @@ void wxControlContainer::SetLastFocus(wxWindow *win) // within the same group. Used by wxSetFocusToChild on wxMSW // -------------------------------------------------------------------- -#ifdef __WXMSW__ +#if defined(__WXMSW__) && wxUSE_RADIOBTN wxRadioButton* wxGetPreviousButtonInGroup(wxRadioButton *btn) { @@ -372,12 +372,12 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) if ( winFocus ) { -#ifdef __WXMSW__ +#if defined(__WXMSW__) && wxUSE_RADIOBTN // If we are in a radio button group, start from the first item in the // group if ( event.IsFromTab() && wxIsKindOf(winFocus, wxRadioButton ) ) winFocus = wxGetFirstButtonInGroup((wxRadioButton*)winFocus); -#endif +#endif // __WXMSW__ // ok, we found the focus - now is it our child? start_node = children.Find( winFocus ); } @@ -451,7 +451,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxWindow *child = node->GetData(); -#ifdef __WXMSW__ +#if defined(__WXMSW__) && wxUSE_RADIOBTN if ( event.IsFromTab() ) { if ( wxIsKindOf(child, wxRadioButton) ) @@ -654,7 +654,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() ) { -#ifdef __WXMSW__ +#if defined(__WXMSW__) && wxUSE_RADIOBTN // If a radiobutton is the first focusable child, search for the // selected radiobutton in the same group wxRadioButton* btn = wxDynamicCast(child, wxRadioButton); @@ -664,7 +664,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) if (selected) child = selected; } -#endif +#endif // __WXMSW__ wxLogTrace(TRACE_FOCUS, _T("SetFocusToChild() => first child (0x%p)."), diff --git a/src/common/event.cpp b/src/common/event.cpp index d0c22a72d1..3ac1284d86 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -34,6 +34,7 @@ #include "wx/module.h" #if wxUSE_GUI + #include "wx/window.h" #include "wx/control.h" #include "wx/dc.h" #include "wx/textctrl.h" diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 703871214c..682a3b3b29 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -266,11 +266,15 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const #endif } +#if wxUSE_TIMER + wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) { return new wxMSWTimerImpl(timer); } +#endif // wxUSE_TIMER + wxEventLoopBase* wxGUIAppTraits::CreateEventLoop() { return new wxEventLoop; diff --git a/src/msw/basemsw.cpp b/src/msw/basemsw.cpp index 754dbc7ea3..5becc21693 100644 --- a/src/msw/basemsw.cpp +++ b/src/msw/basemsw.cpp @@ -82,16 +82,24 @@ bool wxConsoleAppTraits::DoMessageFromThreadWait() return true; } +#if wxUSE_TIMER + wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer) { return new wxMSWTimerImpl(timer); } +#endif // wxUSE_TIMER + +#if wxUSE_CONSOLE_EVENTLOOP + wxEventLoopBase *wxConsoleAppTraits::CreateEventLoop() { return new wxEventLoop(); } +#endif // wxUSE_CONSOLE_EVENTLOOP + WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread) { return DoSimpleWaitForThread(hThread); diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 6e0ea3100b..d1ef3afda2 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -205,6 +205,8 @@ private: DECLARE_NO_COPY_CLASS(StretchBltModeChanger) }; +#if wxUSE_DYNLIB_CLASS + // helper class to cache dynamically loaded libraries and not attempt reloading // them if it fails class wxOnceOnlyDLLLoader @@ -244,6 +246,8 @@ private: static wxOnceOnlyDLLLoader wxGDI32DLL(_T("gdi32")); static wxOnceOnlyDLLLoader wxMSIMG32DLL(_T("msimg32")); +#endif // wxUSE_DYNLIB_CLASS + // =========================================================================== // implementation // =========================================================================== @@ -2673,6 +2677,8 @@ void wxDC::DoGradientFillLinear (const wxRect& rect, wxDCBase::DoGradientFillLinear(rect, initialColour, destColour, nDirection); } +#if wxUSE_DYNLIB_CLASS + static DWORD wxGetDCLayout(HDC hdc) { typedef DWORD (WINAPI *GetLayout_t)(HDC); @@ -2715,3 +2721,17 @@ void wxDC::SetLayoutDirection(wxLayoutDirection dir) pfnSetLayout(GetHdc(), layout); } + +#else // !wxUSE_DYNLIB_CLASS + +// we can't provide RTL support without dynamic loading, so stub it out +wxLayoutDirection wxDC::GetLayoutDirection() const +{ + return wxLayout_Default; +} + +void wxDC::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) +{ +} + +#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 2abcde95b7..f79d16a113 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -307,6 +307,7 @@ bool wxDIB::Save(const wxString& filename) { wxCHECK_MSG( m_handle, false, _T("wxDIB::Save(): invalid object") ); +#if wxUSE_FILE wxFile file(filename, wxFile::write); bool ok = file.IsOpened(); if ( ok ) @@ -335,6 +336,9 @@ bool wxDIB::Save(const wxString& filename) file.Write(ds.dsBm.bmBits, sizeImage) == sizeImage; } } +#else // !wxUSE_FILE + bool ok = false; +#endif // wxUSE_FILE/!wxUSE_FILE if ( !ok ) { diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index 5525d72a61..ae9d7ddb9b 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -201,7 +201,7 @@ bool wxDirData::Read(wxString *filename) if ( err != ERROR_FILE_NOT_FOUND && err != ERROR_NO_MORE_FILES ) { - wxLogSysError(err, _("Can not enumerate files in directory '%s'"), + wxLogSysError(err, wxString(_("Can not enumerate files in directory '%s'")), m_dirname.c_str()); } #endif // __WIN32__ diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 8f0ce449bc..2701eb8ad2 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -563,6 +563,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) } #endif // wxUSE_TOOLBAR +#if wxUSE_MENUS if (m_fsStyle & wxFULLSCREEN_NOMENUBAR) { WXHMENU menu = m_hMenu; @@ -584,6 +585,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) ::SetMenu(GetHwnd(), (HMENU)menu); } } +#endif // wxUSE_MENUS #if wxUSE_STATUSBAR wxStatusBar *theStatusBar = GetStatusBar(); @@ -984,6 +986,8 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) return false; } +#if wxUSE_MENUS + bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) { int item; @@ -1025,6 +1029,30 @@ bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup) return GetEventHandler()->ProcessEvent(event); } +bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) +{ + wxMenu* menu = NULL; + if (GetMenuBar()) + { + int nCount = GetMenuBar()->GetMenuCount(); + for (int n = 0; n < nCount; n++) + { + if (GetMenuBar()->GetMenu(n)->GetHMenu() == hMenu) + { + menu = GetMenuBar()->GetMenu(n); + break; + } + } + } + + wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu); + event.SetEventObject(this); + + return GetEventHandler()->ProcessEvent(event); +} + +#endif // wxUSE_MENUS + // --------------------------------------------------------------------------- // the window proc for wxFrame // --------------------------------------------------------------------------- @@ -1061,11 +1089,12 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara processed = HandlePaint(); break; +#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) +#if wxUSE_MENUS case WM_INITMENUPOPUP: processed = HandleInitMenuPopup((WXHMENU) wParam); break; -#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) case WM_MENUSELECT: { WXWORD item, flags; @@ -1079,6 +1108,7 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara case WM_EXITMENULOOP: processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); break; +#endif // wxUSE_MENUS case WM_QUERYDRAGICON: { @@ -1098,29 +1128,6 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara return rc; } -// handle WM_INITMENUPOPUP message -bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) -{ - wxMenu* menu = NULL; - if (GetMenuBar()) - { - int nCount = GetMenuBar()->GetMenuCount(); - for (int n = 0; n < nCount; n++) - { - if (GetMenuBar()->GetMenu(n)->GetHMenu() == hMenu) - { - menu = GetMenuBar()->GetMenu(n); - break; - } - } - } - - wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu); - event.SetEventObject(this); - - return GetEventHandler()->ProcessEvent(event); -} - // ---------------------------------------------------------------------------- // wxFrame size management: we exclude the areas taken by menu/status/toolbars // from the client area, so the client area is what's really available for the diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 317bc0f788..7548695b8c 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -278,7 +278,7 @@ bool wxImageList::Draw(int index, // Get the bitmap wxBitmap wxImageList::GetBitmap(int index) const { -#if wxUSE_WXDIB +#if wxUSE_WXDIB && wxUSE_IMAGE int bmp_width = 0, bmp_height = 0; GetSize(index, bmp_width, bmp_height); diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 76eda81fc9..061b9211a2 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -16,6 +16,8 @@ #pragma hdrstop #endif +#if wxUSE_MSGDLG + #include "wx/msgdlg.h" #ifndef WX_PRECOMP @@ -132,3 +134,5 @@ int wxMessageDialog::ShowModal() } return ans; } + +#endif // wxUSE_MSGDLG diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 272d3c15bf..359c874cb8 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -1087,7 +1087,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) // provide FlashWindowEx() declaration, so try to detect whether we have // real headers for WINVER 0x0500 by checking for existence of a symbol not // declated in MSVC6 header -#if defined(FLASHW_STOP) && defined(VK_XBUTTON1) +#if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS // available in the headers, check if it is supported by the system typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi); FlashWindowEx_t s_pfnFlashWindowEx = NULL; @@ -1133,6 +1133,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) { +#if wxUSE_DYNLIB_CLASS typedef DWORD (WINAPI *PSETLAYEREDWINDOWATTR)(HWND, DWORD, BYTE, DWORD); static PSETLAYEREDWINDOWATTR pSetLayeredWindowAttributes = NULL; @@ -1144,6 +1145,7 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) } if ( pSetLayeredWindowAttributes == NULL ) return false; +#endif // wxUSE_DYNLIB_CLASS LONG exstyle = GetWindowLong(GetHwnd(), GWL_EXSTYLE); @@ -1155,11 +1157,16 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) return true; } +#if wxUSE_DYNLIB_CLASS // Otherwise, set the layered style if needed and set the alpha value if ((exstyle & WS_EX_LAYERED) == 0 ) SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle | WS_EX_LAYERED); - return pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) != 0; + if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) ) + return true; +#endif // wxUSE_DYNLIB_CLASS + + return false; } bool wxTopLevelWindowMSW::CanSetTransparent() diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index c0efa166b7..243c3320f5 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -158,7 +158,7 @@ bool wxGetHostName(wxChar *WXUNUSED_IN_WINCE(buf), // get full hostname (with domain name if possible) bool wxGetFullHostName(wxChar *buf, int maxSize) { -#if !defined( __WXMICROWIN__) && wxUSE_DYNAMIC_LOADER && wxUSE_SOCKETS +#if !defined( __WXMICROWIN__) && wxUSE_DYNLIB_CLASS && wxUSE_SOCKETS // TODO should use GetComputerNameEx() when available // we don't want to always link with Winsock DLL as we might not use it at @@ -1176,7 +1176,7 @@ bool wxIsPlatform64Bit() { #if defined(_WIN64) return true; // 64-bit programs run only on Win64 -#else // Win32 +#elif wxUSE_DYNLIB_CLASS // Win32 // 32-bit programs run on both 32-bit and 64-bit Windows so check typedef BOOL (WINAPI *IsWow64Process_t)(HANDLE, BOOL *); @@ -1192,6 +1192,8 @@ bool wxIsPlatform64Bit() //else: running under a system without Win64 support return wow64 != FALSE; +#else + return false; #endif // Win64/Win32 } -- 2.47.2