Subversion Repositories Kolibri OS

Rev

Rev 3068 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2693 Serge 1
 
2
#include 
3
#include 
4
#include 
5
#include "winlib.h"
6
7
 
8
9
 
10
extern int res_caption_right[];
11
extern int res_caption_body[];
12
13
 
14
extern int res_close_btn_hl[];
15
extern int res_close_btn_pressed[];
16
17
 
18
extern int res_minimize_btn_hl[];
19
extern int res_minimize_btn_pressed[];
20
21
 
3068 serge 22
23
 
2693 Serge 24
25
 
26
27
 
28
 
29
{
30
    button_t  *btn;
31
32
 
33
    ctx_t     *ctx = &cpt->ctx;
34
35
 
36
    list_initialize(&cpt->ctrl.child);
37
38
 
39
    cpt->ctrl.parent  = (ctrl_t*)win;
40
41
 
3068 serge 42
43
 
3248 Serge 44
    cpt->bitmap.height = CAPTION_HEIGHT;
45
    cpt->bitmap.flags  = 0;
46
47
 
48
    {
2693 Serge 49
        printf("not enough memory for caption bitmap\n");
50
        return 0;
51
    }
3248 Serge 52
2693 Serge 53
 
3248 Serge 54
 
2693 Serge 55
    ctx->pixmap   = &cpt->bitmap;
3248 Serge 56
    ctx->offset_x = 0;
2693 Serge 57
    ctx->offset_y = 0;
58
59
 
60
61
 
62
    cpt->close_btn = btn;
63
64
 
65
    btn->img_hilite  = res_close_btn_hl;
66
    btn->img_pressed = res_close_btn_pressed;
67
68
 
69
    cpt->minimize_btn = btn;
70
71
 
72
    btn->img_hilite  = res_minimize_btn_hl;
73
    btn->img_pressed = res_minimize_btn_pressed;
74
75
 
76
77
 
78
};
79
80
 
81
 
82
{
83
    caption_t *cpt = &win->caption;
84
    bitmap_t  *bitmap = cpt->ctx.pixmap;
3248 Serge 85
2693 Serge 86
 
87
    int new_size;
88
    int pitch;
3248 Serge 89
2693 Serge 90
 
3248 Serge 91
    old_size = (old_size+4095) & ~4095;
2693 Serge 92
93
 
3248 Serge 94
2693 Serge 95
 
3248 Serge 96
    new_size = (new_size+4095) & ~4095;
2693 Serge 97
98
 
99
        user_unmap(bitmap->data, new_size, old_size-new_size);
3248 Serge 100
2693 Serge 101
 
3248 Serge 102
    bitmap->pitch = pitch;
103
2693 Serge 104
 
105
    cpt->ctrl.rc.t    = 0;
106
    cpt->ctrl.rc.r    = win->w;
107
    cpt->ctrl.rc.b    = CAPTION_HEIGHT;
108
    cpt->ctrl.w       = win->w;
109
    cpt->ctrl.h       = CAPTION_HEIGHT;
110
    win->client.t     = CAPTION_HEIGHT;
111
112
 
3068 serge 113
    cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l +
114
                           cpt->close_btn->ctrl.w;
115
2693 Serge 116
 
3068 serge 117
    cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l +
118
                           cpt->minimize_btn->ctrl.w;
119
2693 Serge 120
 
121
122
 
123
 
3068 serge 124
125
 
2693 Serge 126
{
127
    int *pixmap, *src;
128
    rect_t rc;
3248 Serge 129
    int  i, j, w;
2693 Serge 130
131
 
3248 Serge 132
             CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4);
133
2693 Serge 134
 
135
    if( w > 0)
136
    {
137
        pixmap = (int*)cpt->ctx.pixmap->data;
3248 Serge 138
        pixmap+= CAPTION_CORNER_W;
2693 Serge 139
        src = res_caption_body;
140
141
 
142
        {
143
            for(j = 0; j < w; j++)
144
                pixmap[j] = src[i];
145
            pixmap+= cpt->ctx.pixmap->pitch/4;
3248 Serge 146
        }
2693 Serge 147
148
 
3248 Serge 149
//                 w, CAPTION_HEIGHT, 0);
150
2693 Serge 151
 
152
153
 
3068 serge 154
 
3248 Serge 155
             CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4);
156
3068 serge 157
 
3248 Serge 158
    rc.t = 0;
159
    rc.r = cpt->ctrl.w - 25 - 16 - 5 - 8;
160
    rc.b = 18;
161
162
 
163
    draw_text_ext(cpt->ctx.pixmap, win_font, cpt->text, &rc, 0xFFFFFFFF);
164
3068 serge 165
 
2693 Serge 166
    child  = (ctrl_t*)cpt->ctrl.child.next;
167
168
 
169
    {
170
        send_message(child, 1, 0, 0);
171
        child = (ctrl_t*)child->link.next;
172
    };
173
};
174
175
 
176
 
177
{
178
    caption_t *cpt = (caption_t*)ctrl;
179
    window_t *win  = (window_t*)ctrl->parent;
180
181
 
182
    int x, y;
183
184
 
185
    y = ((pos_t)arg2).y;
186
187
 
188
    {
189
        case 1:
190
            break;
191
192
 
193
 
194
            child = get_child(ctrl, x, y);
195
            if( win->child_over )
196
            {
197
                if(child == win->child_over)
198
                    send_message(child, msg, 0, arg2);
199
                else
200
                    send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
201
            };
3068 serge 202
2693 Serge 203
 
204
            if( child )
205
            {
3068 serge 206
                send_message(child, MSG_MOUSEENTER, 0, arg2);
207
                send_message(child,msg,0,arg2);
2693 Serge 208
            }
3068 serge 209
            else if(main_cursor != 0)
210
            {
211
                set_cursor(0);
212
                main_cursor = 0;
213
            }
214
            break;
2693 Serge 215
216
 
217
 
218
            switch((short)arg1)
219
            {
220
                case ID_CLOSE:
221
                    win = (window_t*)ctrl->parent;
222
                    win->win_command = WIN_CLOSED;
223
                    break;
224
225
 
226
                    __asm__ __volatile__(
227
                    "int $0x40"
228
                    ::"a"(18),"b"(10));
229
                    break;
230
                default:
231
                    break;
232
            };
233
234
 
235
            child = get_child(ctrl, x, y);
236
            if(child)
237
                return send_message(child, msg, 0, arg2);
238
    }
239
    return 1;
240
};
241
242
 
243
 
244
 
245
{
246
//    printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
247
//            cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
248
249
 
3248 Serge 250
         cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap->pitch);
251
};
2693 Serge 252