~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/ui/toolbar.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:28:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030102853-x7v876vw4af46v0m
Tags: 1.4.4-3ubuntu1
* Merge with Debian; only Ubuntu change:
  - src/include/k5-thread.h: Define__USE_GNU when #include'ing pthread.h to
    fix FTBFS (from 1.4.3-9ubuntu1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2004 Massachusetts Institute of Technology
 
2
 * Copyright (c) 2005 Massachusetts Institute of Technology
3
3
 *
4
4
 * Permission is hereby granted, free of charge, to any person
5
5
 * obtaining a copy of this software and associated documentation
42
42
 
43
43
LRESULT khm_toolbar_notify(LPNMHDR notice) {
44
44
    switch(notice->code) {
45
 
        case NM_CUSTOMDRAW:
46
 
            {
47
 
                LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice;
48
 
                if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) {
49
 
                    return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE;
50
 
                } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) {
51
 
                    return CDRF_NOTIFYPOSTPAINT;
52
 
                } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) {
53
 
                    /* draw the actual icon */
54
 
                    int iidx;
55
 
                    int ibmp;
56
 
                    HBITMAP hbmp;
57
 
                    RECT r;
58
 
 
59
 
                    khui_action * act = 
60
 
                        khui_find_action((int) nmcd->nmcd.dwItemSpec);
61
 
 
62
 
                    if(!act || !act->ib_normal)
63
 
                        return CDRF_DODEFAULT;
64
 
 
65
 
                    if((act->state & KHUI_ACTIONSTATE_DISABLED) && 
66
 
                       act->ib_disabled) {
67
 
                        ibmp = act->ib_disabled;
68
 
                    } else if(act->ib_hot && 
69
 
                              ((nmcd->nmcd.uItemState & CDIS_HOT) || 
70
 
                               (nmcd->nmcd.uItemState & CDIS_SELECTED))){
71
 
                        ibmp = act->ib_hot;
72
 
                    } else {
73
 
                        ibmp = act->ib_normal;
74
 
                    }
75
 
 
76
 
                    iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp);
77
 
                    if(iidx < 0) {
78
 
                        hbmp = LoadImage(khm_hInstance, 
79
 
                                         MAKEINTRESOURCE(ibmp), 
80
 
                                         IMAGE_BITMAP, 
81
 
                                         KHUI_TOOLBAR_IMAGE_WIDTH, 
82
 
                                         KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
83
 
                        iidx = 
84
 
                            khui_ilist_add_masked_id(ilist_toolbar, 
85
 
                                                     hbmp, 
86
 
                                                     KHUI_TOOLBAR_BGCOLOR, 
87
 
                                                     ibmp);
88
 
                        DeleteObject(hbmp);
89
 
                    }
90
 
 
91
 
                    if(iidx < 0)
92
 
                        return CDRF_DODEFAULT;
93
 
 
94
 
                    CopyRect(&r, &(nmcd->nmcd.rc));
95
 
                    r.left += ((r.right - r.left) - 
96
 
                               KHUI_TOOLBAR_IMAGE_WIDTH) / 2;
97
 
                    r.top += ((r.bottom - r.top) -
98
 
                              KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
99
 
 
100
 
                    khui_ilist_draw(ilist_toolbar, 
101
 
                                    iidx, 
102
 
                                    nmcd->nmcd.hdc, 
103
 
                                    r.left,
104
 
                                    r.top, 
105
 
                                    0);
106
 
 
107
 
                    return CDRF_DODEFAULT;
108
 
                }
109
 
            }
110
 
            break;
 
45
    case TBN_GETINFOTIP:
 
46
        {
 
47
            LPNMTBGETINFOTIP git = (LPNMTBGETINFOTIP) notice;
 
48
            int cmd;
 
49
            khui_action * a;
 
50
 
 
51
            cmd = git->iItem;
 
52
            a = khui_find_action(cmd);
 
53
 
 
54
            if (a) {
 
55
                if (a->caption) {
 
56
                    StringCchCopy(git->pszText, git->cchTextMax, a->caption);
 
57
                } else if (a->tooltip) {
 
58
                    StringCchCopy(git->pszText, git->cchTextMax, a->tooltip);
 
59
                } else if (a->is_caption) {
 
60
                    wchar_t buf[INFOTIPSIZE];
 
61
 
 
62
                    buf[0] = L'\0';
 
63
                    LoadString(khm_hInstance, a->is_caption,
 
64
                               buf, ARRAYLENGTH(buf));
 
65
 
 
66
                    StringCchCopy(git->pszText, git->cchTextMax, buf);
 
67
                } else {
 
68
                    StringCchCopy(git->pszText, git->cchTextMax, L"");
 
69
                }
 
70
            } else {
 
71
                StringCchCopy(git->pszText,
 
72
                              git->cchTextMax,
 
73
                              L"");
 
74
            }
 
75
        }
 
76
        break;
 
77
 
 
78
    case TBN_HOTITEMCHANGE:
 
79
        {
 
80
            LPNMTBHOTITEM hi = (LPNMTBHOTITEM) notice;
 
81
 
 
82
            if (hi->dwFlags & HICF_LEAVING) {
 
83
                khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, L"");
 
84
            } else {
 
85
                khui_action * a;
 
86
                int cmd;
 
87
                wchar_t buf[256];
 
88
 
 
89
                cmd = hi->idNew;
 
90
                a = khui_find_action(cmd);
 
91
 
 
92
                buf[0] = L'\0';
 
93
 
 
94
                if (a) {
 
95
                    if (a->tooltip)
 
96
                        StringCbCopy(buf, sizeof(buf), a->tooltip);
 
97
                    else if (a->is_tooltip) {
 
98
                        LoadString(khm_hInstance, a->is_tooltip,
 
99
                                   buf, ARRAYLENGTH(buf));
 
100
                    }
 
101
                }
 
102
 
 
103
                khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);
 
104
            }
 
105
        }
 
106
        break;
 
107
 
 
108
    case NM_CUSTOMDRAW:
 
109
        {
 
110
            LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice;
 
111
            if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) {
 
112
                return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE;
 
113
            } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) {
 
114
                return CDRF_NOTIFYPOSTPAINT;
 
115
            } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) {
 
116
                /* draw the actual icon */
 
117
                int iidx;
 
118
                int ibmp;
 
119
                HBITMAP hbmp;
 
120
                RECT r;
 
121
 
 
122
                khui_action * act = 
 
123
                    khui_find_action((int) nmcd->nmcd.dwItemSpec);
 
124
 
 
125
                if(!act || !act->ib_normal)
 
126
                    return CDRF_DODEFAULT;
 
127
 
 
128
                if((act->state & KHUI_ACTIONSTATE_DISABLED) && 
 
129
                   act->ib_disabled) {
 
130
                    ibmp = act->ib_disabled;
 
131
                } else if(act->ib_hot && 
 
132
                          ((nmcd->nmcd.uItemState & CDIS_HOT) || 
 
133
                           (nmcd->nmcd.uItemState & CDIS_SELECTED))){
 
134
                    ibmp = act->ib_hot;
 
135
                } else {
 
136
                    ibmp = act->ib_normal;
 
137
                }
 
138
 
 
139
                iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp);
 
140
                if(iidx < 0) {
 
141
                    hbmp = LoadImage(khm_hInstance, 
 
142
                                     MAKEINTRESOURCE(ibmp), 
 
143
                                     IMAGE_BITMAP, 
 
144
                                     KHUI_TOOLBAR_IMAGE_WIDTH, 
 
145
                                     KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
 
146
                    iidx = 
 
147
                        khui_ilist_add_masked_id(ilist_toolbar, 
 
148
                                                 hbmp, 
 
149
                                                 KHUI_TOOLBAR_BGCOLOR, 
 
150
                                                 ibmp);
 
151
                    DeleteObject(hbmp);
 
152
                }
 
153
 
 
154
                if(iidx < 0)
 
155
                    return CDRF_DODEFAULT;
 
156
 
 
157
                CopyRect(&r, &(nmcd->nmcd.rc));
 
158
                r.left += ((r.right - r.left) - 
 
159
                           KHUI_TOOLBAR_IMAGE_WIDTH) / 2;
 
160
                r.top += ((r.bottom - r.top) -
 
161
                          KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
 
162
                
 
163
                khui_ilist_draw(ilist_toolbar, 
 
164
                                iidx, 
 
165
                                nmcd->nmcd.hdc, 
 
166
                                r.left,
 
167
                                r.top, 
 
168
                                0);
 
169
 
 
170
                return CDRF_DODEFAULT;
 
171
            }
 
172
        }
 
173
        break;
111
174
    }
112
175
    return 0;
113
176
}
124
187
        bn.fsStyle = BTNS_SEP;
125
188
        bn.iBitmap = 3;
126
189
 
127
 
        lr = SendMessage(
128
 
                         tb,
 
190
        lr = SendMessage(tb,
129
191
                         TB_ADDBUTTONS,
130
192
                         1,
131
193
                         (LPARAM) &bn);
158
220
                                            TB_ADDSTRING,
159
221
                                            (WPARAM) NULL,
160
222
                                            (LPARAM) buf);
 
223
#if (_WIN32_IE >= 0x0501)
161
224
            bn.fsStyle |= BTNS_SHOWTEXT;
 
225
#endif
162
226
            bn.iString = idx_caption;
163
227
        }
164
228
    }
170
234
    if((opt & KHUI_TOOLBAR_ADD_BITMAP) && a->ib_normal) {
171
235
        bn.fsStyle |= TBSTYLE_CUSTOMERASE;
172
236
        bn.iBitmap = khui_tb_blank;
173
 
    } else
 
237
    } else {
 
238
#if (_WIN32_IE >= 0x0501)
174
239
        bn.iBitmap = I_IMAGENONE;
 
240
#endif
 
241
    }
175
242
 
176
243
    bn.idCommand = a->cmd;
177
244
 
242
309
 
243
310
    def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
244
311
 
245
 
    hwtb = CreateWindowEx(
246
 
        TBSTYLE_EX_MIXEDBUTTONS,
247
 
        TOOLBARCLASSNAME,
248
 
        (LPWSTR) NULL,
249
 
        WS_CHILD |
250
 
        TBSTYLE_FLAT |
251
 
        TBSTYLE_AUTOSIZE | 
252
 
        TBSTYLE_LIST |
253
 
        CCS_NORESIZE | 
254
 
        CCS_NOPARENTALIGN |
255
 
        CCS_ADJUSTABLE |
256
 
        CCS_NODIVIDER,
257
 
        0, 0, 0, 0, rebar,
258
 
        (HMENU) NULL, khm_hInstance,
259
 
        NULL);
 
312
    if (!def) {
 
313
#ifdef DEBUG
 
314
        assert(FALSE);
 
315
#else
 
316
        return;
 
317
#endif
 
318
    }
 
319
 
 
320
    hwtb = CreateWindowEx(0
 
321
#if (_WIN32_IE >= 0x0501)
 
322
                          | TBSTYLE_EX_MIXEDBUTTONS
 
323
#endif
 
324
                          ,
 
325
                          TOOLBARCLASSNAME,
 
326
                          (LPWSTR) NULL,
 
327
                          WS_CHILD |
 
328
                          TBSTYLE_FLAT |
 
329
                          TBSTYLE_AUTOSIZE | 
 
330
                          TBSTYLE_LIST |
 
331
                          TBSTYLE_TOOLTIPS |
 
332
                          CCS_NORESIZE | 
 
333
                          CCS_NOPARENTALIGN |
 
334
                          CCS_ADJUSTABLE |
 
335
                          CCS_NODIVIDER,
 
336
                          0, 0, 0, 0, rebar,
 
337
                          (HMENU) NULL, khm_hInstance,
 
338
                          NULL);
260
339
 
261
340
    if(!hwtb) {
262
341
#ifdef DEBUG
361
440
 
362
441
    SendMessage(rebar,
363
442
        RB_INSERTBAND,
364
 
        1,
 
443
        0,
365
444
        (LPARAM) &rbi);
366
445
}