IconButton::IconButton(Icons eUseIcon, const C4Rect &rtBounds, char caHotkey, const char *tooltip_text) : Button("", rtBounds), dwClr(0u), fHasClr(false), fHighlight(false) { // ctor cHotkey = caHotkey; SetIcon(eUseIcon); // set tooltip and expand hotkey if (tooltip_text) { StdStrBuf tooltip_text_buf(tooltip_text); if (!cHotkey) ExpandHotkeyMarkup(tooltip_text_buf, cHotkey, true); SetToolTip(tooltip_text_buf.getData(), true); } }
void Button::SetText(const char *szToText) { // set new button text if (szToText) { sText.Copy(szToText); // expand hotkey markup ExpandHotkeyMarkup(sText, cHotkey); } else { sText=""; cHotkey=0; } }
CheckBox::CheckBox(const C4Rect &rtBounds, const char *szCaption, bool fChecked) : Control(rtBounds), fChecked(fChecked), fMouseOn(false), fEnabled(true), pFont(NULL) , dwEnabledClr(C4GUI_CheckboxFontClr), dwDisabledClr(C4GUI_CheckboxDisabledFontClr), cHotkey(0) { if (szCaption) { sCaption.Copy(szCaption); ExpandHotkeyMarkup(sCaption, cHotkey); } // key callbacks: Check/Uncheck on space and primary joy button C4CustomKey::CodeList Keys; Keys.push_back(C4KeyCodeEx(K_SPACE)); if (Config.Controls.GamepadGuiControl) { Keys.push_back(C4KeyCodeEx(KEY_Gamepad(0, KEY_JOY_AnyLowButton))); } pKeyCheck = new C4KeyBinding(Keys, "GUICheckboxToggle", KEYSCOPE_Gui, new ControlKeyCB<CheckBox>(*this, &CheckBox::KeyCheck), C4CustomKey::PRIO_Ctrl); pCBHandler = NULL; }
void Label::SetText(const char *szToText, bool fAllowHotkey) { // set new text if (szToText) { sText.Copy(szToText); // expand hotkey markup if (fAllowHotkey && fMarkup) ExpandHotkeyMarkup(sText, cHotkey); } else { sText=""; cHotkey=0; } // update according to text only if autosize label (not wooden) if (!fAutosize) return; // get text extents pFont->GetTextExtent(sText.getData(), rcBounds.Wdt, rcBounds.Hgt, fMarkup); // update pos SetX0(x0); }