1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-09-01 10:59:12 +00:00

(svn r24731) -Codechange: Remove OnOpenOSKWindow and instead specify OK and CANCEL buttons via QueryString members.

This commit is contained in:
frosch
2012-11-13 21:46:54 +00:00
parent 67f92f16ed
commit fd55399167
7 changed files with 20 additions and 49 deletions

View File

@@ -36,13 +36,11 @@ struct OskWindow : public Window {
StringID caption; ///< the caption for this window.
QueryString *qs; ///< text-input
int text_btn; ///< widget number of parent's text field
int ok_btn; ///< widget number of parent's ok button (-1 when ok shouldn't be passed on)
int cancel_btn; ///< widget number of parent's cancel button (-1 when cancel shouldn't be passed on; text will be reverted to original)
Textbuf *text; ///< pointer to parent's textbuffer (to update caret position)
char *orig_str_buf; ///< Original string.
bool shift; ///< Is the shift effectively pressed?
OskWindow(const WindowDesc *desc, QueryStringBaseWindow *parent, int button, int cancel, int ok) : Window()
OskWindow(const WindowDesc *desc, QueryStringBaseWindow *parent, int button) : Window()
{
this->parent = parent;
assert(parent != NULL);
@@ -53,8 +51,6 @@ struct OskWindow : public Window {
this->qs = parent;
this->text_btn = button;
this->cancel_btn = cancel;
this->ok_btn = ok;
this->text = &parent->text;
/* make a copy in case we need to reset later */
@@ -177,8 +173,8 @@ struct OskWindow : public Window {
case WID_OSK_OK:
if (this->qs->orig == NULL || strcmp(this->qs->text.buf, this->qs->orig) != 0) {
/* pass information by simulating a button press on parent window */
if (this->ok_btn >= 0) {
this->parent->OnClick(pt, this->ok_btn, 1);
if (this->qs->ok_button >= 0) {
this->parent->OnClick(pt, this->qs->ok_button, 1);
/* Window gets deleted when the parent window removes itself. */
return;
}
@@ -187,8 +183,8 @@ struct OskWindow : public Window {
break;
case WID_OSK_CANCEL:
if (this->cancel_btn >= 0) { // pass a cancel event to the parent window
this->parent->OnClick(pt, this->cancel_btn, 1);
if (this->qs->cancel_button >= 0) { // pass a cancel event to the parent window
this->parent->OnClick(pt, this->qs->cancel_button, 1);
/* Window gets deleted when the parent window removes itself. */
return;
} else { // or reset to original string
@@ -428,17 +424,13 @@ void GetKeyboardLayout()
* Show the on-screen keyboard (osk) associated with a given textbox
* @param parent pointer to the Window where this keyboard originated from
* @param button widget number of parent's textbox
* @param cancel widget number of parent's cancel button (-1 if cancel events
* should not be passed)
* @param ok widget number of parent's ok button (-1 if ok events should not
* be passed)
*/
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok)
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button)
{
DeleteWindowById(WC_OSK, 0);
GetKeyboardLayout();
new OskWindow(&_osk_desc, parent, button, cancel, ok);
new OskWindow(&_osk_desc, parent, button);
}
/**