Subversion Repositories Kolibri OS

Rev

Rev 5061 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4438 Serge 1
 
2
#include 
3
#include 
4
#include 
5
#include "winlib.h"
6
7
 
8
9
 
10
static int draw_window(window_t *win);
11
12
 
13
uint32_t cursor_ns;
14
uint32_t cursor_we;
15
uint32_t cursor_nwse;
16
uint32_t cursor_nesw;
17
18
 
19
20
 
4446 Serge 21
4438 Serge 22
 
23
24
 
25
26
 
4446 Serge 27
static uint32_t  realtime;
4438 Serge 28
static uint32_t  wait_time;
29
static uint32_t  exp_time;
30
31
 
32
33
 
34
35
 
36
 
37
38
 
4446 Serge 39
ctrl_t *win_get_child(window_t *win, int x, int y)
40
{
41
    ctrl_t *child = NULL;
42
4438 Serge 43
 
4446 Serge 44
    {
45
        if(pt_in_rect(&win->client, x, y))
46
        {
47
            ctrl_t *tmp = (ctrl_t*)win->child.next;
48
4438 Serge 49
 
4446 Serge 50
            {
51
                if(pt_in_rect(&tmp->rc, x, y))
52
                {
53
                    child = get_child(tmp, x, y);
54
                    return child == NULL ? tmp : child;
55
                };
56
                tmp = (ctrl_t*)tmp->link.next;
57
            };
58
        }
59
        else child = (ctrl_t*)(&win->frame);
60
    };
61
    return child;
62
};
63
4438 Serge 64
 
65
 
66
67
 
68
                          int w, int h, handler_t handler)
69
{
70
    char proc_info[1024];
71
    int stride;
72
73
 
74
75
 
76
 
77
78
 
79
80
 
81
    DrawWindow(x, y, w, h,
5372 serge 82
               NULL,0,0x41);
4438 Serge 83
    EndDraw();
84
85
 
86
87
 
88
    y = *(uint32_t*)(proc_info+38);
89
    w = *(uint32_t*)(proc_info+42)+1;
90
    h = *(uint32_t*)(proc_info+46)+1;
91
92
 
93
 //   Window.ctx = ctx;
94
95
 
96
    list_initialize(&Window.child);
97
98
 
99
 
100
//    Window.bitmap.height = 1080;
101
//    Window.bitmap.flags  = 0;
102
103
 
104
 //   {
105
 //       printf("not enough memory for window bitmap\n");
106
 //       return 0;
107
  //  }
108
109
 
110
 //   ctx->offset_x = 0;
111
 //   ctx->offset_y = 0;
112
113
 
114
    Window.rc.t = y;
115
    Window.rc.r = x + w;
116
    Window.rc.b = y + h;
117
118
 
119
    Window.h = h;
120
121
 
122
    Window.style = style;
123
124
 
125
    Window.child_focus = NULL;
126
127
 
128
    init_panel(&Window);
129
    init_frame(&Window);
130
    send_message((ctrl_t*)&Window, MSG_SIZE, 0, 0);
131
    return &Window;
132
};
133
134
 
135
 
136
{
137
    ctrl_t   *child;
138
139
 
140
141
 
142
    {
143
        case MSG_PAINT:
144
            draw_window(win);
145
            break;
146
147
 
148
            child  = (ctrl_t*)win->child.next;
149
            while( &child->link != &win->child)
150
            {
151
                send_message(child, 2, arg1, arg2);
152
                child = (ctrl_t*)child->link.next;
153
            };
154
            break;
155
156
 
157
            child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16));
158
            if( win->child_over )
159
            {
160
                if(child == win->child_over)
161
                    send_message(child, msg, 0, arg2);
162
                else
163
                    send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
164
            }
165
            else if( child )
166
                send_message(child, MSG_MOUSEENTER, 0, arg2);
167
168
 
169
            if( child )
170
                send_message(child,msg,0,arg2);
171
            else if(main_cursor != 0)
172
            {
173
                set_cursor(0);
174
                main_cursor = 0;
175
            }
176
            break;
177
178
 
179
            break;
180
181
 
182
            child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16));
183
            win->child_over = child;
184
            if(child) send_message(child, msg, 0, arg2);
185
    };
186
187
 
188
}
189
190
 
191
{
192
    ctrl_t *child;
193
    void   *ctx;
194
    rect_t *rc = &win->client;
195
196
 
197
    draw_panel(&win->panel);
198
    send_message(win, MSG_DRAW_CLIENT,0,0);
199
200
 
201
202
 
203
204
 
205
//    {
206
//        send_message(child, 1, 0, 0);
207
//        child = (ctrl_t*)child->link.next;
208
//    };
209
210
 
211
};
212
213
 
214
{
215
    ctx_t  *ctx = &win->ctx;
5372 serge 216
    int w, h;
4438 Serge 217
218
 
219
    h = win->client.b - win->client.t;
220
221
 
5372 serge 222
         0, 0, w, h, w, h, ctx->pixmap_pitch);
223
};
4438 Serge 224
225
 
226
 
227
{
228
    win->win_state = state;
229
230
 
231
232
 
233
    DrawWindow(win->rc.l, win->rc.t, win->w-1, win->h-1,
234
               NULL,0,0x41);
235
    EndDraw();
236
237
 
238
    blit_panel(&win->panel);
239
//    blit_client(win);
240
    return 0;
241
}
242
243
 
244
{
245
    char proc_info[1024];
246
247
 
248
    uint8_t  state;
249
250
 
251
252
 
253
254
 
255
256
 
257
    winy = *(uint32_t*)(proc_info+38);
258
    winw = *(uint32_t*)(proc_info+42)+1;
259
    winh = *(uint32_t*)(proc_info+46)+1;
260
261
 
262
263
 
264
    {   win->win_state = MINIMIZED;
265
        return;
266
    }
267
    if(state & 4)
268
    {
269
        win->win_state = ROLLED;
270
        return;
271
    };
272
273
 
274
        state = MAXIMIZED;
275
    else
276
        state = NORMAL;
277
278
 
279
    {
280
        win->rc.l = winx;
281
        win->rc.t = winy;
282
        win->rc.r = winx + win->w;
283
        win->rc.b = winy + win->h;
284
    };
285
286
 
287
//        winh  == win->h &&
288
//        state == win->win_state)
289
//        return;
290
291
 
292
        win->win_state = state;
293
294
 
295
    int old_size;
296
    int new_size;
297
    int pitch;
298
299
 
300
 
301
    old_size = (old_size+4095) & ~4095;
302
303
 
304
305
 
306
    new_size = (new_size+4095) & ~4095;
307
308
 
309
        user_unmap(win->bitmap.data, new_size, old_size-new_size);
310
311
 
312
    win->bitmap.pitch = pitch;
313
#endif
314
315
 
316
    win->rc.b = winy + winh;
317
    win->w = winw;
318
    win->h = winh;
319
320
 
321
    update_panel_size(win);
322
    adjust_frame(win);
323
324
 
325
    draw_window(win);
326
};
327
328
 
329
 
330
{
331
    ctrl_t *child;
332
333
 
334
        return send_message(mouse_capture, msg, 0, old_pos.val);
335
336
 
337
        return send_message((ctrl_t*)win, msg, 0, old_pos.val);
338
339
 
340
        return 0;
341
342
 
343
    {
344
        return send_message(&win->caption.ctrl, msg, 0, old_pos.val);
345
    }
346
347
 
348
    {
349
//        old_pos.x-= win->panel.ctrl.rc.l;
350
//        old_pos.y-= win->panel.ctrl.rc.t;
351
        return send_message(&win->panel.ctrl, msg, 0, old_pos.val);
352
    }
353
354
 
355
 
356
357
 
358
//        send_message((ctrl_t*)win, msg, 0, old_pos.val);
359
};
360
361
 
362
{
363
//    printf("%s win:%x\n", __FUNCTION__, win);
364
365
 
366
367
 
368
    DrawWindow(0,0,0,0, NULL, 0x000000,0x41);
369
    EndDraw();
370
371
 
372
373
 
374
    {
375
        need_update=0;
376
        return;
377
    };
378
379
 
380
    blit_panel(&win->panel);
381
382
 
383
    need_update=0;
384
};
385
386
 
387
{
388
    static uint32_t  mouse_click_time;
389
    static int  mouse_action;
390
    static int  old_buttons;
391
    int         buttons;
392
    uint32_t    wheels;
393
    uint32_t    click_time;
394
    int         action;
395
396
 
397
398
 
399
    pos = GetMousePos(POS_WINDOW);
5061 serge 400
4438 Serge 401
 
402
    {
403
        mouse_action = 0x80000000;
404
        old_pos = pos;
405
    };
406
//    printf("pos x%d y%d\n", pos.x, pos.y);
407
408
 
5061 serge 409
    wheels = get_mouse_wheels();
4438 Serge 410
411
 
412
        wheels = (short)wheels>0 ? MSG_WHEELDOWN : MSG_WHEELUP;
413
        send_mouse_message(win, wheels);
414
    }
415
416
 
417
    {
418
        mouse_action|= action<<3;
419
        mouse_action|= buttons & ~old_buttons;
420
    }
421
    old_buttons = buttons;
422
423
 
424
        DBG("mouse move \n\r");
425
        send_mouse_message(win, MSG_MOUSEMOVE);
426
    };
427
428
 
429
    {
430
        if((mouse_action & 0x09)==0x09)
431
        {
432
//            printf("left button down x= %d y= %d\n\r", old_x.x, old_x.y);
433
            click_time = get_tick_count();
434
            if(click_time < mouse_click_time+35) {
435
                mouse_click_time = click_time;
436
                send_mouse_message(win,MSG_LBTNDBLCLK);
437
            }
438
            else {
439
              mouse_click_time = click_time;
440
              send_mouse_message(win,MSG_LBTNDOWN);
441
            };
442
        }
443
        else {
444
//            printf("left button up \n\r");
445
            send_mouse_message(win,MSG_LBTNUP);
446
        }
447
    };
448
449
 
450
    {
451
        if((mouse_action & 0x12)==0x12) {
452
            DBG("right button down \n\r");
453
            send_mouse_message(win,MSG_RBTNDOWN);
454
        }
455
        else {
456
            DBG("right button up \n\r");
457
            send_mouse_message(win,MSG_RBTNUP);
458
        };
459
    };
460
    if(mouse_action & 0x24)
461
    {
462
        if((mouse_action & 0x24)==0x24){
463
            DBG("middle button down \n\r");
464
            send_mouse_message(win,MSG_MBTNDOWN);
465
        }
466
        else {
467
            DBG("middle button up \n\r");
468
            send_mouse_message(win,MSG_MBTNUP);
469
        };
470
    };
471
472
 
473
 
474
475
 
476
 
477
{
478
    int ev;
479
    oskey_t   key;
480
481
 
482
//    wheels    = get_mouse_wheels();
483
    realtime  = get_tick_count();
484
    exp_time  = -1;
485
486
 
487
    {
488
        wait_time = exp_time - realtime;
489
490
 
491
492
 
493
494
 
495
//            exp_time = update_timers(realtime);
496
497
 
498
        {
499
            case MSG_PAINT:
500
                do_sys_draw(win);
501
                continue;
502
503
 
504
                printf("key pressed\n");
505
                key = get_key();
506
                if( key.state == 0)
507
                    send_message((ctrl_t*)win, ev, 0, key.code);
508
                continue;
509
510
 
511
                printf("Button pressed\n");
512
                continue;
513
514
 
515
                do_sys_mouse(win);
516
                continue;
517
518
 
519
                printf("event %d\n", ev);
520
                continue;
521
        };
522
    };
523
}
524
525
 
526
527
 
528
{
529
    int ev;
530
    oskey_t   key;
531
    int button;
532
533
 
534
    exp_time  = -1;
535
536
 
537
    {
538
        wait_time = exp_time - realtime;
539
540
 
541
542
 
543
544
 
545
//            exp_time = update_timers(realtime);
546
547
 
548
        {
549
            case MSG_PAINT:
550
                do_sys_draw(win);
551
                break;
552
553
 
554
                key = get_key();
555
                if( key.state == 0)
556
                    send_message((ctrl_t*)win, ev, 0, key.code);
557
                break;
558
559
 
560
                button = get_os_button();
561
                if(button == 1)
562
                    win->win_command = WIN_CLOSED;
563
                break;
564
565
 
566
                do_sys_mouse(win);
567
                break;
568
569
 
570
                break;
571
        };
572
573
 
574
    };
575
};
576
577
 
578
 
579
 
580
extern unsigned char res_cursor_we[];
581
extern unsigned char res_cursor_nwse[];
582
extern unsigned char res_cursor_nesw[];
583
584
 
585
{
586
    cursor_ns   = load_cursor(res_cursor_ns, LOAD_FROM_MEM);
587
    cursor_we   = load_cursor(res_cursor_we, LOAD_FROM_MEM);
588
    cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM);
589
    cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM);
590
591
 
592
593
 
594
}
595
596
 
597
{
598
    int ret;
599
600
 
601
    ret |= destroy_cursor(cursor_nwse);
602
    ret |= destroy_cursor(cursor_we);
603
    ret |= destroy_cursor(cursor_ns);
604
605
 
606
};
607
608
 
609
 
610
 
611
{
612
    __asm__ __volatile__(
613
    "int $0x40"
614
    ::"a"(40), "b"(0xC0000027));
615
    __asm__ __volatile__(
616
    "int $0x40"
617
    ::"a"(66), "b"(1),"c"(1));
618
619
 
620
    list_initialize(&timers);
621
};
622
623
 
624
//{
625
//    return &Window.client_ctx;
626
//};
627
628
 
629
{
630
    ctx_t  *ctx = ctrl->ctx;
5372 serge 631
632
 
4438 Serge 633
    int src_x, src_y;
634
635
 
636
    src_y = ctrl->rc.t - ctrl->ctx->offset_y;
637
638
 
639
    ctx_h = ctrl->parent->h;
640
641
 
5372 serge 642
         ctrl->w, ctrl->h, ctx_w, ctx_h, ctx->pixmap_pitch);
643
4438 Serge 644
 
645
};
646
647
 
648
{
649
    ctrl_t *child = NULL;
650
651
 
652
653
 
654
    {
655
        if(pt_in_rect(&tmp->rc, x, y))
656
        {
657
            child = get_child(tmp, x, y);
658
            return child == NULL ? tmp : child;
659
        };
660
        tmp = (ctrl_t*)tmp->link.next;
661
    };
662
    return child;
663
};
664
665
 
666
{
667
    ctrl_t *old = mouse_capture;
668
669
 
670
671
 
672
    "int $0x40"
673
    ::"a"(40), "b"(0x80000027));
674
675
 
676
}
677
678
 
679
{
680
    mouse_capture = NULL;
681
    __asm__ __volatile__(
682
    "int $0x40"
683
    ::"a"(40), "b"(0xC0000027));
684
}
685
>