author | Tero Marttila <terom@fixme.fi> |
Fri, 19 Dec 2008 02:25:44 +0200 | |
branch | terom-mini |
changeset 10442 | 7089fa402bfd |
parent 10276 | b60b7e17db62 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
3 |
/** @file textbuf_gui.h Stuff related to the text buffer GUI. */ |
0 | 4 |
|
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
5 |
#ifndef TEXTBUF_GUI_H |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
6 |
#define TEXTBUF_GUI_H |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1575
diff
changeset
|
7 |
|
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
8 |
#include "window_type.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8124
diff
changeset
|
9 |
#include "string_type.h" |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
10 |
#include "strings_type.h" |
10145
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
11 |
#include "core/enum_type.hpp" |
6670
f0300bf50643
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
6669
diff
changeset
|
12 |
|
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
13 |
struct Textbuf { |
10276
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
14 |
char *buf; ///< buffer in which text is saved |
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
15 |
uint16 maxsize, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxsize is in bytes (including terminating '\0') |
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
16 |
uint16 size, width; ///< the current size of the string. Width specifies screensize in pixels, size is in bytes |
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
17 |
bool caret; ///< is the caret ("_") visible or not |
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
18 |
uint16 caretpos; ///< the current position of the caret in the buffer, in bytes |
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
19 |
uint16 caretxoffs; ///< the current position of the caret in pixels |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1575
diff
changeset
|
20 |
}; |
0 | 21 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
22 |
bool HandleCaret(Textbuf *tb); |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
23 |
|
1879
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1705
diff
changeset
|
24 |
void DeleteTextBufferAll(Textbuf *tb); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
25 |
bool DeleteTextBufferChar(Textbuf *tb, int delmode); |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5044
diff
changeset
|
26 |
bool InsertTextBufferChar(Textbuf *tb, uint32 key); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
27 |
bool InsertTextBufferClipboard(Textbuf *tb); |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
28 |
bool MoveTextBufferPos(Textbuf *tb, int navmode); |
10276
b60b7e17db62
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents:
10148
diff
changeset
|
29 |
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
30 |
void UpdateTextBufferSize(Textbuf *tb); |
0 | 31 |
|
10145
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
32 |
/** Flags used in ShowQueryString() call */ |
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
33 |
enum QueryStringFlags { |
10148
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
34 |
QSF_NONE = 0, |
10145
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
35 |
QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change |
10148
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
36 |
QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned) |
10145
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
37 |
}; |
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
38 |
|
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
39 |
DECLARE_ENUM_AS_BIT_SET(QueryStringFlags) |
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
40 |
|
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
41 |
|
9319
141ca3009ac2
(svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents:
9179
diff
changeset
|
42 |
typedef void QueryCallbackProc(Window*, bool); |
141ca3009ac2
(svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents:
9179
diff
changeset
|
43 |
|
10145
849ba8b8626b
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents:
9319
diff
changeset
|
44 |
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags); |
9319
141ca3009ac2
(svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents:
9179
diff
changeset
|
45 |
void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback); |
0 | 46 |
|
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
47 |
/** The number of 'characters' on the on-screen keyboard. */ |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
48 |
static const uint OSK_KEYBOARD_ENTRIES = 50; |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
49 |
|
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
50 |
/** |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
51 |
* The number of characters has to be OSK_KEYBOARD_ENTRIES. However, these |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
52 |
* have to be UTF-8 encoded, which means up to 4 bytes per character. |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
53 |
* Furthermore the string needs to be '\0'-terminated. |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
54 |
*/ |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
55 |
extern char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1]; |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8214
diff
changeset
|
56 |
|
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
57 |
#endif /* TEXTBUF_GUI_H */ |