framemanager.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/aui/framemanager.h
  3. // Purpose: wxaui: wx advanced user interface - docking window manager
  4. // Author: Benjamin I. Williams
  5. // Modified by:
  6. // Created: 2005-05-17
  7. // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
  8. // Licence: wxWindows Library Licence, Version 3.1
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FRAMEMANAGER_H_
  11. #define _WX_FRAMEMANAGER_H_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #if wxUSE_AUI
  17. #include "wx/dynarray.h"
  18. #include "wx/gdicmn.h"
  19. #include "wx/window.h"
  20. #include "wx/timer.h"
  21. #include "wx/sizer.h"
  22. #include "wx/bitmap.h"
  23. enum wxAuiManagerDock
  24. {
  25. wxAUI_DOCK_NONE = 0,
  26. wxAUI_DOCK_TOP = 1,
  27. wxAUI_DOCK_RIGHT = 2,
  28. wxAUI_DOCK_BOTTOM = 3,
  29. wxAUI_DOCK_LEFT = 4,
  30. wxAUI_DOCK_CENTER = 5,
  31. wxAUI_DOCK_CENTRE = wxAUI_DOCK_CENTER
  32. };
  33. enum wxAuiManagerOption
  34. {
  35. wxAUI_MGR_ALLOW_FLOATING = 1 << 0,
  36. wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1,
  37. wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2,
  38. wxAUI_MGR_TRANSPARENT_HINT = 1 << 3,
  39. wxAUI_MGR_VENETIAN_BLINDS_HINT = 1 << 4,
  40. wxAUI_MGR_RECTANGLE_HINT = 1 << 5,
  41. wxAUI_MGR_HINT_FADE = 1 << 6,
  42. wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7,
  43. wxAUI_MGR_LIVE_RESIZE = 1 << 8,
  44. wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING |
  45. wxAUI_MGR_TRANSPARENT_HINT |
  46. wxAUI_MGR_HINT_FADE |
  47. wxAUI_MGR_NO_VENETIAN_BLINDS_FADE
  48. };
  49. enum wxAuiPaneDockArtSetting
  50. {
  51. wxAUI_DOCKART_SASH_SIZE = 0,
  52. wxAUI_DOCKART_CAPTION_SIZE = 1,
  53. wxAUI_DOCKART_GRIPPER_SIZE = 2,
  54. wxAUI_DOCKART_PANE_BORDER_SIZE = 3,
  55. wxAUI_DOCKART_PANE_BUTTON_SIZE = 4,
  56. wxAUI_DOCKART_BACKGROUND_COLOUR = 5,
  57. wxAUI_DOCKART_SASH_COLOUR = 6,
  58. wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR = 7,
  59. wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR = 8,
  60. wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR = 9,
  61. wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR = 10,
  62. wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR = 11,
  63. wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR = 12,
  64. wxAUI_DOCKART_BORDER_COLOUR = 13,
  65. wxAUI_DOCKART_GRIPPER_COLOUR = 14,
  66. wxAUI_DOCKART_CAPTION_FONT = 15,
  67. wxAUI_DOCKART_GRADIENT_TYPE = 16
  68. };
  69. enum wxAuiPaneDockArtGradients
  70. {
  71. wxAUI_GRADIENT_NONE = 0,
  72. wxAUI_GRADIENT_VERTICAL = 1,
  73. wxAUI_GRADIENT_HORIZONTAL = 2
  74. };
  75. enum wxAuiPaneButtonState
  76. {
  77. wxAUI_BUTTON_STATE_NORMAL = 0,
  78. wxAUI_BUTTON_STATE_HOVER = 1 << 1,
  79. wxAUI_BUTTON_STATE_PRESSED = 1 << 2,
  80. wxAUI_BUTTON_STATE_DISABLED = 1 << 3,
  81. wxAUI_BUTTON_STATE_HIDDEN = 1 << 4,
  82. wxAUI_BUTTON_STATE_CHECKED = 1 << 5
  83. };
  84. enum wxAuiButtonId
  85. {
  86. wxAUI_BUTTON_CLOSE = 101,
  87. wxAUI_BUTTON_MAXIMIZE_RESTORE = 102,
  88. wxAUI_BUTTON_MINIMIZE = 103,
  89. wxAUI_BUTTON_PIN = 104,
  90. wxAUI_BUTTON_OPTIONS = 105,
  91. wxAUI_BUTTON_WINDOWLIST = 106,
  92. wxAUI_BUTTON_LEFT = 107,
  93. wxAUI_BUTTON_RIGHT = 108,
  94. wxAUI_BUTTON_UP = 109,
  95. wxAUI_BUTTON_DOWN = 110,
  96. wxAUI_BUTTON_CUSTOM1 = 201,
  97. wxAUI_BUTTON_CUSTOM2 = 202,
  98. wxAUI_BUTTON_CUSTOM3 = 203
  99. };
  100. enum wxAuiPaneInsertLevel
  101. {
  102. wxAUI_INSERT_PANE = 0,
  103. wxAUI_INSERT_ROW = 1,
  104. wxAUI_INSERT_DOCK = 2
  105. };
  106. // forwards and array declarations
  107. class wxAuiDockUIPart;
  108. class wxAuiPaneButton;
  109. class wxAuiPaneInfo;
  110. class wxAuiDockInfo;
  111. class wxAuiDockArt;
  112. class wxAuiManagerEvent;
  113. #ifndef SWIG
  114. WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockInfo, wxAuiDockInfoArray, WXDLLIMPEXP_AUI);
  115. WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockUIPart, wxAuiDockUIPartArray, WXDLLIMPEXP_AUI);
  116. WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneButton, wxAuiPaneButtonArray, WXDLLIMPEXP_AUI);
  117. WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneInfo, wxAuiPaneInfoArray, WXDLLIMPEXP_AUI);
  118. WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiPaneInfo*, wxAuiPaneInfoPtrArray, class WXDLLIMPEXP_AUI);
  119. WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiDockInfo*, wxAuiDockInfoPtrArray, class WXDLLIMPEXP_AUI);
  120. #endif // SWIG
  121. extern WXDLLIMPEXP_AUI wxAuiDockInfo wxAuiNullDockInfo;
  122. extern WXDLLIMPEXP_AUI wxAuiPaneInfo wxAuiNullPaneInfo;
  123. class WXDLLIMPEXP_AUI wxAuiPaneInfo
  124. {
  125. public:
  126. wxAuiPaneInfo()
  127. {
  128. window = NULL;
  129. frame = NULL;
  130. state = 0;
  131. dock_direction = wxAUI_DOCK_LEFT;
  132. dock_layer = 0;
  133. dock_row = 0;
  134. dock_pos = 0;
  135. floating_pos = wxDefaultPosition;
  136. floating_size = wxDefaultSize;
  137. best_size = wxDefaultSize;
  138. min_size = wxDefaultSize;
  139. max_size = wxDefaultSize;
  140. dock_proportion = 0;
  141. DefaultPane();
  142. }
  143. ~wxAuiPaneInfo() {}
  144. #ifndef SWIG
  145. wxAuiPaneInfo(const wxAuiPaneInfo& c)
  146. {
  147. name = c.name;
  148. caption = c.caption;
  149. icon = c.icon;
  150. window = c.window;
  151. frame = c.frame;
  152. state = c.state;
  153. dock_direction = c.dock_direction;
  154. dock_layer = c.dock_layer;
  155. dock_row = c.dock_row;
  156. dock_pos = c.dock_pos;
  157. best_size = c.best_size;
  158. min_size = c.min_size;
  159. max_size = c.max_size;
  160. floating_pos = c.floating_pos;
  161. floating_size = c.floating_size;
  162. dock_proportion = c.dock_proportion;
  163. buttons = c.buttons;
  164. rect = c.rect;
  165. }
  166. wxAuiPaneInfo& operator=(const wxAuiPaneInfo& c)
  167. {
  168. name = c.name;
  169. caption = c.caption;
  170. window = c.window;
  171. frame = c.frame;
  172. state = c.state;
  173. dock_direction = c.dock_direction;
  174. dock_layer = c.dock_layer;
  175. dock_row = c.dock_row;
  176. dock_pos = c.dock_pos;
  177. best_size = c.best_size;
  178. min_size = c.min_size;
  179. max_size = c.max_size;
  180. floating_pos = c.floating_pos;
  181. floating_size = c.floating_size;
  182. dock_proportion = c.dock_proportion;
  183. buttons = c.buttons;
  184. rect = c.rect;
  185. return *this;
  186. }
  187. #endif // SWIG
  188. // Write the safe parts of a newly loaded PaneInfo structure "source" into "this"
  189. // used on loading perspectives etc.
  190. void SafeSet(wxAuiPaneInfo source)
  191. {
  192. // note source is not passed by reference so we can overwrite, to keep the
  193. // unsafe bits of "dest"
  194. source.window = window;
  195. source.frame = frame;
  196. source.buttons = buttons;
  197. wxCHECK_RET(source.IsValid(),
  198. "window settings and pane settings are incompatible");
  199. // now assign
  200. *this = source;
  201. }
  202. bool IsOk() const { return window != NULL; }
  203. bool IsFixed() const { return !HasFlag(optionResizable); }
  204. bool IsResizable() const { return HasFlag(optionResizable); }
  205. bool IsShown() const { return !HasFlag(optionHidden); }
  206. bool IsFloating() const { return HasFlag(optionFloating); }
  207. bool IsDocked() const { return !HasFlag(optionFloating); }
  208. bool IsToolbar() const { return HasFlag(optionToolbar); }
  209. bool IsTopDockable() const { return HasFlag(optionTopDockable); }
  210. bool IsBottomDockable() const { return HasFlag(optionBottomDockable); }
  211. bool IsLeftDockable() const { return HasFlag(optionLeftDockable); }
  212. bool IsRightDockable() const { return HasFlag(optionRightDockable); }
  213. bool IsDockable() const
  214. {
  215. return HasFlag(optionTopDockable | optionBottomDockable |
  216. optionLeftDockable | optionRightDockable);
  217. }
  218. bool IsFloatable() const { return HasFlag(optionFloatable); }
  219. bool IsMovable() const { return HasFlag(optionMovable); }
  220. bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); }
  221. bool IsMaximized() const { return HasFlag(optionMaximized); }
  222. bool HasCaption() const { return HasFlag(optionCaption); }
  223. bool HasGripper() const { return HasFlag(optionGripper); }
  224. bool HasBorder() const { return HasFlag(optionPaneBorder); }
  225. bool HasCloseButton() const { return HasFlag(buttonClose); }
  226. bool HasMaximizeButton() const { return HasFlag(buttonMaximize); }
  227. bool HasMinimizeButton() const { return HasFlag(buttonMinimize); }
  228. bool HasPinButton() const { return HasFlag(buttonPin); }
  229. bool HasGripperTop() const { return HasFlag(optionGripperTop); }
  230. #ifdef SWIG
  231. %typemap(out) wxAuiPaneInfo& { $result = $self; Py_INCREF($result); }
  232. #endif
  233. wxAuiPaneInfo& Window(wxWindow* w)
  234. {
  235. wxAuiPaneInfo test(*this);
  236. test.window = w;
  237. wxCHECK_MSG(test.IsValid(), *this,
  238. "window settings and pane settings are incompatible");
  239. *this = test;
  240. return *this;
  241. }
  242. wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; }
  243. wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; }
  244. wxAuiPaneInfo& Icon(const wxBitmap& b) { icon = b; return *this; }
  245. wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; }
  246. wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; }
  247. wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; }
  248. wxAuiPaneInfo& Bottom() { dock_direction = wxAUI_DOCK_BOTTOM; return *this; }
  249. wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return *this; }
  250. wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return *this; }
  251. wxAuiPaneInfo& Direction(int direction) { dock_direction = direction; return *this; }
  252. wxAuiPaneInfo& Layer(int layer) { dock_layer = layer; return *this; }
  253. wxAuiPaneInfo& Row(int row) { dock_row = row; return *this; }
  254. wxAuiPaneInfo& Position(int pos) { dock_pos = pos; return *this; }
  255. wxAuiPaneInfo& BestSize(const wxSize& size) { best_size = size; return *this; }
  256. wxAuiPaneInfo& MinSize(const wxSize& size) { min_size = size; return *this; }
  257. wxAuiPaneInfo& MaxSize(const wxSize& size) { max_size = size; return *this; }
  258. wxAuiPaneInfo& BestSize(int x, int y) { best_size.Set(x,y); return *this; }
  259. wxAuiPaneInfo& MinSize(int x, int y) { min_size.Set(x,y); return *this; }
  260. wxAuiPaneInfo& MaxSize(int x, int y) { max_size.Set(x,y); return *this; }
  261. wxAuiPaneInfo& FloatingPosition(const wxPoint& pos) { floating_pos = pos; return *this; }
  262. wxAuiPaneInfo& FloatingPosition(int x, int y) { floating_pos.x = x; floating_pos.y = y; return *this; }
  263. wxAuiPaneInfo& FloatingSize(const wxSize& size) { floating_size = size; return *this; }
  264. wxAuiPaneInfo& FloatingSize(int x, int y) { floating_size.Set(x,y); return *this; }
  265. wxAuiPaneInfo& Fixed() { return SetFlag(optionResizable, false); }
  266. wxAuiPaneInfo& Resizable(bool resizable = true) { return SetFlag(optionResizable, resizable); }
  267. wxAuiPaneInfo& Dock() { return SetFlag(optionFloating, false); }
  268. wxAuiPaneInfo& Float() { return SetFlag(optionFloating, true); }
  269. wxAuiPaneInfo& Hide() { return SetFlag(optionHidden, true); }
  270. wxAuiPaneInfo& Show(bool show = true) { return SetFlag(optionHidden, !show); }
  271. wxAuiPaneInfo& CaptionVisible(bool visible = true) { return SetFlag(optionCaption, visible); }
  272. wxAuiPaneInfo& Maximize() { return SetFlag(optionMaximized, true); }
  273. wxAuiPaneInfo& Restore() { return SetFlag(optionMaximized, false); }
  274. wxAuiPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); }
  275. wxAuiPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); }
  276. wxAuiPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); }
  277. wxAuiPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); }
  278. wxAuiPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); }
  279. wxAuiPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); }
  280. wxAuiPaneInfo& PinButton(bool visible = true) { return SetFlag(buttonPin, visible); }
  281. wxAuiPaneInfo& DestroyOnClose(bool b = true) { return SetFlag(optionDestroyOnClose, b); }
  282. wxAuiPaneInfo& TopDockable(bool b = true) { return SetFlag(optionTopDockable, b); }
  283. wxAuiPaneInfo& BottomDockable(bool b = true) { return SetFlag(optionBottomDockable, b); }
  284. wxAuiPaneInfo& LeftDockable(bool b = true) { return SetFlag(optionLeftDockable, b); }
  285. wxAuiPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); }
  286. wxAuiPaneInfo& Floatable(bool b = true) { return SetFlag(optionFloatable, b); }
  287. wxAuiPaneInfo& Movable(bool b = true) { return SetFlag(optionMovable, b); }
  288. wxAuiPaneInfo& DockFixed(bool b = true) { return SetFlag(optionDockFixed, b); }
  289. wxAuiPaneInfo& Dockable(bool b = true)
  290. {
  291. return TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b);
  292. }
  293. wxAuiPaneInfo& DefaultPane()
  294. {
  295. wxAuiPaneInfo test(*this);
  296. test.state |= optionTopDockable | optionBottomDockable |
  297. optionLeftDockable | optionRightDockable |
  298. optionFloatable | optionMovable | optionResizable |
  299. optionCaption | optionPaneBorder | buttonClose;
  300. wxCHECK_MSG(test.IsValid(), *this,
  301. "window settings and pane settings are incompatible");
  302. *this = test;
  303. return *this;
  304. }
  305. wxAuiPaneInfo& CentrePane() { return CenterPane(); }
  306. wxAuiPaneInfo& CenterPane()
  307. {
  308. state = 0;
  309. return Center().PaneBorder().Resizable();
  310. }
  311. wxAuiPaneInfo& ToolbarPane()
  312. {
  313. DefaultPane();
  314. state |= (optionToolbar | optionGripper);
  315. state &= ~(optionResizable | optionCaption);
  316. if (dock_layer == 0)
  317. dock_layer = 10;
  318. return *this;
  319. }
  320. wxAuiPaneInfo& SetFlag(int flag, bool option_state)
  321. {
  322. wxAuiPaneInfo test(*this);
  323. if (option_state)
  324. test.state |= flag;
  325. else
  326. test.state &= ~flag;
  327. wxCHECK_MSG(test.IsValid(), *this,
  328. "window settings and pane settings are incompatible");
  329. *this = test;
  330. return *this;
  331. }
  332. bool HasFlag(int flag) const
  333. {
  334. return (state & flag) != 0;
  335. }
  336. #ifdef SWIG
  337. %typemap(out) wxAuiPaneInfo& ;
  338. #endif
  339. public:
  340. // NOTE: You can add and subtract flags from this list,
  341. // but do not change the values of the flags, because
  342. // they are stored in a binary integer format in the
  343. // perspective string. If you really need to change the
  344. // values around, you'll have to ensure backwards-compatibility
  345. // in the perspective loading code.
  346. enum wxAuiPaneState
  347. {
  348. optionFloating = 1 << 0,
  349. optionHidden = 1 << 1,
  350. optionLeftDockable = 1 << 2,
  351. optionRightDockable = 1 << 3,
  352. optionTopDockable = 1 << 4,
  353. optionBottomDockable = 1 << 5,
  354. optionFloatable = 1 << 6,
  355. optionMovable = 1 << 7,
  356. optionResizable = 1 << 8,
  357. optionPaneBorder = 1 << 9,
  358. optionCaption = 1 << 10,
  359. optionGripper = 1 << 11,
  360. optionDestroyOnClose = 1 << 12,
  361. optionToolbar = 1 << 13,
  362. optionActive = 1 << 14,
  363. optionGripperTop = 1 << 15,
  364. optionMaximized = 1 << 16,
  365. optionDockFixed = 1 << 17,
  366. buttonClose = 1 << 21,
  367. buttonMaximize = 1 << 22,
  368. buttonMinimize = 1 << 23,
  369. buttonPin = 1 << 24,
  370. buttonCustom1 = 1 << 26,
  371. buttonCustom2 = 1 << 27,
  372. buttonCustom3 = 1 << 28,
  373. savedHiddenState = 1 << 30, // used internally
  374. actionPane = 1 << 31 // used internally
  375. };
  376. public:
  377. wxString name; // name of the pane
  378. wxString caption; // caption displayed on the window
  379. wxBitmap icon; // icon of the pane, may be invalid
  380. wxWindow* window; // window that is in this pane
  381. wxFrame* frame; // floating frame window that holds the pane
  382. unsigned int state; // a combination of wxPaneState values
  383. int dock_direction; // dock direction (top, bottom, left, right, center)
  384. int dock_layer; // layer number (0 = innermost layer)
  385. int dock_row; // row number on the docking bar (0 = first row)
  386. int dock_pos; // position inside the row (0 = first position)
  387. wxSize best_size; // size that the layout engine will prefer
  388. wxSize min_size; // minimum size the pane window can tolerate
  389. wxSize max_size; // maximum size the pane window can tolerate
  390. wxPoint floating_pos; // position while floating
  391. wxSize floating_size; // size while floating
  392. int dock_proportion; // proportion while docked
  393. wxAuiPaneButtonArray buttons; // buttons on the pane
  394. wxRect rect; // current rectangle (populated by wxAUI)
  395. bool IsValid() const;
  396. };
  397. class WXDLLIMPEXP_FWD_AUI wxAuiFloatingFrame;
  398. class WXDLLIMPEXP_AUI wxAuiManager : public wxEvtHandler
  399. {
  400. friend class wxAuiFloatingFrame;
  401. public:
  402. wxAuiManager(wxWindow* managedWnd = NULL,
  403. unsigned int flags = wxAUI_MGR_DEFAULT);
  404. virtual ~wxAuiManager();
  405. void UnInit();
  406. void SetFlags(unsigned int flags);
  407. unsigned int GetFlags() const;
  408. void SetManagedWindow(wxWindow* managedWnd);
  409. wxWindow* GetManagedWindow() const;
  410. static wxAuiManager* GetManager(wxWindow* window);
  411. void SetArtProvider(wxAuiDockArt* artProvider);
  412. wxAuiDockArt* GetArtProvider() const;
  413. wxAuiPaneInfo& GetPane(wxWindow* window);
  414. wxAuiPaneInfo& GetPane(const wxString& name);
  415. wxAuiPaneInfoArray& GetAllPanes();
  416. bool AddPane(wxWindow* window,
  417. const wxAuiPaneInfo& paneInfo);
  418. bool AddPane(wxWindow* window,
  419. const wxAuiPaneInfo& paneInfo,
  420. const wxPoint& dropPos);
  421. bool AddPane(wxWindow* window,
  422. int direction = wxLEFT,
  423. const wxString& caption = wxEmptyString);
  424. bool InsertPane(wxWindow* window,
  425. const wxAuiPaneInfo& insertLocation,
  426. int insertLevel = wxAUI_INSERT_PANE);
  427. bool DetachPane(wxWindow* window);
  428. void Update();
  429. wxString SavePaneInfo(wxAuiPaneInfo& pane);
  430. void LoadPaneInfo(wxString panePart, wxAuiPaneInfo &pane);
  431. wxString SavePerspective();
  432. bool LoadPerspective(const wxString& perspective, bool update = true);
  433. void SetDockSizeConstraint(double widthPct, double heightPct);
  434. void GetDockSizeConstraint(double* widthPct, double* heightPct) const;
  435. void ClosePane(wxAuiPaneInfo& paneInfo);
  436. void MaximizePane(wxAuiPaneInfo& paneInfo);
  437. void RestorePane(wxAuiPaneInfo& paneInfo);
  438. void RestoreMaximizedPane();
  439. public:
  440. virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
  441. virtual bool CanDockPanel(const wxAuiPaneInfo & p);
  442. void StartPaneDrag(
  443. wxWindow* paneWindow,
  444. const wxPoint& offset);
  445. wxRect CalculateHintRect(
  446. wxWindow* paneWindow,
  447. const wxPoint& pt,
  448. const wxPoint& offset);
  449. void DrawHintRect(
  450. wxWindow* paneWindow,
  451. const wxPoint& pt,
  452. const wxPoint& offset);
  453. virtual void ShowHint(const wxRect& rect);
  454. virtual void HideHint();
  455. void OnHintActivate(wxActivateEvent& event);
  456. public:
  457. // deprecated -- please use SetManagedWindow() and
  458. // and GetManagedWindow() instead
  459. wxDEPRECATED( void SetFrame(wxFrame* frame) );
  460. wxDEPRECATED( wxFrame* GetFrame() const );
  461. protected:
  462. void UpdateHintWindowConfig();
  463. void DoFrameLayout();
  464. void LayoutAddPane(wxSizer* container,
  465. wxAuiDockInfo& dock,
  466. wxAuiPaneInfo& pane,
  467. wxAuiDockUIPartArray& uiparts,
  468. bool spacerOnly);
  469. void LayoutAddDock(wxSizer* container,
  470. wxAuiDockInfo& dock,
  471. wxAuiDockUIPartArray& uiParts,
  472. bool spacerOnly);
  473. wxSizer* LayoutAll(wxAuiPaneInfoArray& panes,
  474. wxAuiDockInfoArray& docks,
  475. wxAuiDockUIPartArray & uiParts,
  476. bool spacerOnly = false);
  477. virtual bool ProcessDockResult(wxAuiPaneInfo& target,
  478. const wxAuiPaneInfo& newPos);
  479. bool DoDrop(wxAuiDockInfoArray& docks,
  480. wxAuiPaneInfoArray& panes,
  481. wxAuiPaneInfo& drop,
  482. const wxPoint& pt,
  483. const wxPoint& actionOffset = wxPoint(0,0));
  484. wxAuiDockUIPart* HitTest(int x, int y);
  485. wxAuiDockUIPart* GetPanePart(wxWindow* pane);
  486. int GetDockPixelOffset(wxAuiPaneInfo& test);
  487. void OnFloatingPaneMoveStart(wxWindow* window);
  488. void OnFloatingPaneMoving(wxWindow* window, wxDirection dir );
  489. void OnFloatingPaneMoved(wxWindow* window, wxDirection dir);
  490. void OnFloatingPaneActivated(wxWindow* window);
  491. void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt);
  492. void OnFloatingPaneResized(wxWindow* window, const wxRect& rect);
  493. void Render(wxDC* dc);
  494. void Repaint(wxDC* dc = NULL);
  495. void ProcessMgrEvent(wxAuiManagerEvent& event);
  496. void UpdateButtonOnScreen(wxAuiDockUIPart* buttonUiPart,
  497. const wxMouseEvent& event);
  498. void GetPanePositionsAndSizes(wxAuiDockInfo& dock,
  499. wxArrayInt& positions,
  500. wxArrayInt& sizes);
  501. /// Ends a resize action, or for live update, resizes the sash
  502. bool DoEndResizeAction(wxMouseEvent& event);
  503. void SetActivePane(wxWindow* active_pane);
  504. public:
  505. // public events (which can be invoked externally)
  506. void OnRender(wxAuiManagerEvent& evt);
  507. void OnPaneButton(wxAuiManagerEvent& evt);
  508. protected:
  509. // protected events
  510. void OnPaint(wxPaintEvent& evt);
  511. void OnEraseBackground(wxEraseEvent& evt);
  512. void OnSize(wxSizeEvent& evt);
  513. void OnSetCursor(wxSetCursorEvent& evt);
  514. void OnLeftDown(wxMouseEvent& evt);
  515. void OnLeftUp(wxMouseEvent& evt);
  516. void OnMotion(wxMouseEvent& evt);
  517. void OnCaptureLost(wxMouseCaptureLostEvent& evt);
  518. void OnLeaveWindow(wxMouseEvent& evt);
  519. void OnChildFocus(wxChildFocusEvent& evt);
  520. void OnHintFadeTimer(wxTimerEvent& evt);
  521. void OnFindManager(wxAuiManagerEvent& evt);
  522. protected:
  523. enum
  524. {
  525. actionNone = 0,
  526. actionResize,
  527. actionClickButton,
  528. actionClickCaption,
  529. actionDragToolbarPane,
  530. actionDragFloatingPane
  531. };
  532. protected:
  533. wxWindow* m_frame; // the window being managed
  534. wxAuiDockArt* m_art; // dock art object which does all drawing
  535. unsigned int m_flags; // manager flags wxAUI_MGR_*
  536. wxAuiPaneInfoArray m_panes; // array of panes structures
  537. wxAuiDockInfoArray m_docks; // array of docks structures
  538. wxAuiDockUIPartArray m_uiParts; // array of UI parts (captions, buttons, etc)
  539. int m_action; // current mouse action
  540. wxPoint m_actionStart; // position where the action click started
  541. wxPoint m_actionOffset; // offset from upper left of the item clicked
  542. wxAuiDockUIPart* m_actionPart; // ptr to the part the action happened to
  543. wxWindow* m_actionWindow; // action frame or window (NULL if none)
  544. wxRect m_actionHintRect; // hint rectangle for the action
  545. wxRect m_lastRect;
  546. wxAuiDockUIPart* m_hoverButton;// button uipart being hovered over
  547. wxRect m_lastHint; // last hint rectangle
  548. wxPoint m_lastMouseMove; // last mouse move position (see OnMotion)
  549. int m_currentDragItem;
  550. bool m_skipping;
  551. bool m_hasMaximized;
  552. double m_dockConstraintX; // 0.0 .. 1.0; max pct of window width a dock can consume
  553. double m_dockConstraintY; // 0.0 .. 1.0; max pct of window height a dock can consume
  554. wxFrame* m_hintWnd; // transparent hint window, if supported by platform
  555. wxTimer m_hintFadeTimer; // transparent fade timer
  556. wxByte m_hintFadeAmt; // transparent fade amount
  557. wxByte m_hintFadeMax; // maximum value of hint fade
  558. void* m_reserved;
  559. #ifndef SWIG
  560. DECLARE_EVENT_TABLE()
  561. DECLARE_CLASS(wxAuiManager)
  562. #endif // SWIG
  563. };
  564. // event declarations/classes
  565. class WXDLLIMPEXP_AUI wxAuiManagerEvent : public wxEvent
  566. {
  567. public:
  568. wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type)
  569. {
  570. manager = NULL;
  571. pane = NULL;
  572. button = 0;
  573. veto_flag = false;
  574. canveto_flag = true;
  575. dc = NULL;
  576. }
  577. #ifndef SWIG
  578. wxAuiManagerEvent(const wxAuiManagerEvent& c) : wxEvent(c)
  579. {
  580. manager = c.manager;
  581. pane = c.pane;
  582. button = c.button;
  583. veto_flag = c.veto_flag;
  584. canveto_flag = c.canveto_flag;
  585. dc = c.dc;
  586. }
  587. #endif
  588. wxEvent *Clone() const { return new wxAuiManagerEvent(*this); }
  589. void SetManager(wxAuiManager* mgr) { manager = mgr; }
  590. void SetPane(wxAuiPaneInfo* p) { pane = p; }
  591. void SetButton(int b) { button = b; }
  592. void SetDC(wxDC* pdc) { dc = pdc; }
  593. wxAuiManager* GetManager() const { return manager; }
  594. wxAuiPaneInfo* GetPane() const { return pane; }
  595. int GetButton() const { return button; }
  596. wxDC* GetDC() const { return dc; }
  597. void Veto(bool veto = true) { veto_flag = veto; }
  598. bool GetVeto() const { return veto_flag; }
  599. void SetCanVeto(bool can_veto) { canveto_flag = can_veto; }
  600. bool CanVeto() const { return canveto_flag && veto_flag; }
  601. public:
  602. wxAuiManager* manager;
  603. wxAuiPaneInfo* pane;
  604. int button;
  605. bool veto_flag;
  606. bool canveto_flag;
  607. wxDC* dc;
  608. #ifndef SWIG
  609. private:
  610. DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiManagerEvent)
  611. #endif
  612. };
  613. class WXDLLIMPEXP_AUI wxAuiDockInfo
  614. {
  615. public:
  616. wxAuiDockInfo()
  617. {
  618. dock_direction = 0;
  619. dock_layer = 0;
  620. dock_row = 0;
  621. size = 0;
  622. min_size = 0;
  623. resizable = true;
  624. fixed = false;
  625. toolbar = false;
  626. reserved1 = false;
  627. }
  628. #ifndef SWIG
  629. wxAuiDockInfo(const wxAuiDockInfo& c)
  630. {
  631. dock_direction = c.dock_direction;
  632. dock_layer = c.dock_layer;
  633. dock_row = c.dock_row;
  634. size = c.size;
  635. min_size = c.min_size;
  636. resizable = c.resizable;
  637. fixed = c.fixed;
  638. toolbar = c.toolbar;
  639. panes = c.panes;
  640. rect = c.rect;
  641. reserved1 = c.reserved1;
  642. }
  643. wxAuiDockInfo& operator=(const wxAuiDockInfo& c)
  644. {
  645. dock_direction = c.dock_direction;
  646. dock_layer = c.dock_layer;
  647. dock_row = c.dock_row;
  648. size = c.size;
  649. min_size = c.min_size;
  650. resizable = c.resizable;
  651. fixed = c.fixed;
  652. toolbar = c.toolbar;
  653. panes = c.panes;
  654. rect = c.rect;
  655. reserved1 = c.reserved1;
  656. return *this;
  657. }
  658. #endif // SWIG
  659. bool IsOk() const { return dock_direction != 0; }
  660. bool IsHorizontal() const { return dock_direction == wxAUI_DOCK_TOP ||
  661. dock_direction == wxAUI_DOCK_BOTTOM; }
  662. bool IsVertical() const { return dock_direction == wxAUI_DOCK_LEFT ||
  663. dock_direction == wxAUI_DOCK_RIGHT ||
  664. dock_direction == wxAUI_DOCK_CENTER; }
  665. public:
  666. wxAuiPaneInfoPtrArray panes; // array of panes
  667. wxRect rect; // current rectangle
  668. int dock_direction; // dock direction (top, bottom, left, right, center)
  669. int dock_layer; // layer number (0 = innermost layer)
  670. int dock_row; // row number on the docking bar (0 = first row)
  671. int size; // size of the dock
  672. int min_size; // minimum size of a dock (0 if there is no min)
  673. bool resizable; // flag indicating whether the dock is resizable
  674. bool toolbar; // flag indicating dock contains only toolbars
  675. bool fixed; // flag indicating that the dock operates on
  676. // absolute coordinates as opposed to proportional
  677. bool reserved1;
  678. };
  679. class WXDLLIMPEXP_AUI wxAuiDockUIPart
  680. {
  681. public:
  682. enum
  683. {
  684. typeCaption,
  685. typeGripper,
  686. typeDock,
  687. typeDockSizer,
  688. typePane,
  689. typePaneSizer,
  690. typeBackground,
  691. typePaneBorder,
  692. typePaneButton
  693. };
  694. int type; // ui part type (see enum above)
  695. int orientation; // orientation (either wxHORIZONTAL or wxVERTICAL)
  696. wxAuiDockInfo* dock; // which dock the item is associated with
  697. wxAuiPaneInfo* pane; // which pane the item is associated with
  698. wxAuiPaneButton* button; // which pane button the item is associated with
  699. wxSizer* cont_sizer; // the part's containing sizer
  700. wxSizerItem* sizer_item; // the sizer item of the part
  701. wxRect rect; // client coord rectangle of the part itself
  702. };
  703. class WXDLLIMPEXP_AUI wxAuiPaneButton
  704. {
  705. public:
  706. int button_id; // id of the button (e.g. buttonClose)
  707. };
  708. #ifndef SWIG
  709. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_BUTTON, wxAuiManagerEvent );
  710. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_CLOSE, wxAuiManagerEvent );
  711. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEvent );
  712. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_RESTORE, wxAuiManagerEvent );
  713. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEvent );
  714. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, wxAuiManagerEvent );
  715. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_FIND_MANAGER, wxAuiManagerEvent );
  716. typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
  717. #define wxAuiManagerEventHandler(func) \
  718. wxEVENT_HANDLER_CAST(wxAuiManagerEventFunction, func)
  719. #define EVT_AUI_PANE_BUTTON(func) \
  720. wx__DECLARE_EVT0(wxEVT_AUI_PANE_BUTTON, wxAuiManagerEventHandler(func))
  721. #define EVT_AUI_PANE_CLOSE(func) \
  722. wx__DECLARE_EVT0(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(func))
  723. #define EVT_AUI_PANE_MAXIMIZE(func) \
  724. wx__DECLARE_EVT0(wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEventHandler(func))
  725. #define EVT_AUI_PANE_RESTORE(func) \
  726. wx__DECLARE_EVT0(wxEVT_AUI_PANE_RESTORE, wxAuiManagerEventHandler(func))
  727. #define EVT_AUI_PANE_ACTIVATED(func) \
  728. wx__DECLARE_EVT0(wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEventHandler(func))
  729. #define EVT_AUI_RENDER(func) \
  730. wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func))
  731. #define EVT_AUI_FIND_MANAGER(func) \
  732. wx__DECLARE_EVT0(wxEVT_AUI_FIND_MANAGER, wxAuiManagerEventHandler(func))
  733. #else
  734. %constant wxEventType wxEVT_AUI_PANE_BUTTON;
  735. %constant wxEventType wxEVT_AUI_PANE_CLOSE;
  736. %constant wxEventType wxEVT_AUI_PANE_MAXIMIZE;
  737. %constant wxEventType wxEVT_AUI_PANE_RESTORE;
  738. %constant wxEventType wxEVT_AUI_PANE_ACTIVATED;
  739. %constant wxEventType wxEVT_AUI_RENDER;
  740. %constant wxEventType wxEVT_AUI_FIND_MANAGER;
  741. %pythoncode {
  742. EVT_AUI_PANE_BUTTON = wx.PyEventBinder( wxEVT_AUI_PANE_BUTTON )
  743. EVT_AUI_PANE_CLOSE = wx.PyEventBinder( wxEVT_AUI_PANE_CLOSE )
  744. EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANE_MAXIMIZE )
  745. EVT_AUI_PANE_RESTORE = wx.PyEventBinder( wxEVT_AUI_PANE_RESTORE )
  746. EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder( wxEVT_AUI_PANE_ACTIVATED )
  747. EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER )
  748. EVT_AUI_FIND_MANAGER = wx.PyEventBinder( wxEVT_AUI_FIND_MANAGER )
  749. }
  750. #endif // SWIG
  751. #endif // wxUSE_AUI
  752. #endif //_WX_FRAMEMANAGER_H_