Subversion Repositories Kolibri OS

Rev

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