Debian Codegraph @

include/ui/istatusbarmanager.h

raw
1 #pragma once
2
3 #include "imodule.h"
4
5 class wxWindow;
6
7 namespace ui
8 {
9
10 namespace statusbar
11 {
12
13 // Use these positions to place the status bar elements in between
14 // the default ones. A position of 32 would put a widget in between
15 // StandardPosition::GridSize and StandardPosition::OrthoViewPosition.
16 struct StandardPosition
17 {
18 enum
19 {
20 Front = 0,
21 Commands = 10,
22 MapStatistics = 20,
23 GridSize = 30,
24 OrthoViewPosition = 40,
25 ShaderClipboard = 50,
26 MapEditStopwatch = 60,
27 Back = 9000,
28 };
29 };
30
31 class IStatusBarManager :
32 public RegisterableModule
33 {
34 public:
35 virtual ~IStatusBarManager() {}
36
37 /**
38 * Get the status bar widget, for packing into the main window.
39 * The widget will be parented to a temporary wxFrame, so it has to be
40 * re-parented before packing.
41 */
42 virtual wxWindow* getStatusBar() = 0;
43
44 /**
45 * greebo: This adds a named element to the status bar. Pass the widget
46 * which should be added and specify the position order.
47 *
48 * @name: the name of the element (can be used for later lookup).
49 * @widget: the widget to pack.
50 * @pos: the position to insert. Use POS_FRONT or POS_BACK to put the element
51 * at the front or back of the status bar container.
52 */
53 virtual void addElement(const std::string& name, wxWindow* widget, int pos) = 0;
54
55 /**
56 * greebo: A specialised method, adding a named text element.
57 * Use the setText() method to update this element.
58 *
59 * @name: the name for this element (can be used as key for the setText() method).
60 * @icon: the icon file to pack into the element, relative the BITMAPS_PATH. Leave empty
61 * if no icon is desired.
62 * @pos: the position to insert. Use POS_FRONT or POS_BACK to put the element
63 * at the front or back of the status bar container.
64 * @description: a description shown when the mouse pointer hovers of this item.
65 */
66 virtual void addTextElement(const std::string& name, const std::string& icon, int pos,
67 const std::string& description) = 0;
68
69 /**
70 * Updates the content of the named text element. The name must refer to
71 * an element previously added by addTextElement().
72 * If immediateUpdate is set to true, the UI will be updated right now. UI updates come with
73 * a certain cost, try to avoid it unless it's really necessary.
74 */
75 virtual void setText(const std::string& name, const std::string& text, bool immediateUpdate = false) = 0;
76
77 /**
78 * Returns a named status bar widget, previously added by addElement().
79 *
80 * @returns: NULL if the named widget does not exist.
81 */
82 virtual wxWindow* getElement(const std::string& name) = 0;
83 };
84
85 }
86
87 }
88
89 constexpr const char* const MODULE_STATUSBARMANAGER = "StatusBarManager";
90
91 inline ui::statusbar::IStatusBarManager& GlobalStatusBarManager()
92 {
93 static module::InstanceReference<ui::statusbar::IStatusBarManager> _reference(MODULE_STATUSBARMANAGER);
94 return _reference;
95 }