Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4438 Serge 1
 
2
#include 
3
#include 
4
#include "winlib.h"
5
6
 
7
8
 
9
extern int res_caption_right[];
10
extern int res_caption_body[];
11
12
 
13
extern int res_close_btn_hl[];
14
extern int res_close_btn_pressed[];
15
16
 
17
extern int res_minimize_btn_hl[];
18
extern int res_minimize_btn_pressed[];
19
20
 
21
extern int res_full_btn_hl[];
22
extern int res_full_btn_pressed[];
23
24
 
25
26
 
27
28
 
29
30
 
31
 
32
{
33
    button_t  *btn;
34
35
 
36
    ctx_t     *ctx = &cpt->ctx;
37
38
 
39
    list_initialize(&cpt->ctrl.child);
40
41
 
42
    cpt->ctrl.parent  = (ctrl_t*)win;
43
44
 
45
46
 
47
    cpt->bitmap.height = CAPTION_HEIGHT;
48
    cpt->bitmap.flags  = 0;
49
50
 
51
    {
52
        printf("not enough memory for caption bitmap\n");
53
        return 0;
54
    }
55
56
 
57
 
58
    ctx->pixmap   = &cpt->bitmap;
59
    ctx->offset_x = 0;
60
    ctx->offset_y = 0;
61
62
 
63
64
 
65
    cpt->close_btn = btn;
66
67
 
68
    btn->img_hilite  = res_close_btn_hl;
69
    btn->img_pressed = res_close_btn_pressed;
70
71
 
72
    cpt->minimize_btn = btn;
73
74
 
75
    btn->img_hilite  = res_minimize_btn_hl;
76
    btn->img_pressed = res_minimize_btn_pressed;
77
78
 
79
    cpt->full_btn = btn;
80
81
 
82
    btn->img_hilite  = res_full_btn_hl;
83
    btn->img_pressed = res_full_btn_pressed;
84
85
 
86
87
 
88
};
89
90
 
91
 
92
{
93
    caption_t *cpt = &win->caption;
94
    bitmap_t  *bitmap = &cpt->bitmap;
95
96
 
97
    resize_bitmap(bitmap);
98
99
 
100
    cpt->ctrl.rc.t    = 0;
101
    cpt->ctrl.rc.r    = win->w;
102
    cpt->ctrl.rc.b    = CAPTION_HEIGHT;
103
    cpt->ctrl.w       = win->w;
104
    cpt->ctrl.h       = CAPTION_HEIGHT;
105
    win->client.t     = CAPTION_HEIGHT;
106
107
 
108
    cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l +
109
                           cpt->close_btn->ctrl.w;
110
111
 
112
    cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l +
113
                           cpt->minimize_btn->ctrl.w;
114
115
 
116
    cpt->full_btn->ctrl.rc.r = cpt->full_btn->ctrl.rc.l +
117
                           cpt->full_btn->ctrl.w;
118
119
 
120
121
 
122
 
123
124
 
125
{
126
    int *pixmap, *src;
127
    rect_t rc;
128
    int  i, j, w;
129
130
 
131
132
 
133
             CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4);
134
135
 
136
    if( w > 0)
137
    {
138
        pixmap = (int*)cpt->ctx.pixmap->data;
139
        pixmap+= CAPTION_CORNER_W;
140
        src = res_caption_body;
141
142
 
143
        {
144
            for(j = 0; j < w; j++)
145
                pixmap[j] = src[i];
146
            pixmap+= cpt->ctx.pixmap->pitch/4;
147
        }
148
149
 
150
//                 w, CAPTION_HEIGHT, 0);
151
152
 
153
154
 
155
 
156
             CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4);
157
158
 
159
    rc.t = 0;
160
    rc.r = cpt->ctrl.w - 27 - 18 - 18 - 5 - 5 - 8;
161
    rc.b = 18;
162
163
 
164
165
 
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
            };
202
203
 
204
            if( child )
205
            {
206
                send_message(child, MSG_MOUSEENTER, 0, arg2);
207
                send_message(child,msg,0,arg2);
208
            }
209
            else if(main_cursor != 0)
210
            {
211
                set_cursor(0);
212
                main_cursor = 0;
213
            }
214
            break;
215
216
 
217
 
218
            switch((short)arg1)
219
            {
220
                case ID_CLOSE:
221
                    win->win_command = WIN_CLOSED;
222
                    break;
223
224
 
225
                    __asm__ __volatile__(
226
                    "int $0x40"
227
                    ::"a"(18),"b"(10));
228
                    win->win_state = MINIMIZED;
229
                    send_message((ctrl_t*)win, MSG_SIZE, 0, 0);
230
                    break;
231
                case ID_FULLSCREEN:
232
                {
233
                    int screensize;
234
235
 
236
                    win->saved_state = win->win_state;
237
                    screensize = GetScreenSize();
238
                    __asm__ __volatile__(
239
                    "int $0x40"
240
                    ::"a"(67), "b"(0), "c"(0),
241
                    "d"((screensize >> 16)-1),"S"((screensize & 0xFFFF)-1) );
242
                    win->win_state = FULLSCREEN;
243
                    window_update_layout(win);
244
                };
245
                    break;
246
247
 
248
                    break;
249
            };
250
251
 
252
            child = get_child(ctrl, x, y);
253
            if(child)
254
                return send_message(child, msg, 0, arg2);
255
    }
256
    return 1;
257
};
258
259
 
260
 
261
 
262
{
263
//    printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
264
//            cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
265
266
 
267
268
 
269
         cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap->pitch);
270
};
271