Subversion Repositories Kolibri OS

Rev

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