Subversion Repositories Kolibri OS

Rev

Rev 3248 | 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
3068 serge 164
 
2693 Serge 165
    child  = (ctrl_t*)cpt->ctrl.child.next;
166
167
 
168
    {
169
        send_message(child, 1, 0, 0);
170
        child = (ctrl_t*)child->link.next;
171
    };
172
};
173
174
 
175
 
176
{
177
    caption_t *cpt = (caption_t*)ctrl;
178
    window_t *win  = (window_t*)ctrl->parent;
179
180
 
181
    int x, y;
182
183
 
184
    y = ((pos_t)arg2).y;
185
186
 
187
    {
188
        case 1:
189
            break;
190
191
 
192
 
193
            child = get_child(ctrl, x, y);
194
            if( win->child_over )
195
            {
196
                if(child == win->child_over)
197
                    send_message(child, msg, 0, arg2);
198
                else
199
                    send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
200
            };
3068 serge 201
2693 Serge 202
 
203
            if( child )
204
            {
3068 serge 205
                send_message(child, MSG_MOUSEENTER, 0, arg2);
206
                send_message(child,msg,0,arg2);
2693 Serge 207
            }
3068 serge 208
            else if(main_cursor != 0)
209
            {
210
                set_cursor(0);
211
                main_cursor = 0;
212
            }
213
            break;
2693 Serge 214
215
 
216
 
217
            switch((short)arg1)
218
            {
219
                case ID_CLOSE:
220
                    win->win_command = WIN_CLOSED;
221
                    break;
222
223
 
224
                    __asm__ __volatile__(
225
                    "int $0x40"
226
                    ::"a"(18),"b"(10));
227
                    win->win_state = MINIMIZED;
3292 Serge 228
                    send_message((ctrl_t*)win, MSG_SIZE, 0, 0);
229
                    break;
2693 Serge 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