29 #include <wx/tbarbase.h>
30 #include <wx/dynarray.h>
43 wxItemKind kind, wxString tooltip, wxString label) {
45 m_tipString = tooltip;
48 m_bmpNormal = bmpNormal;
49 m_bmpDisabled = bmpDisabled;
55 wxString tooltip, wxString label) {
57 m_tipString = tooltip;
60 m_bmpNormal = bmpNormal;
61 m_bmpDisabled = wxNullBitmap;
69 wxItemKind m_toolKind;
74 wxBitmap m_bmpDisabled;
75 wxToolBarToolBase *m_tool;
78 wxString m_NormalIconSVG;
79 wxString m_RolloverIconSVG;
80 wxString m_ToggledIconSVG;
83 typedef std::vector<ToolbarItemContainer *> ArrayOfToolbarItemContainer;
85 #define TOOLTIPON_TIMER 10000
86 #define TOOLTIPOFF_TIMER 10001
89 TOOLBAR_HIDE_TO_GRABBER = 0,
90 TOOLBAR_HIDE_TO_FIRST_TOOL,
107 const wxPoint &pos = wxDefaultPosition,
108 const wxSize &size = wxDefaultSize,
109 long style = wxNO_BORDER,
110 int orient = wxTB_HORIZONTAL)
115 Create(parent, winid, pos, size, style, orient);
119 const wxPoint &pos = wxDefaultPosition,
120 const wxSize &size = wxDefaultSize,
121 long style = wxNO_BORDER,
122 int orient = wxTB_HORIZONTAL);
126 virtual void SetToggledBackgroundColour(wxColour c) {
127 m_toggle_bg_color = c;
129 virtual void SetBackgroundColour(wxColour c) {m_background_color = c; }
130 virtual wxColour GetBackgroundColour() {
return m_background_color;}
131 virtual void SetColorScheme(ColorScheme cs);
134 bool OnMouseEvent(wxMouseEvent &event, wxPoint &position);
135 void OnToolTipTimerEvent(wxTimerEvent &event);
136 void OnToolTipOffTimerEvent(wxTimerEvent &event);
138 wxToolBarToolBase *AddTool(
int toolid,
const wxString &label,
139 const wxBitmap &bitmap,
140 const wxBitmap &bmpDisabled,
141 wxItemKind kind = wxITEM_NORMAL,
142 const wxString &shortHelp = wxEmptyString,
143 const wxString &longHelp = wxEmptyString,
144 wxObject *data = NULL);
146 wxToolBarToolBase *AddTool(
int toolid,
const wxString &label,
147 const wxBitmap &bitmap,
148 const wxString &shortHelp = wxEmptyString,
149 wxItemKind kind = wxITEM_NORMAL) {
150 return AddTool(toolid, label, bitmap, wxNullBitmap, kind, shortHelp);
153 wxToolBarToolBase *InsertTool(
size_t pos,
int id,
const wxString &label,
154 const wxBitmap &bitmap,
155 const wxBitmap &bmpDisabled, wxItemKind kind,
156 const wxString &shortHelp,
157 const wxString &longHelp, wxObject *clientData);
159 wxToolBarToolBase *InsertTool(
size_t pos, wxToolBarToolBase *tool);
162 virtual bool OnLeftClick(
int toolid,
bool toggleDown);
165 virtual void OnRightClick(
int toolid,
long x,
long y);
167 virtual void DoPluginToolUp();
169 bool IsDirty(){
return m_dirty; }
170 void SetDirty(
bool value ){ m_dirty = value; }
172 size_t GetToolsCount()
const {
return m_tools.GetCount(); }
173 void SetToolShowCount(
int count) { m_nShowTools = count; }
174 int GetToolShowCount() {
return m_nShowTools; }
176 int GetNoRowsOrColumns() {
return m_currentRowsOrColumns; };
177 int GetLineCount() {
return m_LineCount; };
178 int GetVisibleToolCount();
180 void SetToolNormalBitmapEx(wxToolBarToolBase *tool,
const wxString &iconname);
181 void SetToolNormalBitmapSVG(wxToolBarToolBase *tool, wxString fileSVG);
183 void EnableRolloverBitmaps(
bool enable) {
184 m_tbenableRolloverBitmaps = enable;
187 wxBitmap &GetBitmap(){
return m_bitmap; }
190 virtual wxControl *FindControl(
int toolid);
193 virtual wxToolBarToolBase *AddSeparator();
194 virtual wxToolBarToolBase *InsertSeparator(
size_t pos);
198 virtual wxToolBarToolBase *RemoveTool(
int toolid);
201 virtual bool DeleteToolByPos(
size_t pos);
202 virtual bool DeleteTool(
int toolid);
205 virtual void ClearTools();
209 virtual bool Realize();
214 virtual void EnableTool(
int toolid,
bool enable);
215 virtual void ToggleTool(
int toolid,
bool toggle);
217 virtual void SetToolBitmaps(
int toolid, wxBitmap *bmp, wxBitmap *bmpRollover);
218 virtual void SetToolBitmapsSVG(
int id, wxString fileSVGNormal,
219 wxString fileSVGRollover,
220 wxString fileSVGToggled);
222 void InvalidateBitmaps();
223 wxBitmap &CreateBitmap(
double display_scale = 1.0);
226 virtual wxObject *GetToolClientData(
int toolid)
const;
227 virtual void SetToolClientData(
int toolid, wxObject *clientData);
230 virtual int GetToolPos(
int id)
const;
233 virtual bool GetToolState(
int toolid)
const;
235 virtual bool GetToolEnabled(
int toolid)
const;
237 virtual void SetToolShortHelp(
int toolid,
const wxString &helpString);
238 virtual wxString GetToolShortHelp(
int toolid)
const;
239 virtual void SetToolLongHelp(
int toolid,
const wxString &helpString);
240 virtual wxString GetToolLongHelp(
int toolid)
const;
242 virtual void SetToolTooltipHiViz(
int id,
bool b_hiviz);
244 virtual void SetSizeFactor(
float factor) {
245 m_sizefactor = factor;
252 void SetMaxRowsCols(
int rows,
int cols) {
256 int GetMaxRows()
const {
return m_maxRows; }
257 int GetMaxCols()
const {
return m_maxCols; }
261 virtual void SetToolBitmapSize(
const wxSize &size) {
262 m_defaultWidth = size.x;
263 m_defaultHeight = size.y;
265 virtual wxSize GetToolBitmapSize()
const {
266 return wxSize(m_defaultWidth, m_defaultHeight);
271 virtual wxSize GetToolSize()
const {
return GetToolBitmapSize(); }
273 virtual wxRect GetToolRect(
int tool_id);
277 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
280 wxToolBarToolBase *FindById(
int toolid)
const;
283 bool IsVertical()
const {
return m_orient == wxTB_VERTICAL; }
286 wxToolBarToolsList m_tools;
295 wxCoord m_defaultWidth, m_defaultHeight;
298 wxCoord m_maxWidth, m_maxHeight;
302 void EnableTooltips();
303 void DisableTooltips();
310 virtual wxToolBarToolBase *DoAddTool(
311 int toolid,
const wxString &label,
const wxBitmap &bitmap,
312 const wxBitmap &bmpDisabled, wxItemKind kind,
313 const wxString &shortHelp = wxEmptyString,
314 const wxString &longHelp = wxEmptyString, wxObject *clientData = NULL,
315 wxCoord xPos = wxDefaultCoord, wxCoord yPos = wxDefaultCoord);
317 virtual bool DoInsertTool(
size_t pos, wxToolBarToolBase *tool);
318 virtual bool DoDeleteTool(
size_t pos, wxToolBarToolBase *tool);
320 virtual void DoEnableTool(wxToolBarToolBase *tool,
bool enable);
321 virtual void DoToggleTool(wxToolBarToolBase *tool,
bool toggle);
323 virtual wxToolBarToolBase *CreateTool(
int winid,
const wxString &label,
324 const wxBitmap &bmpNormal,
325 const wxBitmap &bmpDisabled,
326 wxItemKind kind, wxObject *clientData,
327 const wxString &shortHelp,
328 const wxString &longHelp);
331 void DrawTool(wxToolBarToolBase *tool);
332 virtual void DrawTool(wxDC &dc, wxToolBarToolBase *tool);
333 void CreateToolBitmap(wxToolBarToolBase *toolBase);
336 int m_currentRowsOrColumns;
339 int m_pressedTool, m_currentTool;
341 wxCoord m_lastX, m_lastY;
342 wxCoord m_xPos, m_yPos;
344 wxColour m_toggle_bg_color;
345 wxColour m_toolOutlineColour;
346 wxColour m_background_color;
351 ColorScheme m_currentColorScheme;
353 wxTimer m_tooltip_timer;
355 wxTimer m_tooltipoff_timer;
357 bool m_btooltip_show;
359 bool m_btoolbar_is_zooming;
366 int m_last_plugin_down_id;
369 bool m_tbenableRolloverBitmaps;
373 DECLARE_EVENT_TABLE()
381 #define DESTROY_TIMER 3
390 void OnClose(wxCloseEvent &event);
391 void OnWindowCreate(wxWindowCreateEvent &event);
392 void OnToolLeftClick(wxCommandEvent &event);
393 virtual void OnKeyDown(wxKeyEvent &event);
394 virtual void OnKeyUp(wxKeyEvent &event);
395 void OldMouseEvent(wxMouseEvent &event);
396 bool MouseEvent(wxMouseEvent &event);
397 void FadeTimerEvent(wxTimerEvent &event);
398 bool IsToolbarShown() {
return (m_ptoolbar != 0); }
399 float GetScaleFactor() {
return m_sizefactor; }
400 void DestroyTimerEvent(wxTimerEvent &event);
401 void DrawDC(
ocpnDC &dc,
double displayScale);
402 void DrawGL(
ocpnDC &gldc,
double displayScale);
404 void RefreshFadeTimer();
406 void EnableSubmerge(
bool enable) { m_benableSubmerge = enable; }
410 void SetToolbarHideMethod(
int n_method) { n_toolbarHideMethod = n_method; }
412 void SetToolConfigString(wxString
string) { m_configString = string; }
413 wxString GetToolConfigString() {
return m_configString; }
415 float GetSizeFactor() {
return m_sizefactor; }
417 void CreateConfigMenu();
420 void RefreshToolbar();
426 void EnableTooltips() {
427 if (m_ptoolbar) m_ptoolbar->EnableTooltips();
429 void DisableTooltips() {
430 if (m_ptoolbar) m_ptoolbar->DisableTooltips();
432 void UpdateRecoveryWindow(
bool b_toolbarEnable);
433 void EnableTool(
int toolid,
bool enable);
434 void SetToolShortHelp(
int toolid,
const wxString &helpString);
436 void DestroyToolBar();
437 void ToggleOrientation();
438 void MoveDialogInScreenCoords(wxPoint posn, wxPoint posn_old);
439 void SetDefaultPosition();
440 void LockPosition(
bool lock) { m_block = lock; }
441 virtual void SetColorScheme(ColorScheme cs);
442 ColorScheme GetColorScheme() {
return m_cs; }
443 bool CheckSurfaceRequest(wxMouseEvent &event);
444 void GetFrameRelativePosition(
int *x,
int *y);
445 void RestoreRelativePosition(
int x,
int y);
447 void SetGeometry(
bool bAvoid, wxRect rectAvoid);
448 void SetMinX(
int offset) { m_dock_min_x = offset; }
449 void SetMinY(
int offset) { m_dock_min_y = offset; }
450 long GetOrient() {
return m_orient; }
451 wxSize GetToolSize();
452 wxRect GetToolbarRect();
453 wxSize GetToolbarSize();
454 wxPoint GetToolbarPosition();
456 void SetAutoHideTimer(
int time);
457 void SetAutoHide(
bool hide) { m_bAutoHideToolbar = hide; }
459 size_t GetToolCount();
460 void SetToolShowMask(wxString mask);
461 wxString GetToolShowMask(
void) {
return m_toolShowMask; }
463 void SetToolShowCount(
int count);
464 int GetToolShowCount(
void);
469 int GetDockX() {
return m_dock_x; }
470 int GetDockY() {
return m_dock_y; }
471 void SetDockX(
int x) { m_dock_x = x; }
472 void SetDockY(
int y) { m_dock_y = y; }
474 void SetYAuxOffset(
int offset) { m_auxOffsetY = offset; }
476 void SetCanToggleOrientation(
bool enable) { b_canToggleOrientation = enable; }
477 bool GetCanToggleOrientation() {
return b_canToggleOrientation; }
479 bool toolbarConfigChanged;
481 wxMenu *m_FloatingToolbarConfigMenu;
483 wxString m_tblastAISiconName;
484 wxToolBarToolBase *m_pTBAISTool;
485 bool m_toolbar_scale_tools_shown;
486 void SetBackGroundColorString(wxString colorRef);
487 void SetULDockPosition(wxPoint position);
489 ArrayOfToolbarItemContainer m_Items;
492 int RebuildToolbar();
493 void EnableRolloverBitmaps(
bool bEnable);
494 bool GetEnableRolloverBitmaps() {
return m_enableRolloverBitmaps; }
500 void DoFade(
int value);
505 wxBoxSizer *m_topSizer;
508 wxTimer m_fade_timer;
521 bool m_marginsInvisible;
523 wxTimer m_destroyTimer;
524 wxSize m_recoversize;
526 bool m_bAutoHideToolbar;
527 int m_nAutoHideToolbar;
528 bool m_benableSubmerge;
530 wxString m_backcolorString;
532 wxString m_toolShowMask;
533 int n_toolbarHideMethod;
534 bool b_canToggleOrientation;
535 wxString m_configString;
536 bool m_enableRolloverBitmaps;
539 unsigned int m_texture;
540 wxImage m_toolbar_image;
547 std::vector<wxRadioButton *> choices;
554 #define SYMBOL_ToolbarChoices_STYLE \
555 wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX
559 DECLARE_EVENT_TABLE()
565 const wxString &caption = _T(
""),
566 const wxPoint &pos = wxDefaultPosition,
567 const wxSize &size = wxDefaultSize,
568 long style = SYMBOL_ToolbarChoices_STYLE);
572 void SetColorScheme(ColorScheme cs);
573 void RecalculateSize(
void);
576 void OnCancelClick(wxCommandEvent &event);
577 void OnOkClick(wxCommandEvent &event);
579 wxButton *m_CancelButton;
580 wxButton *m_OKButton;
582 std::vector<wxCheckBox *> cboxes;
583 wxMenu *m_configMenu;