Make reindent
[krb5.git] / src / windows / identity / ui / credwnd.h
1 /*
2  * Copyright (c) 2005 Massachusetts Institute of Technology
3  *
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:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
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
22  * SOFTWARE.
23  */
24
25 /* $Id$ */
26
27 #ifndef __KHIMAIRA_CREDWND_H
28 #define __KHIMAIRA_CREDWND_H
29
30 #define KHUI_CREDWND_CLASS_NAME L"NetIDMgrCredWnd"
31
32 #define KHUI_CREDWND_FLAG_ATTRNAME L"CredWndFlags"
33
34 extern khm_int32 khui_cw_flag_id;
35
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
41
42 #define CW_EXPSTATE_MASK        0x00000c00
43
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 */
51     khm_int32   attr_id;
52     void *      data;       /* level specific data :
53                                Identity -> handle to identity
54                                Type -> type ID
55                                otherwise -> canonical data buffer
56                             */
57     khm_size    cb_data;
58
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;
63
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_* */
74
75 typedef struct khui_credwnd_row_t {
76     khm_int32   flags;
77     khm_int32   col;
78     khm_handle  data;
79     khm_size idx_start;
80     khm_size idx_end;
81     RECT        r_ext;          /* extents of this row */
82 } khui_credwnd_row;
83
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_* */
90
91 /* row allocation */
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
96
97 typedef struct khui_credwnd_col_t {
98     khm_int32 attr_id;
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;
103     wchar_t * title;
104 } khui_credwnd_col;
105
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
111
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
120
121 /* Custom column attributes (are not kcdb attributes) */
122 #define CW_CA_FLAGS -1
123 #define CW_CANAME_FLAGS L"_CWFlags"
124
125 #define CW_CA_TYPEICON -2
126 #define CW_CANAME_TYPEICON L"_CWTypeIcon"
127
128 #define cw_is_custom_attr(i) ((i)<0)
129
130 typedef struct tag_khui_credwnd_ident {
131
132     khm_handle ident;
133     khm_int32  ident_flags;
134     khm_int32  credtype;
135     wchar_t    name[KCDB_IDENT_MAXCCH_NAME];
136     wchar_t    credtype_name[KCDB_MAXCCH_NAME];
137
138     khm_size   credcount;       /* count of all credentials */
139     khm_size   id_credcount;    /* count of identity credentials
140                                    (credentials that are of the
141                                    identity type */
142     khm_size   init_credcount;  /* count of initial credentials */
143     FILETIME   ft_expire;
144
145 } khui_credwnd_ident;
146
147 #define CW_IDENT_ALLOC_INCR 4
148
149 #define CW_EXP_ROW_MULT 2
150
151 typedef struct khui_credwnd_tbl_t {
152     HWND hwnd;                  /* the window that this table belongs to */
153
154     khm_handle csp_view;        /* handle to the configuration space
155                                    that defined the view */
156
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 */
162
163     HWND hwnd_header;           /* header control */
164     khm_int32 header_height;    /* height of the header */
165     HWND hwnd_notif;            /* notification control */
166
167     khui_credwnd_col * cols;    /* n_cols elements */
168     khui_credwnd_row * rows;    /* n_rows elements */
169     int       n_cols;
170     int       n_total_cols;     /* number of columns actually
171                                    allocated in cols */
172     int       n_rows;
173     int       n_total_rows;     /* number of rows actually allocated
174                                    in rows */
175
176     khui_credwnd_outline * outline;
177
178     khm_int32 flags;            /* combo of KHUI_CW_TBL_* */
179
180     int       cursor_row;       /* cursor and selection */
181     int       anchor_row;       /* anchor, for range selections */
182
183     /* view parameters */
184     khm_int32 hpad;
185     khm_int32 vpad;
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 */
189
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 */
195
196     HBRUSH hb_normal;       /* normal background brush */
197     HBRUSH hb_grey;         /* normal background brush (greyed) */
198     HBRUSH hb_s;            /* normal background brush (selected) */
199
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) */
205
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) */
211
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) */
218
219     COLORREF cr_hdr_outline;/* header outline color */
220
221     HCURSOR hc_hand;        /* the HAND cursor */
222     khui_ilist * ilist;     /* image list */
223
224     HICON   hi_lg_ident;    /* large identity icon */
225
226     /* mouse state */
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 */
230
231     khui_bitmap kbm_logo_shade;
232
233     /* the credentials set */
234     khm_handle credset;
235
236     khui_credwnd_ident * idents;
237     khm_size n_idents;
238     khm_size nc_idents;
239
240     khm_int32 view_all_idents;
241
242 } khui_credwnd_tbl;
243
244 #define KHUI_MAXCB_HEADING 256
245
246 /* table flags */
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
255
256 /* mouse_state constants */
257 #define CW_MOUSE_NONE       0x00000000 /* nothing interesting */
258 #define CW_MOUSE_WIDGET     0x00000001 /* mouse is highlighting a
259                                           widget */
260 #define CW_MOUSE_LDOWN      0x00000002 /* left button is down */
261 #define CW_MOUSE_ROW        0x00000004 /* mouse is acive over a valid
262                                           row */
263 #define CW_MOUSE_WOUTLINE   0x00000008 /* mouse is highlighting an
264                                           outline widget */
265 #define CW_MOUSE_WSTICKY    0x00000010 /* mouse is highlighting a
266                                           sticky widget */
267 #define CW_MOUSE_WICON      0x00000020 /* an icon widget.  represents
268                                           the icon next to identities
269                                           and next to credentials. */
270
271 #define CW_MOUSE_WMASK      0x00000039 /* all widget bits */
272
273 void khm_unregister_credwnd_class(void);
274
275 void khm_register_credwnd_class(void);
276
277 HWND khm_create_credwnd(HWND parent);
278
279 LRESULT CALLBACK khm_credwnd_proc(HWND hwnd,
280     UINT uMsg,
281     WPARAM wParam,
282     LPARAM lParam
283     );
284
285 void    cw_load_view(khui_credwnd_tbl * tbl, wchar_t * viewname, HWND hwnd);
286
287 void    cw_update_creds(khui_credwnd_tbl * tbl);
288
289 void    cw_unload_view(khui_credwnd_tbl * tbl);
290
291 void    cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi);
292
293 int     cw_update_extents(khui_credwnd_tbl * tbl, khm_boolean update_scroll);
294
295 void    cw_insert_header_cols(khui_credwnd_tbl * tbl);
296
297 void    khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default,
298                                 LOGFONT * pfont);
299
300 void    khm_set_cw_element_font(wchar_t * name, LOGFONT * pfont);
301
302 void    khm_draw_identity_menu_item(HWND hwnd, LPDRAWITEMSTRUCT lpd, khui_action * act);
303
304 void    khm_measure_identity_menu_item(HWND hwnd, LPMEASUREITEMSTRUCT lpm, khui_action * act);
305
306 #endif