File: gui_dialog.h

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (185 lines) | stat: -rw-r--r-- 7,406 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef M4_GUI_GUI_DIALOG_H
#define M4_GUI_GUI_DIALOG_H

#include "m4/m4_types.h"
#include "m4/graphics/gr_buff.h"
#include "m4/gui/gui.h"
#include "m4/gui/gui_item.h"
#include "m4/gui/gui_univ.h"

namespace M4 {

enum {
	TS_GIVEN = 0, TS_JUST_LEFT, TS_JUST_RIGHT, TS_CENTRE
};

struct Dialog {
	int32   w, h;
	int32   num_items;
	Item *itemList;
	Item *listBottom;
	Item *cancel_item, *return_item, *default_item;
	GrBuff *dlgBuffer;

	// General support methods
	void destroy();
	void refresh();
	void resize(int32 newW, int32 newH);
	void configure(int32 defaultTag, int32 returnTag, int32 cancelTag);
	void setDefault(int32 tag);
	bool setPressed(int32 tag);
	void show();

	// Add methods
	bool addMessage(int32 x, int32 y, const char *prompt, int32 tag);
	bool addPicture(int32 x, int32 y, Buffer *myBuff, int32 tag);
	bool addButton(int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
	bool addRepeatButton(int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
	bool addList(int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag);

	// Item Fields
	Item *getItem(int32 tag);
	void changeItemPrompt(const char *newPrompt, Item *myItem, int32 tag);
	bool removeItem(Item *myItem, int32 tag);
	void refreshItem(Item *myItem, int32 tag);

	// Text Fields
	bool addTextField(int32 x1, int32 y1, int32 x2, const char *defaultPrompt, M4CALLBACK cb, int32 tag, int32 fieldLength);
	void registerTextField();

};

struct TextScrn {
	int32 w, h;
	int32 textColor;
	int32 textColor_alt1;
	int32 textColor_alt2;
	int32 hiliteColor;
	int32 hiliteColor_alt1;
	int32 hiliteColor_alt2;
	int32 luminance;
	Font *myFont;
	TextItem *myTextItems;
	TextItem *hiliteItem;
	GrBuff *textScrnBuffer;
};

struct Dialog_Globals {
	bool okButton = false;
	//event handler vars
	bool movingScreen = false;
	Item *clickItem = nullptr;
	Item *doubleClickItem = nullptr;
	char listboxSearchStr[80] = { 0 };
};

bool gui_dialog_init();
void gui_dialog_shutdown();

//GENERAL DIALOG SUPPORT
Dialog *DialogCreateAbsolute(int32 x1, int32 y1, int32 x2, int32 y2, uint32 scrnFlags);
Dialog *DialogCreate(M4Rect *r, uint32 scrnFlags);
void vmng_Dialog_Destroy(Dialog *d);     //used only by viewmgr.cpp **DO NOT USE
void DialogDestroy(Dialog *d, M4Rect *r = nullptr);
void Dialog_Refresh(Dialog *d);
void Dialog_Refresh_All();
void Dialog_Resize(Dialog *d, int32 newW, int32 newH);
bool GetDialogCoords(Dialog *d, M4Rect *r);
void Dialog_Configure(Dialog *d, int32 defaultTag, int32 returnTag, int32 cancelTag);
void Dialog_SetDefault(Dialog *d, int32 tag);
bool Dialog_SetPressed(Dialog *d, int32 tag);

//MESSAGE TYPE SUPPORT
bool Dialog_Add_Message(Dialog *d, int32 x, int32 y, const char *prompt, int32 tag);

//PICTURE TYPE SUPPORT
bool Dialog_Add_Picture(Dialog *d, int32 x, int32 y, Buffer *myBuff, int32 tag);

//BUTTON TYPE SUPPORT
bool Dialog_Add_Button(Dialog *d, int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
bool Dialog_Add_RepeatButton(Dialog *d, int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);

//LIST TYPE SUPPORT
bool Dialog_Add_List(Dialog *d, int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag);
bool Dialog_Add_DirList(Dialog *d, int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag, char *myDir, char *myTypes);
bool Dialog_Change_DirList(Dialog *d, Item *myItem, const char *myDir, const char *myTypes);
bool Dialog_Add_List_Item(Dialog *d, Item *myItem, const char *prompt, int32 tag, int32 listTag, int32 addMode, bool refresh);
bool Dialog_Delete_List_Item(Dialog *d, Item *myItem, int32 tag, ListItem *myListItem, int32 listTag);
bool Dialog_Change_List_Item(Dialog *d, Item *myItem, int32 tag, ListItem *myListItem, int32 listTag, char *newPrompt, int32 newListTag, int32 changeMode, bool refresh);
void Dialog_EmptyListBox(Dialog *d, Item *i, int32 tag);
char *Dialog_GetListItemPrompt(Dialog *d, Item *i, int32 tag, int32 listTag);
ListItem *Dialog_GetCurrListItem(Dialog *d, Item *i, int32 tag);
char *Dialog_GetCurrListItemPrompt(Dialog *d, Item *i, int32 tag);
bool Dialog_GetCurrListItemTag(Dialog *d, Item *i, int32 tag, int32 *listTag);
bool Dialog_ListItemExists(Dialog *d, Item *myItem, int32 tag, char *prompt, int32 listTag);
bool Dialog_ListboxSearch(Dialog *d, Item *myItem, int32 tag, int32 searchMode, char *searchStr, int32 parm1);
void Dialog_GetPrevListItem(Dialog *d);
void Dialog_GetNextListItem(Dialog *d);

//TEXTFIELD TYPE SUPPORT
bool Dialog_Add_TextField(Dialog *d, int32 x1, int32 y1, int32 x2, const char *defaultPrompt, M4CALLBACK cb, int32 tag, int32 fieldLength);
void Dialog_RegisterTextField(Dialog *d);

//HOTKEY SUPPORT
bool Dialog_Add_Key(Dialog *d, long myKey, HotkeyCB cb);
bool Dialog_Remove_Key(Dialog *d, long myKey);

//GENERAL ITEM SUPPORT
Item *Dialog_Get_Item(Dialog *d, int32 tag);
void Dialog_Change_Item_Prompt(Dialog *d, const char *newPrompt, Item *myItem, int32 tag);
bool Dialog_Remove_Item(Dialog *d, Item *myItem, int32 tag);
void Dialog_Refresh_Item(Dialog *d, Item *myItem, int32 tag);
void Dialog_KeyMouseCollision();

void Dialog_SystemError(char *s);

bool sizeofGUIelement_border(int16 el_type, int32 *w, int32 *h);
bool sizeofGUIelement_interior(ButtonDrawRec *bdr, M4Rect *myRect);
bool drawGUIelement(ButtonDrawRec *bdr, M4Rect *myRect);

bool custom_drawGUIelement(ButtonDrawRec *bdr, M4Rect *myRect);
bool custom_sizeofGUIelement_border(int16 el_type, int32 *w, int32 *h);
bool custom_sizeofGUIelement_interior(ButtonDrawRec *bdr, M4Rect *myRect);

//----------------------------------------------------------------------------------------
//TEXTSCRN STUFF...
TextScrn *TextScrn_Create(int32 x1, int32 y1, int32 x2, int32 y2, int32 luminance, uint32 scrnFlags,
	int32 textColor, int32 hiliteColor,
	int32 textColor_alt1 = 0, int32 hiliteColor_alt1 = 0,
	int32 textColor_alt2 = 0, int32 hiliteColor_alt2 = 0);
void vmng_TextScrn_Destroy(TextScrn *myTextScrn);
void TextScrn_Destroy(TextScrn *myTextScrn);
void TextScrn_Activate(TextScrn *myTextScrn);
bool TextScrn_Add_Key(TextScrn *myTextScrn, long myKey, HotkeyCB cb);
bool TextScrn_Add_TextItem(TextScrn *myTextScrn, int32 x, int32 y, int32 tag,
	int32 justification, const char *prompt, M4CALLBACK callback);
bool TextScrn_Add_Message(TextScrn *myTextScrn, int32 x, int32 y, int32 tag,
	int32 justification, const char *prompt);
void TextScrn_Change_TextItem(TextScrn *myTextScrn, int32 tag, char *prompt, uint8 color);
void TextScrn_Delete_TextItem(TextScrn *myTextScrn, int32 tag);

} // End of namespace M4

#endif