1 #ifndef EL__BFU_HIERBOX_H
2 #define EL__BFU_HIERBOX_H
4 #include "bfu/common.h"
5 #include "bfu/listbox.h"
6 #include "util/lists.h"
10 /** BFU hierbox browser button */
11 struct hierbox_browser_button
{
12 /** The button label text
13 * It is automatically localized. */
16 /** The button handler
17 * The handler gets called when the button is activated */
18 widget_handler_T
*handler
;
20 /** Allow this button in anonymous mode
21 * Should the button be displayed in anonymous mode or not? This
22 * can be used to disable actions that are not safe in anonymous
24 unsigned int anonymous
:1;
27 /** BFU hierbox browser
29 * Hierarchic listbox browsers are used for the various (subsystem)
30 * managers. They basically consist of some state data maintained
31 * throughout the life of the dialog (i.e. the listbox widget),
32 * manager specific operations (for modifying the underlying data
33 * structures), and some buttons.
35 struct hierbox_browser
{
36 /** The title of the browser
37 * Note, it is automatically localized. */
40 /** Callback for (un)expansion of the listboxes
41 * Can be used by subsystems to install a handler to be called
42 * when listboxes are expanded and unexpanded. */
43 void (*expansion_callback
)(void);
45 /** Array of browser buttons
47 * Each button represents an action for modifying or interacting
48 * with the items in the manager.
50 * A close button will be installed by default. */
51 const struct hierbox_browser_button
*buttons
;
52 /** The number of browser buttons */
55 /** List of active listbox containers
57 * Several instantiations of a manager can exist at the same
58 * time, if the user has more than one terminal open. This list
59 * contains all the listbox contains for this particular manager
60 * that are currently open. */
61 LIST_OF(struct listbox_data
) boxes
;
62 /** List of active dialogs
64 * Several instantiations of a manager can exist at the same
65 * time, if the user has more than one terminal open. This list
66 * contains all the manager dialogs for this particular manager
67 * that are currently open. */
68 LIST_OF(struct hierbox_dialog_list_item
) dialogs
;
71 * The ancestor of all listboxes in this listbox browser. */
72 struct listbox_item root
;
74 /** Browser specific listbox operations
75 * The operations for managing the underlying data structures of
77 const struct listbox_ops
*ops
;
79 /** State saved between invocations
80 * Each time the browser is closed, its current state is saved
81 * in this member so it can be restored when the browser is
82 * opened again. This way the currently selected item can be
83 * preserved across several interactions with the browser. */
84 struct listbox_data box_data
;
85 /** Option for not saving the state
86 * Some browsers with highly dynamic content should not have
87 * their state restored. This member can be used to mark such
89 unsigned int do_not_save_state
:1;
92 /** Define a hierbox browser
93 * This macro takes care of initializing all the fields of a hierbox
94 * browser so it is ready to use. */
95 #define struct_hierbox_browser(name, title, buttons, ops) \
96 struct hierbox_browser name = { \
100 sizeof_array(buttons), \
101 { D_LIST_HEAD(name.boxes) }, \
102 { D_LIST_HEAD(name.dialogs) }, \
105 { D_LIST_HEAD(name.root.child) }, \
114 struct hierbox_dialog_list_item
{
115 LIST_HEAD(struct hierbox_dialog_list_item
);
117 struct dialog_data
*dlg_data
;
120 void done_listbox_item(struct hierbox_browser
*browser
, struct listbox_item
*item
);
121 void update_hierbox_browser(struct hierbox_browser
*browser
);
123 struct listbox_item
*
124 add_listbox_item(struct hierbox_browser
*browser
, struct listbox_item
*root
,
125 enum listbox_item_type type
, void *data
, int add_position
);
127 #define add_listbox_folder(browser, root,data) \
128 add_listbox_item(browser, root, BI_FOLDER, data, 1)
130 #define add_listbox_leaf(browser, root, data) \
131 add_listbox_item(browser, root, BI_LEAF, data, 1)
133 /** Open a hierbox browser
134 * Opens an instantiation of a hierbox browser
136 * @param browser The browser to open.
137 * @param ses The session (and terminal) on which it should appear.
138 * @return A reference to the dialog that was created or NULL.
141 hierbox_browser(struct hierbox_browser
*browser
, struct session
*ses
);
143 widget_handler_status_T
push_hierbox_info_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
144 widget_handler_status_T
push_hierbox_goto_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
145 widget_handler_status_T
push_hierbox_delete_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
146 widget_handler_status_T
push_hierbox_clear_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
147 widget_handler_status_T
push_hierbox_search_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);