Subversion Repositories Kolibri OS

Rev

Rev 4446 | Rev 5372 | 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-1, h-1,
82
               NULL,0,0x41);
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
    int w, h;
216
217
 
218
    h = win->client.b - win->client.t;
219
220
 
221
         0, 0, w, h, w, h,win->ctx->pixmap->pitch);
222
};
223
224
 
225
 
226
{
227
    win->win_state = state;
228
229
 
230
231
 
232
    DrawWindow(win->rc.l, win->rc.t, win->w-1, win->h-1,
233
               NULL,0,0x41);
234
    EndDraw();
235
236
 
237
    blit_panel(&win->panel);
238
//    blit_client(win);
239
    return 0;
240
}
241
242
 
243
{
244
    char proc_info[1024];
245
246
 
247
    uint8_t  state;
248
249
 
250
251
 
252
253
 
254
255
 
256
    winy = *(uint32_t*)(proc_info+38);
257
    winw = *(uint32_t*)(proc_info+42)+1;
258
    winh = *(uint32_t*)(proc_info+46)+1;
259
260
 
261
262
 
263
    {   win->win_state = MINIMIZED;
264
        return;
265
    }
266
    if(state & 4)
267
    {
268
        win->win_state = ROLLED;
269
        return;
270
    };
271
272
 
273
        state = MAXIMIZED;
274
    else
275
        state = NORMAL;
276
277
 
278
    {
279
        win->rc.l = winx;
280
        win->rc.t = winy;
281
        win->rc.r = winx + win->w;
282
        win->rc.b = winy + win->h;
283
    };
284
285
 
286
//        winh  == win->h &&
287
//        state == win->win_state)
288
//        return;
289
290
 
291
        win->win_state = state;
292
293
 
294
    int old_size;
295
    int new_size;
296
    int pitch;
297
298
 
299
 
300
    old_size = (old_size+4095) & ~4095;
301
302
 
303
304
 
305
    new_size = (new_size+4095) & ~4095;
306
307
 
308
        user_unmap(win->bitmap.data, new_size, old_size-new_size);
309
310
 
311
    win->bitmap.pitch = pitch;
312
#endif
313
314
 
315
    win->rc.b = winy + winh;
316
    win->w = winw;
317
    win->h = winh;
318
319
 
320
    update_panel_size(win);
321
    adjust_frame(win);
322
323
 
324
    draw_window(win);
325
};
326
327
 
328
 
329
{
330
    ctrl_t *child;
331
332
 
333
        return send_message(mouse_capture, msg, 0, old_pos.val);
334
335
 
336
        return send_message((ctrl_t*)win, msg, 0, old_pos.val);
337
338
 
339
        return 0;
340
341
 
342
    {
343
        return send_message(&win->caption.ctrl, msg, 0, old_pos.val);
344
    }
345
346
 
347
    {
348
//        old_pos.x-= win->panel.ctrl.rc.l;
349
//        old_pos.y-= win->panel.ctrl.rc.t;
350
        return send_message(&win->panel.ctrl, msg, 0, old_pos.val);
351
    }
352
353
 
354
 
355
356
 
357
//        send_message((ctrl_t*)win, msg, 0, old_pos.val);
358
};
359
360
 
361
{
362
//    printf("%s win:%x\n", __FUNCTION__, win);
363
364
 
365
366
 
367
    DrawWindow(0,0,0,0, NULL, 0x000000,0x41);
368
//    DefineButton(15, 15, 0x00000001, 0);
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
    int ctx_w, ctx_h;
631
    int src_x, src_y;
632
633
 
634
    src_y = ctrl->rc.t - ctrl->ctx->offset_y;
635
636
 
637
    ctx_h = ctrl->parent->h;
638
639
 
640
         ctrl->w, ctrl->h, ctx_w, ctx_h, ctrl->ctx->pixmap->pitch);
641
642
 
643
};
644
645
 
646
 
647
                        int src_x, int src_y, int w, int h,
648
                        int src_w, int src_h, int stride)
649
{
650
    volatile struct blit_call bc;
651
652
 
653
    bc.dsty = dst_y;
654
    bc.w    = w;
655
    bc.h    = h;
656
    bc.srcx = src_x;
657
    bc.srcy = src_y;
658
    bc.srcw = src_w;
659
    bc.srch = src_h;
660
    bc.stride = stride;
661
    bc.bitmap = bitmap;
662
663
 
664
    "int $0x40"
665
    ::"a"(73),"b"(0x20),"c"(&bc.dstx));
666
667
 
668
669
 
670
{
671
    ctrl_t *child = NULL;
672
673
 
674
675
 
676
    {
677
        if(pt_in_rect(&tmp->rc, x, y))
678
        {
679
            child = get_child(tmp, x, y);
680
            return child == NULL ? tmp : child;
681
        };
682
        tmp = (ctrl_t*)tmp->link.next;
683
    };
684
    return child;
685
};
686
687
 
688
{
689
    ctrl_t *old = mouse_capture;
690
691
 
692
693
 
694
    "int $0x40"
695
    ::"a"(40), "b"(0x80000027));
696
697
 
698
}
699
700
 
701
{
702
    mouse_capture = NULL;
703
    __asm__ __volatile__(
704
    "int $0x40"
705
    ::"a"(40), "b"(0xC0000027));
706
}
707
>