-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize toolbar on OSX #23614
base: master
Are you sure you want to change the base?
Customize toolbar on OSX #23614
Changes from all commits
567b632
10c87b1
89a8a7f
779f9c1
e0060ae
57f5df6
a632e68
4fcc972
abfab1d
8be1d3a
92728d8
ce48129
35392ef
029c0c1
9dc456b
24cb97c
f18e6b9
7543be5
73f1a88
489a21d
6e0f893
37f9368
9883ce5
1a4de0b
76c1d5d
f83da65
8980a62
9d7a875
250879e
a49443d
57dd140
7606d55
fe732c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -724,6 +724,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX, wxCommandEvent); | |||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_RCLICKED, wxCommandEvent); | ||||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_DROPDOWN, wxCommandEvent); | ||||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_ENTER, wxCommandEvent); | ||||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TB_CUSTOMIZE, wxCommandEvent); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just
Suggested change
|
||||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent); | ||||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent); | ||||||
|
||||||
|
@@ -4682,6 +4683,7 @@ typedef void (wxEvtHandler::*wxFullScreenEventFunction)(wxFullScreenEvent&); | |||||
#define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func)) | ||||||
#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) | ||||||
#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func)) | ||||||
#define EVT_TB_CUSTOMIZE(func) wx__DECLARE_EVT1(wxEVT_TB_CUSTOMIZE, wxCommandEventHandler(func)) | ||||||
#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func)) | ||||||
#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func)) | ||||||
#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func)) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -89,9 +89,11 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase | |||||
wxObject *clientData = nullptr, | ||||||
const wxString& shortHelp = wxEmptyString, | ||||||
const wxString& longHelp = wxEmptyString) override; | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please try to avoid whitespace-only changes (even if you make them accidentally, nothing prevents you from looking at the diff and removing them afterwards). |
||||||
virtual wxToolBarToolBase *CreateTool(wxControl *control, | ||||||
const wxString& label) override; | ||||||
|
||||||
void *GetMacToolbar() { return m_macToolbar; }; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The prevailing convention is to use
Suggested change
|
||||||
protected: | ||||||
// common part of all ctors | ||||||
void Init(); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,8 @@ class WXDLLIMPEXP_CORE wxToolBarToolBase : public wxObject | |
const wxString& longHelpString = wxEmptyString) | ||
: m_label(label), | ||
m_shortHelpString(shortHelpString), | ||
m_longHelpString(longHelpString) | ||
m_longHelpString(longHelpString), | ||
m_available(true) | ||
{ | ||
Init | ||
( | ||
|
@@ -94,7 +95,8 @@ class WXDLLIMPEXP_CORE wxToolBarToolBase : public wxObject | |
wxToolBarToolBase(wxToolBarBase *tbar, | ||
wxControl *control, | ||
const wxString& label) | ||
: m_label(label) | ||
: m_label(label), | ||
m_available(true) | ||
{ | ||
Init(tbar, wxTOOL_STYLE_CONTROL, control->GetId(), wxITEM_MAX); | ||
|
||
|
@@ -144,6 +146,8 @@ class WXDLLIMPEXP_CORE wxToolBarToolBase : public wxObject | |
bool IsToggled() const { return m_toggled; } | ||
bool CanBeToggled() const | ||
{ return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; } | ||
bool IsAvailable() const { return m_available; } | ||
virtual void MarkAvailable(bool available) { m_available = available; } | ||
|
||
// attributes | ||
wxBitmapBundle GetNormalBitmapBundle() const { return m_bmpNormal; } | ||
|
@@ -266,6 +270,7 @@ class WXDLLIMPEXP_CORE wxToolBarToolBase : public wxObject | |
// short and long help strings | ||
wxString m_shortHelpString; | ||
wxString m_longHelpString; | ||
bool m_available; | ||
|
||
#if wxUSE_MENUS | ||
wxMenu *m_dropdownMenu; | ||
|
@@ -314,7 +319,7 @@ class WXDLLIMPEXP_CORE wxToolBarBase : public wxControl | |
const wxString& shortHelp = wxEmptyString, | ||
wxItemKind kind = wxITEM_NORMAL) | ||
{ | ||
return AddTool(toolid, label, bitmap, wxBitmapBundle(), kind, shortHelp); | ||
return AddTool(toolid, label, bitmap, wxBitmapBundle(), kind, shortHelp, wxEmptyString, nullptr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
} | ||
|
||
// add a check tool, i.e. a tool which can be toggled | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -159,6 +159,19 @@ class wxToolBarToolBase : public wxObject | |||||
|
||||||
void SetDropdownMenu(wxMenu *menu); | ||||||
wxMenu *GetDropdownMenu() const; | ||||||
|
||||||
/** | ||||||
Mark the tool to be not visible. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pretty misleading for a function called like this. You should say it may be used to mark the tool as being not currently visible if |
||||||
|
||||||
By default all tools and controls in the toolbar are visible. | ||||||
If you want, you can mark the tool/control not visible by default | ||||||
When you do that user will be able to go to the customization | ||||||
dialog and add the tool/control at a later time. | ||||||
When you want that you pass "false" to this function. | ||||||
|
||||||
@since 3.3.0 | ||||||
*/ | ||||||
void MarkAvailable(bool available); | ||||||
}; | ||||||
|
||||||
|
||||||
|
@@ -271,6 +284,15 @@ class wxToolBarToolBase : public wxObject | |||||
Process a @c wxEVT_TOOL_DROPDOWN event. If unhandled, | ||||||
displays the default dropdown menu set using | ||||||
wxToolBar::SetDropdownMenu(). | ||||||
@event{EVT_TB_CUSTOMIZE(id)} | ||||||
Process a @c wxEVT_TB_CUSTOMIZE event. Under MSW and OSX | ||||||
it will display native customization dialogs. On GTK it will | ||||||
be generic. | ||||||
Comment on lines
+288
to
+290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be true, there is no implementation at all for MSW and just a stub for GTK. This is not necessarily a problem, but the documentation shouldn't like and you should check that the API you propose is at least in principle implementable under the other platforms. |
||||||
In order for this event to happen you need to double click the | ||||||
toolbar on MSW and right click + context menu selection on OSX/GTK | ||||||
By default all added tools are displayed. | ||||||
|
||||||
This event is implemented @since 3.3.0 | ||||||
@endEventTable | ||||||
|
||||||
The toolbar class emits menu commands in the same way that a frame menubar | ||||||
|
@@ -878,6 +900,25 @@ class wxToolBar : public wxControl | |||||
@see GetMargins(), wxSize | ||||||
*/ | ||||||
void SetMargins(const wxSize& size); | ||||||
|
||||||
/** | ||||||
Return whether the tool is displayed by default or not | ||||||
By default all tools are displayed. | ||||||
|
||||||
@since 3.3 | ||||||
*/ | ||||||
bool IsAvailable() const; | ||||||
|
||||||
/** | ||||||
Calling this function with the parameter set to false will not add the tool to the toolbar | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
by default. | ||||||
|
||||||
@param available | ||||||
Whether add the tool by default to the toolbar or not. | ||||||
|
||||||
@since 3.3 | ||||||
*/ | ||||||
void MarkAvailable(bool available); | ||||||
///@} | ||||||
|
||||||
/** | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -470,6 +470,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) | |
combo->Append("combobox with extremely, extremely, extremely, extremely long label"); | ||
combo->Append("in a"); | ||
combo->Append("toolbar"); | ||
combo->MarkAvailable( false ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create another initially unavailable control instead of hiding this one. |
||
toolBar->AddControl(combo, "Combo Label"); | ||
} | ||
#endif // USE_CONTROLS_IN_TOOLBAR | ||
|
@@ -511,7 +512,9 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) | |
toolBar->AddStretchableSpace(); | ||
toolBar->AddTool(wxID_HELP, "Help", toolBarBitmaps[Tool_help], "Help button", wxITEM_CHECK); | ||
|
||
toolBar->AddTool(wxID_ABOUT, "About", toolBarBitmaps[Tool_about], "About"); | ||
wxToolBarToolBase *tool = new wxToolBarToolBase( toolBar, wxID_ABOUT, "About", toolBarBitmaps[Tool_about], toolBarBitmaps[Tool_about] ); | ||
tool->MarkAvailable( false ); | ||
toolBar->AddTool( tool ); | ||
|
||
if ( !m_pathBmp.empty() ) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need to add functions that only make sense for toolbar tools to base
wxControl
class. You will have to change the code to use them inwxToolBatTool
only.