From 5ff14574fc48a85531252d675b1cf8cfadb65399 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 9 Sep 2006 17:29:19 +0000 Subject: [PATCH] some app.h cleanup: minimize includes, use static cast git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41099 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/app.h | 26 ++++++-------------------- include/wx/msw/stackwalk.h | 2 ++ src/aui/framemanager.cpp | 1 + src/common/appcmn.cpp | 19 +++++++++++++++++-- src/common/imagbmp.cpp | 7 ++++--- src/common/image.cpp | 5 ++--- src/common/wxchar.cpp | 6 ++++-- src/gtk/bitmap.cpp | 1 + src/gtk/cursor.cpp | 1 + 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/include/wx/app.h b/include/wx/app.h index da16865843..ef7a14120b 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -18,16 +18,9 @@ // ---------------------------------------------------------------------------- #include "wx/event.h" // for the base class - -#if wxUSE_GUI - #include "wx/window.h" // for wxTopLevelWindows - - #include "wx/vidmode.h" -#endif // wxUSE_GUI - #include "wx/build.h" #include "wx/init.h" // we must declare wxEntry() -#include "wx/intl.h" +#include "wx/intl.h" // for wxLayoutDirection class WXDLLIMPEXP_BASE wxAppConsole; class WXDLLIMPEXP_BASE wxAppTraits; @@ -37,6 +30,7 @@ class WXDLLIMPEXP_BASE wxMessageOutput; #if wxUSE_GUI class WXDLLEXPORT wxEventLoop; + struct WXDLLIMPEXP_CORE wxVideoMode; #endif // ---------------------------------------------------------------------------- @@ -447,15 +441,7 @@ public: // return the "main" top level window (if it hadn't been set previously // with SetTopWindow(), will return just some top level window and, if // there are none, will return NULL) - virtual wxWindow *GetTopWindow() const - { - if (m_topWindow) - return m_topWindow; - else if (wxTopLevelWindows.GetCount() > 0) - return wxTopLevelWindows.GetFirst()->GetData(); - else - return (wxWindow *)NULL; - } + virtual wxWindow *GetTopWindow() const; // control the exit behaviour: by default, the program will exit the // main loop (and so, usually, terminate) when the last top-level @@ -473,7 +459,7 @@ public: // Get display mode that is used use. This is only used in framebuffer // wxWin ports (such as wxMGL or wxDFB). - virtual wxVideoMode GetDisplayMode() const { return wxVideoMode(); } + virtual wxVideoMode GetDisplayMode() const; // Set display mode to use. This is only used in framebuffer wxWin // ports (such as wxMGL or wxDFB). This method should be called from // wxApp::OnInitGui @@ -607,7 +593,7 @@ protected: // // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in // console mode it does nothing at all -#define wxTheApp ((wxApp *)wxApp::GetInstance()) +#define wxTheApp wx_static_cast(wxApp*, wxApp::GetInstance()) // ---------------------------------------------------------------------------- // global functions @@ -674,7 +660,7 @@ public: wxAppInitializer \ wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ DECLARE_APP(appname) \ - appname& wxGetApp() { return *(appname *)wxTheApp; } + appname& wxGetApp() { return *wx_static_cast(appname*, wxApp::GetInstance()); } // Same as IMPLEMENT_APP() normally but doesn't include themes support in // wxUniversal builds diff --git a/include/wx/msw/stackwalk.h b/include/wx/msw/stackwalk.h index 9c794e7db8..b8ea90e7b9 100644 --- a/include/wx/msw/stackwalk.h +++ b/include/wx/msw/stackwalk.h @@ -12,6 +12,8 @@ #ifndef _WX_MSW_STACKWALK_H_ #define _WX_MSW_STACKWALK_H_ +#include "wx/arrstr.h" + // these structs are declared in windows headers struct _CONTEXT; struct _EXCEPTION_POINTERS; diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 495e462ad8..25e9ebbfc9 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -30,6 +30,7 @@ #include "wx/aui/floatpane.h" #ifndef WX_PRECOMP + #include "wx/panel.h" #include "wx/settings.h" #include "wx/app.h" #include "wx/dcclient.h" diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 4cc829b673..fb02e6b93d 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -25,10 +25,9 @@ #endif #ifndef WX_PRECOMP - #include "wx/list.h" #include "wx/app.h" + #include "wx/window.h" #include "wx/bitmap.h" - #include "wx/intl.h" #include "wx/log.h" #include "wx/msgdlg.h" #include "wx/confbase.h" @@ -40,6 +39,7 @@ #include "wx/evtloop.h" #include "wx/msgout.h" #include "wx/thread.h" +#include "wx/vidmode.h" #include "wx/ptr_scpd.h" #if defined(__WXMSW__) @@ -157,6 +157,21 @@ void wxAppBase::CleanUp() #endif // wxUSE_THREADS } +// ---------------------------------------------------------------------------- + +wxWindow* wxAppBase::GetTopWindow() const +{ + wxWindow* window = m_topWindow; + if (window == NULL && wxTopLevelWindows.GetCount() > 0) + window = wxTopLevelWindows.GetFirst()->GetData(); + return window; +} + +wxVideoMode wxAppBase::GetDisplayMode() const +{ + return wxVideoMode(); +} + #if wxUSE_CMDLINE_PARSER // ---------------------------------------------------------------------------- diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 0dced8f819..9cf6d614f9 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -16,6 +16,8 @@ #if wxUSE_IMAGE +#include "wx/imagbmp.h" + #ifndef WX_PRECOMP #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" @@ -23,13 +25,12 @@ #include "wx/log.h" #include "wx/app.h" #include "wx/bitmap.h" - #include "wx/module.h" + #include "wx/palette.h" + #include "wx/intl.h" #endif -#include "wx/imagbmp.h" #include "wx/filefn.h" #include "wx/wfstream.h" -#include "wx/intl.h" #include "wx/quantize.h" // For memcpy diff --git a/src/common/image.cpp b/src/common/image.cpp index 0f42524c20..545afb1301 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -20,17 +20,16 @@ #ifndef WX_PRECOMP #include "wx/log.h" - #include "wx/app.h" #include "wx/hash.h" #include "wx/utils.h" - #include "wx/bitmap.h" #include "wx/math.h" #include "wx/module.h" + #include "wx/palette.h" + #include "wx/intl.h" #endif #include "wx/filefn.h" #include "wx/wfstream.h" -#include "wx/intl.h" #if wxUSE_XPM #include "wx/xpmdecod.h" diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index eaab6699ac..9be21d4697 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -20,6 +20,8 @@ #pragma hdrstop #endif +#include "wx/wxchar.h" + #define _ISOC9X_SOURCE 1 // to get vsscanf() #define _BSD_SOURCE 1 // to still get strdup() @@ -35,11 +37,11 @@ #endif #ifndef WX_PRECOMP - #include "wx/wxchar.h" #include "wx/string.h" #include "wx/hash.h" + #include "wx/utils.h" // for wxMin and wxMax + #include "wx/log.h" #endif - #include "wx/utils.h" // for wxMin and wxMax #if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H) #include diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 27e64ff532..fcc84f7786 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -18,6 +18,7 @@ #include "wx/icon.h" #include "wx/math.h" #include "wx/image.h" + #include "wx/colour.h" #endif #include "wx/rawbmp.h" diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index f051a5332c..a175daaa6e 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -16,6 +16,7 @@ #include "wx/app.h" #include "wx/utils.h" #include "wx/image.h" + #include "wx/colour.h" #endif // WX_PRECOMP #include "wx/gtk/private.h" //for idle stuff -- 2.45.2