2 * Copyright (c) 2005 Massachusetts Institute of Technology
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 #ifndef __KHIMAIRA_CREDWND_H
28 #define __KHIMAIRA_CREDWND_H
30 #define KHUI_CREDWND_CLASS_NAME L"NetIDMgrCredWnd"
32 #define KHUI_CREDWND_FLAG_ATTRNAME L"CredWndFlags"
34 extern khm_int32 khui_cw_flag_id;
36 /* The expiration states */
37 #define CW_EXPSTATE_NONE 0x00000000
38 #define CW_EXPSTATE_WARN 0x00000400
39 #define CW_EXPSTATE_CRITICAL 0x00000800
40 #define CW_EXPSTATE_EXPIRED 0x00000c00
42 #define CW_EXPSTATE_MASK 0x00000c00
44 typedef struct khui_credwnd_outline_t {
45 khm_int32 flags; /* combination of KHUI_CW_O_* */
46 khm_int32 start; /* first row of outline */
47 khm_int32 length; /* number of rows in outline */
48 khm_int32 level; /* outline level */
49 khm_int32 col; /* outline column */
50 wchar_t *header; /* character string associated with header */
52 void * data; /* level specific data :
53 Identity -> handle to identity
55 otherwise -> canonical data buffer
59 khm_size idx_start; /* index of the first cred in the credset */
60 khm_size idx_end; /* index of the last cred in the credset */
61 TDCL(struct khui_credwnd_outline_t);
62 } khui_credwnd_outline;
64 #define KHUI_CW_O_EXPAND 0x00000001
65 #define KHUI_CW_O_STICKY 0x00000002
66 #define KHUI_CW_O_VISIBLE 0x00000004
67 #define KHUI_CW_O_SHOWFLAG 0x00000008
68 #define KHUI_CW_O_SELECTED 0x00000010
69 #define KHUI_CW_O_DATAALLOC 0x00000020
70 #define KHUI_CW_O_NOOUTLINE 0x00000040
71 #define KHUI_CW_O_RELIDENT 0x00000080
72 #define KHUI_CW_O_EMPTY 0x00000100
73 /* NOTE: KHUI_CW_O_* shares the same bit-space as CW_EXPSTATE_* */
75 typedef struct khui_credwnd_row_t {
81 RECT r_ext; /* extents of this row */
84 #define KHUI_CW_ROW_CRED 0x00000002
85 #define KHUI_CW_ROW_HEADER 0x00000004
86 #define KHUI_CW_ROW_TIMERSET 0x00000008
87 #define KHUI_CW_ROW_SELECTED 0x00000010
88 #define KHUI_CW_ROW_EXPVIEW 0x00000020
89 /* NOTE: KHUI_CW_ROW_* shares the same bit-space as CW_EXPSTATE_* */
92 /* initial number of rows to be allocated */
93 #define KHUI_CW_ROW_INITIAL 512
94 /* allocation increment, if we run out of space */
95 #define KHUI_CW_ROW_INCREMENT 512
97 typedef struct khui_credwnd_col_t {
99 khm_int32 width; /* width of the column (screen units) */
100 khm_int32 x; /* starting x coordinate (screen units) */
101 khm_int32 flags; /* combination of KHUI_CW_COL_* */
102 khm_int32 sort_index;
106 /* column allocation */
107 /* initial number of columns to be allocated */
108 #define KHUI_CW_COL_INITIAL 16
109 /* allocation increment, if we run out of space */
110 #define KHUI_CW_COL_INCREMENT 16
112 #define KHUI_CW_COL_AUTOSIZE 0x00000001
113 #define KHUI_CW_COL_SORT_INC 0x00000002
114 #define KHUI_CW_COL_SORT_DEC 0x00000004
115 #define KHUI_CW_COL_GROUP 0x00000008
116 #define KHUI_CW_COL_FIXED_WIDTH 0x00000010
117 #define KHUI_CW_COL_FIXED_POS 0x00000020
118 #define KHUI_CW_COL_META 0x00000040
119 #define KHUI_CW_COL_FILLER 0x00000080
121 /* Custom column attributes (are not kcdb attributes) */
122 #define CW_CA_FLAGS -1
123 #define CW_CANAME_FLAGS L"_CWFlags"
125 #define CW_CA_TYPEICON -2
126 #define CW_CANAME_TYPEICON L"_CWTypeIcon"
128 #define cw_is_custom_attr(i) ((i)<0)
130 typedef struct tag_khui_credwnd_ident {
133 khm_int32 ident_flags;
135 wchar_t name[KCDB_IDENT_MAXCCH_NAME];
136 wchar_t credtype_name[KCDB_MAXCCH_NAME];
138 khm_size credcount; /* count of all credentials */
139 khm_size id_credcount; /* count of identity credentials
140 (credentials that are of the
142 khm_size init_credcount; /* count of initial credentials */
145 } khui_credwnd_ident;
147 #define CW_IDENT_ALLOC_INCR 4
149 #define CW_EXP_ROW_MULT 2
151 typedef struct khui_credwnd_tbl_t {
152 HWND hwnd; /* the window that this table belongs to */
154 khm_handle csp_view; /* handle to the configuration space
155 that defined the view */
157 khm_int32 scr_top; /* screen units */
158 khm_int32 scr_left; /* screen units */
159 khm_int32 ext_width; /* screen units */
160 khm_int32 ext_height; /* screen units */
161 khm_int32 cell_height; /* screen units */
163 HWND hwnd_header; /* header control */
164 khm_int32 header_height; /* height of the header */
165 HWND hwnd_notif; /* notification control */
167 khui_credwnd_col * cols; /* n_cols elements */
168 khui_credwnd_row * rows; /* n_rows elements */
170 int n_total_cols; /* number of columns actually
173 int n_total_rows; /* number of rows actually allocated
176 khui_credwnd_outline * outline;
178 khm_int32 flags; /* combo of KHUI_CW_TBL_* */
180 int cursor_row; /* cursor and selection */
181 int anchor_row; /* anchor, for range selections */
183 /* view parameters */
186 khm_int32 hpad_h; /* horizontal padding correction for headers */
187 khm_int32 threshold_warn; /* Warning threshold, in seconds*/
188 khm_int32 threshold_critical; /* Critical threshold, in seconds */
190 /* graphics objects we are going to need. */
191 HFONT hf_normal; /* normal text */
192 HFONT hf_header; /* header text */
193 HFONT hf_bold; /* bold text */
194 HFONT hf_bold_header; /* bold header text */
196 HBRUSH hb_normal; /* normal background brush */
197 HBRUSH hb_grey; /* normal background brush (greyed) */
198 HBRUSH hb_s; /* normal background brush (selected) */
200 HBRUSH hb_hdr_bg; /* header background brush (normal) */
201 HBRUSH hb_hdr_bg_cred; /* header background brush (valid creds) */
202 HBRUSH hb_hdr_bg_exp; /* header background brush (expired) */
203 HBRUSH hb_hdr_bg_warn; /* header background brush (warn) */
204 HBRUSH hb_hdr_bg_crit; /* header background brush (critical) */
206 HBRUSH hb_hdr_bg_s; /* header background brush (selected) */
207 HBRUSH hb_hdr_bg_cred_s;/* header background brush (valid creds) */
208 HBRUSH hb_hdr_bg_exp_s; /* header background brush (expired,selected) */
209 HBRUSH hb_hdr_bg_warn_s;/* header background brush (warn,selected) */
210 HBRUSH hb_hdr_bg_crit_s;/* header background brush (critical,selected) */
212 COLORREF cr_normal; /* text color (normal) */
213 COLORREF cr_s; /* text color (selected) */
214 COLORREF cr_hdr_normal; /* header text color (normal) */
215 COLORREF cr_hdr_s; /* header text color (selected) */
216 COLORREF cr_hdr_gray; /* header text color (greyed) */
217 COLORREF cr_hdr_gray_s; /* header text color (greyed,selected) */
219 COLORREF cr_hdr_outline;/* header outline color */
221 HCURSOR hc_hand; /* the HAND cursor */
222 khui_ilist * ilist; /* image list */
224 HICON hi_lg_ident; /* large identity icon */
227 khm_int32 mouse_state; /* state of the mouse can be combo of CW_MOUSE_* values */
228 khm_int32 mouse_row; /* row that the mouse state applies to */
229 khm_int32 mouse_col; /* col that the mouse state applies to */
231 khui_bitmap kbm_logo_shade;
233 /* the credentials set */
236 khui_credwnd_ident * idents;
240 khm_int32 view_all_idents;
244 #define KHUI_MAXCB_HEADING 256
247 #define KHUI_CW_TBL_INITIALIZED 0x00000001
248 #define KHUI_CW_TBL_COL_DIRTY 0x00000002
249 #define KHUI_CW_TBL_ROW_DIRTY 0x00000004
250 #define KHUI_CW_TBL_ACTIVE 0x00000100
251 #define KHUI_CW_TBL_CUSTVIEW 0x00000200
252 #define KHUI_CW_TBL_COLSKIP 0x00000400
253 #define KHUI_CW_TBL_EXPIDENT 0x00000800
254 #define KHUI_CW_TBL_NOHEADER 0x00001000
256 /* mouse_state constants */
257 #define CW_MOUSE_NONE 0x00000000 /* nothing interesting */
258 #define CW_MOUSE_WIDGET 0x00000001 /* mouse is highlighting a
260 #define CW_MOUSE_LDOWN 0x00000002 /* left button is down */
261 #define CW_MOUSE_ROW 0x00000004 /* mouse is acive over a valid
263 #define CW_MOUSE_WOUTLINE 0x00000008 /* mouse is highlighting an
265 #define CW_MOUSE_WSTICKY 0x00000010 /* mouse is highlighting a
267 #define CW_MOUSE_WICON 0x00000020 /* an icon widget. represents
268 the icon next to identities
269 and next to credentials. */
271 #define CW_MOUSE_WMASK 0x00000039 /* all widget bits */
273 void khm_unregister_credwnd_class(void);
275 void khm_register_credwnd_class(void);
277 HWND khm_create_credwnd(HWND parent);
279 LRESULT CALLBACK khm_credwnd_proc(HWND hwnd,
285 void cw_load_view(khui_credwnd_tbl * tbl, wchar_t * viewname, HWND hwnd);
287 void cw_update_creds(khui_credwnd_tbl * tbl);
289 void cw_unload_view(khui_credwnd_tbl * tbl);
291 void cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi);
293 int cw_update_extents(khui_credwnd_tbl * tbl, khm_boolean update_scroll);
295 void cw_insert_header_cols(khui_credwnd_tbl * tbl);
297 void khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default,
300 void khm_set_cw_element_font(wchar_t * name, LOGFONT * pfont);
302 void khm_draw_identity_menu_item(HWND hwnd, LPDRAWITEMSTRUCT lpd, khui_action * act);
304 void khm_measure_identity_menu_item(HWND hwnd, LPMEASUREITEMSTRUCT lpm, khui_action * act);