Files
@ r17613:a9b2554a5d79
Branch filter:
Location: cpp/openttd-patchpack/source/src/querystring_gui.h - annotation
r17613:a9b2554a5d79
2.6 KiB
text/x-c
(svn r22387) -Fix-ish [FS#4601]: Windows' recv seems to return "graceful closed" before having passed the remaining buffer which causes OpenTTD to think all connections are "incorrectly" terminated, i.e. without the "I'm leaving" packet from the client. So let the client wait a tiny bit after sending the "I'm leaving" packet and before gracefully closing the connection
r9179:660680ae613d r9179:660680ae613d r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9897:9cbe1cc406a0 r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r11081:725ce4237987 r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r13292:ac6cc47d56f5 r11081:725ce4237987 r13292:ac6cc47d56f5 r9179:660680ae613d r9179:660680ae613d r15259:4136e608f02e r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r16665:b1ac123a9a5a r16665:b1ac123a9a5a r16666:196251fd14e5 r9179:660680ae613d r16666:196251fd14e5 r12998:eae10f6a2586 r12998:eae10f6a2586 r12998:eae10f6a2586 r12998:eae10f6a2586 r12998:eae10f6a2586 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9897:9cbe1cc406a0 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r10563:12d6e31fa9ad r10547:46e9c74ed423 r11030:4d8ca8b9bddb r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r13233:9fcdcfbe5992 r9179:660680ae613d r9179:660680ae613d | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file querystring_gui.h Base for the GUIs that have an edit box in them. */
#ifndef QUERYSTRING_GUI_H
#define QUERYSTRING_GUI_H
#include "textbuf_gui.h"
#include "window_gui.h"
/**
* Return values for HandleEditBoxKey
*/
enum HandleEditBoxResult
{
HEBR_EDITING = 0, // Other key pressed.
HEBR_CONFIRM, // Return or enter key pressed.
HEBR_CANCEL, // Escape key pressed.
HEBR_NOT_FOCUSED, // Edit box widget not focused.
};
/**
* Data stored about a string that can be modified in the GUI
*/
struct QueryString {
StringID caption;
Textbuf text;
const char *orig;
CharSetFilter afilter;
bool handled;
/**
* Make sure everything gets initialized properly.
*/
QueryString() : orig(NULL)
{
}
/**
* Make sure everything gets freed.
*/
~QueryString()
{
free((void*)this->orig);
}
private:
bool HasEditBoxFocus(const Window *w, int wid) const;
public:
void DrawEditBox(Window *w, int wid);
void HandleEditBox(Window *w, int wid);
HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, EventState &state);
};
struct QueryStringBaseWindow : public Window, public QueryString {
char *edit_str_buf; ///< Buffer for string.
const uint16 edit_str_size; ///< Maximum length of string (in bytes), including terminating '\0'.
const uint16 max_chars; ///< Maximum length of string (in characters), including terminating '\0'.
QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), edit_str_size(size), max_chars(chars == UINT16_MAX ? size : chars)
{
assert(size != 0);
this->edit_str_buf = CallocT<char>(size);
}
~QueryStringBaseWindow()
{
free(this->edit_str_buf);
}
void DrawEditBox(int wid);
void HandleEditBox(int wid);
HandleEditBoxResult HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
virtual void OnOpenOSKWindow(int wid);
virtual void OnOSKInput(int wid) {}
};
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);
void UpdateOSKOriginalText(const QueryStringBaseWindow *parent, int button);
#endif /* QUERYSTRING_GUI_H */
|