virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_QES_PREVIOUS: case WID_QES_NEXT: { const Sign *si = this->PrevNextSign(widget == WID_QES_NEXT); /* Rebuild the sign list */ this->signs.ForceRebuild(); this->signs.NeedResort(); this->BuildSignsList(); this->SortSignsList(); /* Scroll to sign and reopen window */ ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); UpdateSignEditWindow(si); break; } case WID_QES_DELETE: /* Only need to set the buffer to null, the rest is handled as the OK button */ RenameSign(this->cur_sign, ""); /* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */ break; case WID_QES_OK: if (RenameSign(this->cur_sign, this->name_editbox.text.buf)) break; /* FALL THROUGH */ case WID_QES_CANCEL: delete this; break; } }
SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) { this->caption = STR_EDIT_SIGN_CAPTION; this->afilter = CS_ALPHANUMERAL; this->InitNested(desc, WN_QUERY_STRING_SIGN); this->LowerWidget(WID_QES_TEXT); UpdateSignEditWindow(si); this->SetFocusedWidget(WID_QES_TEXT); }
SignWindow(WindowDesc *desc, const Sign *si) : Window(desc), name_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) { this->querystrings[WID_QES_TEXT] = &this->name_editbox; this->name_editbox.caption = STR_EDIT_SIGN_CAPTION; this->name_editbox.cancel_button = WID_QES_CANCEL; this->name_editbox.ok_button = WID_QES_OK; this->InitNested(WN_QUERY_STRING_SIGN); UpdateSignEditWindow(si); this->SetFocusedWidget(WID_QES_TEXT); }