Subversion Repositories Kolibri OS

Rev

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