ScummVM API documentation
gui_dialog.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef M4_GUI_GUI_DIALOG_H
24 #define M4_GUI_GUI_DIALOG_H
25 
26 #include "m4/m4_types.h"
27 #include "m4/graphics/gr_buff.h"
28 #include "m4/gui/gui.h"
29 #include "m4/gui/gui_item.h"
30 #include "m4/gui/gui_univ.h"
31 
32 namespace M4 {
33 
34 enum {
35  TS_GIVEN = 0, TS_JUST_LEFT, TS_JUST_RIGHT, TS_CENTRE
36 };
37 
38 struct Dialog {
39  int32 w, h;
40  int32 num_items;
41  Item *itemList;
42  Item *listBottom;
43  Item *cancel_item, *return_item, *default_item;
44  GrBuff *dlgBuffer;
45 
46  // General support methods
47  void destroy();
48  void refresh();
49  void resize(int32 newW, int32 newH);
50  void configure(int32 defaultTag, int32 returnTag, int32 cancelTag);
51  void setDefault(int32 tag);
52  bool setPressed(int32 tag);
53  void show();
54 
55  // Add methods
56  bool addMessage(int32 x, int32 y, const char *prompt, int32 tag);
57  bool addPicture(int32 x, int32 y, Buffer *myBuff, int32 tag);
58  bool addButton(int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
59  bool addRepeatButton(int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
60  bool addList(int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag);
61 
62  // Item Fields
63  Item *getItem(int32 tag);
64  void changeItemPrompt(const char *newPrompt, Item *myItem, int32 tag);
65  bool removeItem(Item *myItem, int32 tag);
66  void refreshItem(Item *myItem, int32 tag);
67 
68  // Text Fields
69  bool addTextField(int32 x1, int32 y1, int32 x2, const char *defaultPrompt, M4CALLBACK cb, int32 tag, int32 fieldLength);
70  void registerTextField();
71 
72 };
73 
74 struct TextScrn {
75  int32 w, h;
76  int32 textColor;
77  int32 textColor_alt1;
78  int32 textColor_alt2;
79  int32 hiliteColor;
80  int32 hiliteColor_alt1;
81  int32 hiliteColor_alt2;
82  int32 luminance;
83  Font *myFont;
84  TextItem *myTextItems;
85  TextItem *hiliteItem;
86  GrBuff *textScrnBuffer;
87 };
88 
90  bool okButton = false;
91  //event handler vars
92  bool movingScreen = false;
93  Item *clickItem = nullptr;
94  Item *doubleClickItem = nullptr;
95  char listboxSearchStr[80] = { 0 };
96 };
97 
98 bool gui_dialog_init();
99 void gui_dialog_shutdown();
100 
101 //GENERAL DIALOG SUPPORT
102 Dialog *DialogCreateAbsolute(int32 x1, int32 y1, int32 x2, int32 y2, uint32 scrnFlags);
103 Dialog *DialogCreate(M4Rect *r, uint32 scrnFlags);
104 void vmng_Dialog_Destroy(Dialog *d); //used only by viewmgr.cpp **DO NOT USE
105 void DialogDestroy(Dialog *d, M4Rect *r = nullptr);
106 void Dialog_Refresh(Dialog *d);
107 void Dialog_Refresh_All();
108 void Dialog_Resize(Dialog *d, int32 newW, int32 newH);
109 bool GetDialogCoords(Dialog *d, M4Rect *r);
110 void Dialog_Configure(Dialog *d, int32 defaultTag, int32 returnTag, int32 cancelTag);
111 void Dialog_SetDefault(Dialog *d, int32 tag);
112 bool Dialog_SetPressed(Dialog *d, int32 tag);
113 
114 //MESSAGE TYPE SUPPORT
115 bool Dialog_Add_Message(Dialog *d, int32 x, int32 y, const char *prompt, int32 tag);
116 
117 //PICTURE TYPE SUPPORT
118 bool Dialog_Add_Picture(Dialog *d, int32 x, int32 y, Buffer *myBuff, int32 tag);
119 
120 //BUTTON TYPE SUPPORT
121 bool Dialog_Add_Button(Dialog *d, int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
122 bool Dialog_Add_RepeatButton(Dialog *d, int32 x, int32 y, const char *prompt, M4CALLBACK cb, int32 tag);
123 
124 //LIST TYPE SUPPORT
125 bool Dialog_Add_List(Dialog *d, int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag);
126 bool Dialog_Add_DirList(Dialog *d, int32 x1, int32 y1, int32 x2, int32 y2, M4CALLBACK cb, int32 tag, char *myDir, char *myTypes);
127 bool Dialog_Change_DirList(Dialog *d, Item *myItem, const char *myDir, const char *myTypes);
128 bool Dialog_Add_List_Item(Dialog *d, Item *myItem, const char *prompt, int32 tag, int32 listTag, int32 addMode, bool refresh);
129 bool Dialog_Delete_List_Item(Dialog *d, Item *myItem, int32 tag, ListItem *myListItem, int32 listTag);
130 bool Dialog_Change_List_Item(Dialog *d, Item *myItem, int32 tag, ListItem *myListItem, int32 listTag, char *newPrompt, int32 newListTag, int32 changeMode, bool refresh);
131 void Dialog_EmptyListBox(Dialog *d, Item *i, int32 tag);
132 char *Dialog_GetListItemPrompt(Dialog *d, Item *i, int32 tag, int32 listTag);
133 ListItem *Dialog_GetCurrListItem(Dialog *d, Item *i, int32 tag);
134 char *Dialog_GetCurrListItemPrompt(Dialog *d, Item *i, int32 tag);
135 bool Dialog_GetCurrListItemTag(Dialog *d, Item *i, int32 tag, int32 *listTag);
136 bool Dialog_ListItemExists(Dialog *d, Item *myItem, int32 tag, char *prompt, int32 listTag);
137 bool Dialog_ListboxSearch(Dialog *d, Item *myItem, int32 tag, int32 searchMode, char *searchStr, int32 parm1);
138 void Dialog_GetPrevListItem(Dialog *d);
139 void Dialog_GetNextListItem(Dialog *d);
140 
141 //TEXTFIELD TYPE SUPPORT
142 bool Dialog_Add_TextField(Dialog *d, int32 x1, int32 y1, int32 x2, const char *defaultPrompt, M4CALLBACK cb, int32 tag, int32 fieldLength);
143 void Dialog_RegisterTextField(Dialog *d);
144 
145 //HOTKEY SUPPORT
146 bool Dialog_Add_Key(Dialog *d, long myKey, HotkeyCB cb);
147 bool Dialog_Remove_Key(Dialog *d, long myKey);
148 
149 //GENERAL ITEM SUPPORT
150 Item *Dialog_Get_Item(Dialog *d, int32 tag);
151 void Dialog_Change_Item_Prompt(Dialog *d, const char *newPrompt, Item *myItem, int32 tag);
152 bool Dialog_Remove_Item(Dialog *d, Item *myItem, int32 tag);
153 void Dialog_Refresh_Item(Dialog *d, Item *myItem, int32 tag);
154 void Dialog_KeyMouseCollision();
155 
156 void Dialog_SystemError(char *s);
157 
158 bool sizeofGUIelement_border(int16 el_type, int32 *w, int32 *h);
159 bool sizeofGUIelement_interior(ButtonDrawRec *bdr, M4Rect *myRect);
160 bool drawGUIelement(ButtonDrawRec *bdr, M4Rect *myRect);
161 
162 bool custom_drawGUIelement(ButtonDrawRec *bdr, M4Rect *myRect);
163 bool custom_sizeofGUIelement_border(int16 el_type, int32 *w, int32 *h);
164 bool custom_sizeofGUIelement_interior(ButtonDrawRec *bdr, M4Rect *myRect);
165 
166 //----------------------------------------------------------------------------------------
167 //TEXTSCRN STUFF...
168 TextScrn *TextScrn_Create(int32 x1, int32 y1, int32 x2, int32 y2, int32 luminance, uint32 scrnFlags,
169  int32 textColor, int32 hiliteColor,
170  int32 textColor_alt1 = 0, int32 hiliteColor_alt1 = 0,
171  int32 textColor_alt2 = 0, int32 hiliteColor_alt2 = 0);
172 void vmng_TextScrn_Destroy(TextScrn *myTextScrn);
173 void TextScrn_Destroy(TextScrn *myTextScrn);
174 void TextScrn_Activate(TextScrn *myTextScrn);
175 bool TextScrn_Add_Key(TextScrn *myTextScrn, long myKey, HotkeyCB cb);
176 bool TextScrn_Add_TextItem(TextScrn *myTextScrn, int32 x, int32 y, int32 tag,
177  int32 justification, const char *prompt, M4CALLBACK callback);
178 bool TextScrn_Add_Message(TextScrn *myTextScrn, int32 x, int32 y, int32 tag,
179  int32 justification, const char *prompt);
180 void TextScrn_Change_TextItem(TextScrn *myTextScrn, int32 tag, char *prompt, uint8 color);
181 void TextScrn_Delete_TextItem(TextScrn *myTextScrn, int32 tag);
182 
183 } // End of namespace M4
184 
185 #endif
Definition: gui_dialog.h:74
Definition: gr_font.h:30
Definition: gui_item.h:62
Definition: gui_dialog.h:89
Definition: gui_item.h:69
Definition: gui_item.h:82
Definition: gui_univ.h:59
Definition: m4_types.h:67
Definition: database.h:28
Definition: gr_buff.h:30
Definition: gui_dialog.h:38
Definition: gui.h:52