00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_LAYOUTMANAGER_H_
00013 #define _WX_LAYOUTMANAGER_H_
00014
00015
00016
00017
00018
00019 #include <wx/defs.h>
00020 #include <wx/object.h>
00021 #include <wx/gdicmn.h>
00022 #include <wx/event.h>
00023 #include <wx/wfstream.h>
00024 #include "wx/export.h"
00025
00026 class wxFrame;
00027 class wxDockHost;
00028 class wxDockPanel;
00029 class wxDockWindowBase;
00030 class wxConfigBase;
00031
00032 #define wxDEFAULT_LEFT_HOST wxT("LeftHost")
00033 #define wxDEFAULT_RIGHT_HOST wxT("RightHost")
00034 #define wxDEFAULT_TOP_HOST wxT("TopHost")
00035 #define wxDEFAULT_BOTTOM_HOST wxT("BottomHost")
00036
00037 #define wxINITIAL_HOST_SIZE 64
00038
00039
00040
00041
00042
00043 class WXDLLIMPEXP_DI wxOwnerEventHandler : public wxEvtHandler
00044 {
00045 DECLARE_CLASS( wxOwnerEventHandler )
00046 DECLARE_EVENT_TABLE()
00047 public:
00048 wxOwnerEventHandler() {
00049 pOwner_ = NULL;
00050 }
00051 void SetOwner( class wxLayoutManager * pOwner ) {
00052 pOwner_ = pOwner;
00053 }
00054
00055 void OnSize( wxSizeEvent &WXUNUSED(event) );
00056 void OnMove( wxMoveEvent &WXUNUSED(event) );
00057 void OnUpdateLayout( wxCommandEvent &WXUNUSED(event) );
00058 void OnMenu( wxCommandEvent &event );
00059
00060 private:
00061 class wxLayoutManager * pOwner_;
00062 };
00063
00064
00065
00066
00067
00068 enum wxPlacement {
00069 wxHIP_NONE,
00070 wxHIP_FRONT,
00071 wxHIP_BACK
00072 };
00073
00074 struct WXDLLIMPEXP_DI wxHostInfo {
00075
00076 wxHostInfo() {
00077 Reset();
00078 }
00079 wxDockHost * operator =(wxDockHost * pDockHost) {
00080 pHost = pDockHost;
00081 valid = true;
00082 return pDockHost;
00083 }
00084 void Reset() {
00085 valid = false;
00086 pHost = NULL;
00087 pPanel = NULL;
00088 placement = wxHIP_NONE;
00089 }
00090 bool valid;
00091 wxDockHost * pHost;
00092 wxDockPanel * pPanel;
00093 wxPlacement placement;
00094 };
00095
00096
00097
00098
00099
00100 WX_DECLARE_USER_EXPORTED_LIST( wxDockHost, DockHostList, WXDLLIMPEXP_DI );
00101 WX_DECLARE_USER_EXPORTED_LIST( wxDockWindowBase, DockWindowList, WXDLLIMPEXP_DI );
00102
00103 #define wxDWF_LIVE_UPDATE 0x01
00104 #define wxDWF_SPLITTER_BORDERS 0x02
00105
00106
00109 class WXDLLIMPEXP_DI wxLayoutManager : public wxObject
00110 {
00111 DECLARE_DYNAMIC_CLASS( wxLayoutManager )
00112
00113 public:
00114 wxLayoutManager( wxWindow * pOwnerWindow );
00115 ~wxLayoutManager();
00116
00117 void Init();
00118 void SetLayout( unsigned int flags,
00119 wxWindow * pAutoLayoutClientWindow = NULL );
00120 void SetWindowMenu( wxMenu * menu )
00121 { pWindowMenu_ = menu; }
00122
00123
00124 void AddDefaultHosts();
00125 void AddDockHost( wxDirection dir, int initialSize = wxINITIAL_HOST_SIZE,
00126 const wxString& name = wxT("guessname") );
00127 wxDockHost * GetDockHost( const wxString& name );
00128 wxDockHost * GetDockHost( const wxDirection &_dir );
00129
00130
00131 void AddDockWindow( wxDockWindowBase * pDockWindow );
00132 void DockWindow( wxDockWindowBase * pDockWindow, wxHostInfo &hi,
00133 bool noHideOperation = false );
00134 void UndockWindow( wxDockWindowBase * pDockWindow,
00135 bool noShowOperation = false );
00136
00137
00138 bool SaveToStream( wxOutputStream &stream );
00139 bool LoadFromStream( wxInputStream &stream );
00140 #ifdef wxDI_USE_XMLLOADSAVE
00141 bool SaveToXML( const wxString& filename );
00142 bool LoadFromXML( const wxString& filename );
00143 #endif
00144 bool SaveToConfig(wxConfigBase *, const wxString &key) const;
00145 bool LoadFromConfig(wxConfigBase *, const wxString &key);
00146
00147
00148 wxHostInfo TestForHost( int sx, int sy );
00149 wxRect TrimDockArea( wxDockHost * pDockHost, wxRect &dockArea );
00150 bool IsPrimaryDockHost( wxDockHost * pDockHost );
00151 void SetDockArea( wxRect &rect );
00152 wxRect GetDockArea();
00153 wxRect RectToScreen( wxRect &rect );
00154 wxPoint PointFromScreen( wxPoint &point );
00155 unsigned int GetFlags();
00156
00157 void UpdateAllHosts( bool sizeChange, wxDockHost * pIgnoreHost = NULL );
00158
00159
00160 void OnSize();
00161 void OnMove();
00162 void OnUpdateLayout();
00163 void OnMenuToggle( int entryId );
00164
00165 private:
00166 wxDockHost * findDockHost( const wxString& name );
00167 wxDockWindowBase * findDockWindow( const wxString& name );
00168
00169 void settingsChanged();
00170
00171 private:
00172 DockHostList dockHosts_;
00173 DockWindowList dockWindows_;
00174
00175 wxWindow * pOwnerWindow_;
00176 wxOwnerEventHandler frameEventHandler_;
00177
00178 unsigned int flags_;
00179 wxWindow * pAutoLayoutClientWindow_;
00180 wxRect dockArea_;
00181 wxMenu * pWindowMenu_;
00182 };
00183
00184
00185
00186
00187
00188
00189
00190 BEGIN_DECLARE_EVENT_TYPES()
00191 DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_DI, wxEVT_LAYOUT_CHANGED, wxEVT_FIRST + 1211 )
00192 END_DECLARE_EVENT_TYPES()
00193
00194 #define EVT_LAYOUT_CHANGED( fn ) \
00195 DECLARE_EVENT_TABLE_ENTRY( wxEVT_LAYOUT_CHANGED, -1, -1, \
00196 (wxObjectEventFunction) (wxEventFunction) & fn, NULL ),
00197
00198 #endif
00199