Subversion Repositories Kolibri OS

Rev

Rev 2693 | 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
 
2693 Serge 44
    if(!ctx->pixmap)
45
    {
46
        printf("not enough memory for caption bitmap\n");
47
        return 0;
48
    };
49
50
 
51
52
 
53
    ctx->offset_x = 0;
54
    ctx->offset_y = 0;
55
56
 
57
58
 
59
    cpt->close_btn = btn;
60
61
 
62
    btn->img_hilite  = res_close_btn_hl;
63
    btn->img_pressed = res_close_btn_pressed;
64
65
 
66
    cpt->minimize_btn = btn;
67
68
 
69
    btn->img_hilite  = res_minimize_btn_hl;
70
    btn->img_pressed = res_minimize_btn_pressed;
71
72
 
73
74
 
75
};
76
77
 
78
 
79
{
80
    caption_t *cpt = &win->caption;
81
82
 
83
    int new_size;
84
    int stride;
85
86
 
87
    old_size = (old_size+4095) & ~4095;
88
89
 
90
91
 
92
    new_size = (new_size+4095) & ~4095;
93
94
 
95
        user_unmap(cpt->ctx.pixmap, new_size, old_size-new_size);
96
97
 
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
 
3068 serge 108
    cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l +
109
                           cpt->close_btn->ctrl.w;
110
2693 Serge 111
 
3068 serge 112
    cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l +
113
                           cpt->minimize_btn->ctrl.w;
114
2693 Serge 115
 
116
117
 
3068 serge 118
{
119
    uint32_t    width;
120
    uint32_t    height;
121
    uint32_t    pitch;
122
    uint32_t    handle;
123
    uint8_t    *data;
124
}bitmap_t;
125
2693 Serge 126
 
3068 serge 127
128
 
2693 Serge 129
{
130
    int *pixmap, *src;
131
    int  i, j, w;
132
133
 
134
    src = res_caption_left;
135
136
 
137
    {
138
        for(j=0; j < CAPTION_CORNER_W; j++)
139
            pixmap[j] = src[j];
140
        pixmap+= cpt->ctx.stride/4;
141
        src+= CAPTION_CORNER_W;
142
    };
143
144
 
145
    if( w > 0)
146
    {
147
        pixmap = cpt->ctx.pixmap;
148
        pixmap+= CAPTION_CORNER_W;
149
        src = res_caption_body;
150
151
 
152
        {
153
            for(j = 0; j < w; j++)
154
                pixmap[j] = src[i];
155
            pixmap+= cpt->ctx.stride/4;
156
        }
157
    };
158
159
 
160
    pixmap+= cpt->ctrl.w - CAPTION_CORNER_W;
161
162
 
163
164
 
165
    {
166
        for(j = 0; j < CAPTION_CORNER_W; j++)
167
            pixmap[j] = src[j];
168
        pixmap+= cpt->ctx.stride/4;
169
        src+= CAPTION_CORNER_W;
170
    };
171
172
 
3068 serge 173
174
 
175
    bitmap.pitch = cpt->ctx.stride;
176
177
 
178
179
 
2693 Serge 180
    child  = (ctrl_t*)cpt->ctrl.child.next;
181
182
 
183
    {
184
        send_message(child, 1, 0, 0);
185
        child = (ctrl_t*)child->link.next;
186
    };
187
};
188
189
 
190
 
191
{
192
    caption_t *cpt = (caption_t*)ctrl;
193
    window_t *win  = (window_t*)ctrl->parent;
194
195
 
196
    int x, y;
197
198
 
199
    y = ((pos_t)arg2).y;
200
201
 
202
    {
203
        case 1:
204
            break;
205
206
 
207
 
208
            child = get_child(ctrl, x, y);
209
            if( win->child_over )
210
            {
211
                if(child == win->child_over)
212
                    send_message(child, msg, 0, arg2);
213
                else
214
                    send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
215
            };
3068 serge 216
2693 Serge 217
 
218
            if( child )
219
            {
3068 serge 220
                send_message(child, MSG_MOUSEENTER, 0, arg2);
221
                send_message(child,msg,0,arg2);
2693 Serge 222
            }
3068 serge 223
            else if(main_cursor != 0)
224
            {
225
                set_cursor(0);
226
                main_cursor = 0;
227
            }
228
            break;
2693 Serge 229
230
 
231
 
232
            switch((short)arg1)
233
            {
234
                case ID_CLOSE:
235
                    win = (window_t*)ctrl->parent;
236
                    win->win_command = WIN_CLOSED;
237
                    break;
238
239
 
240
                    __asm__ __volatile__(
241
                    "int $0x40"
242
                    ::"a"(18),"b"(10));
243
                    break;
244
                default:
245
                    break;
246
            };
247
248
 
249
            child = get_child(ctrl, x, y);
250
            if(child)
251
                return send_message(child, msg, 0, arg2);
252
    }
253
    return 1;
254
};
255
256
 
257
 
258
 
259
{
260
//    printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
261
//            cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
262
263
 
264
         cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
265
};
266