X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/916eabe60eee4adb05387bbf1eaf1915ae5eac18..e1ef506e13b7c8e96483b7fc0852dcb46688badd:/include/wx/control.h diff --git a/include/wx/control.h b/include/wx/control.h index a7c6496e72..e2db727b4c 100644 --- a/include/wx/control.h +++ b/include/wx/control.h @@ -24,6 +24,13 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[]; +enum wxEllipsizeMode +{ + wxELLIPSIZE_START, + wxELLIPSIZE_MIDDLE, + wxELLIPSIZE_END +}; + // ---------------------------------------------------------------------------- // wxControl is the base class for all controls // ---------------------------------------------------------------------------- @@ -46,9 +53,6 @@ public: // get the control alignment (left/right/centre, top/bottom/centre) int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; } - // get just the text of the label, without mnemonic characters ('&') - wxString GetLabelText() const { return GetLabelText(GetLabel()); } - virtual void SetLabel(const wxString& label) { m_labelOrig = label; @@ -65,14 +69,29 @@ public: return m_labelOrig; } + // get just the text of the label, without mnemonic characters ('&') + wxString GetLabelText() const { return GetLabelText(GetLabel()); } + + void SetLabelText(const wxString& text) + { + SetLabel(EscapeMnemonics(text)); + } + // static utilities: + // replaces parts of the string with ellipsis if needed + static wxString Ellipsize(const wxString& label, const wxDC& dc, + wxEllipsizeMode mode, int maxWidth); + // get the string without mnemonic characters ('&') static wxString GetLabelText(const wxString& label); // removes the mnemonics characters static wxString RemoveMnemonics(const wxString& str); + // escapes (by doubling them) the mnemonics + static wxString EscapeMnemonics(const wxString& str); + // return the accel index in the string or -1 if none and puts the modified // string into second parameter if non NULL static int FindAccelIndex(const wxString& label,