1 /*!
2  * \file
3  * \ingroup notepad_window
4  * \brief   Handling of the in-game notepad.
5  */
6 #ifndef __NOTEPAD_H__
7 #define __NOTEPAD_H__
8 
9 #include "widgets.h"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 extern int popup_win;      /*!< ID of the popup window */
16 extern int notepad_loaded; /*!< boolean flag, indicating whether the notepad was loaded before. */
17 
18 /* state structure for an input popup window */
19 typedef struct
20 {
21 	int popup_win, parent, popup_field, popup_line, popup_label, popup_ok, popup_no;
22 	int maxlen, cols, rows, x, y;
23 	int accept_do_not_close, allow_nonprint_chars;
24 	void (*popup_cancel)(void *);
25 	void (*popup_input)(const char *, void *);
26 	Uint32 text_flags;
27 	text_message popup_text;
28 	unsigned char* popup_line_text;
29 	void *data;
30 } INPUT_POPUP;
31 
32 /*!
33  * \ingroup notepad_window
34  * \brief   Initialise an input popup state structure
35  *
36  *      Initialise an input popup state structure using the given values.
37  *
38  * \param ipu    	pointer to the input popup window state structure
39  * \param parent    id of the parent window
40  * \param maxlen    the maximum length of the popup window text.
41  * \param rows      number of rows for the text widget
42  * \param cols      number of chars columns for the text widget
43  * \param cancel	callback function if the window is cancelled (or NULL)
44  * \param input		callback function to pass entered text (or (unusefully) NULL)
45  * \callgraph
46  */
47 void init_ipu (INPUT_POPUP *ipu, int parent, int maxlen, int rows, int cols, void cancel(void *), void input(const char *, void *));
48 
49 /*!
50  * \ingroup notepad_window
51  * \brief   Hides and clears an open pop up window.
52  *
53  *      Hides and clears an open pop up window.
54  *
55  * \param ipu    	pointer to the input popup window state structure
56  * \callgraph
57  */
58 void clear_popup_window (INPUT_POPUP *ipu);
59 
60 /*!
61  * \ingroup notepad_window
62  * \brief   Closes any open window.
63  *
64  *      Closes any open input popup window and frees the text buffer.
65  *
66  * \param ipu    	pointer to the input popup window state structure
67  * \callgraph
68  */
69 void close_ipu (INPUT_POPUP *ipu);
70 
71 /*!
72  * \ingroup notepad_window
73  * \brief   Displays a popup window
74  *
75  *      Displays a popup window using the given \a label.
76  *
77  * \param ipu    	pointer to the input popup window state structure
78  * \param label     the label of the popup window
79  * \callgraph
80  */
81 void display_popup_win (INPUT_POPUP *ipu, const char* label);
82 
83 /*!
84  * \ingroup notepad_window
85  * \brief   Centres the popup window to parent window
86  *
87  *      Centres the popup window to parent window.
88  *
89  * \param ipu    	pointer to the input popup window state structure
90  * \callgraph
91  */
92 void centre_popup_window (INPUT_POPUP *ipu);
93 
94 /*!
95  * \ingroup notepad_window
96  * \brief   Displays the in-game notepad.
97  *
98  *      Displays the in-game notepad within the tabbed window.
99  *
100  * \callgraph
101  */
102 void fill_notepad_window(int window_id);
103 
104 /*!
105  * \ingroup notepad_window
106  * \brief   Saves the current content of the notepad window into a default file.
107  *
108  *      Saves the current notepad content into the file notes.xml.
109  *
110  * \retval int  always 1
111  */
112 int notepad_save_file(void);
113 
114 #ifdef __cplusplus
115 } // extern "C"
116 #endif
117 
118 #endif
119