Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef __WINLIB_H__
  2. #define __WINLIB_H__
  3.  
  4. #include <kos32sys.h>
  5.  
  6. #include "control.h"
  7.  
  8. #define CAPTION_HEIGHT      24
  9. #define PANEL_HEIGHT        55
  10.  
  11. typedef struct
  12. {
  13.     link_t      link;
  14.     link_t      child;
  15.  
  16.     handler_t  *handler;
  17.     ctrl_t     *parent;
  18.  
  19.     ctx_t      *ctx;
  20.     uint32_t    id;
  21.     uint32_t    style;
  22.  
  23.     rect_t      rc;
  24.     int         w;
  25.     int         h;
  26.  
  27.     rect_t      left;    /*  left  border            */
  28.     rect_t      right;   /*  right border            */
  29.     rect_t      bottom;  /*  bottom border           */
  30.  
  31.     button_t   *close_btn;
  32.     rect_t     *track;
  33. }frame_t;
  34.  
  35. typedef struct
  36. {
  37.     ctrl_t     ctrl;
  38.     ctx_t      ctx;
  39.     bitmap_t   bitmap;
  40.     char      *text;
  41.     ctrl_t    *child_over;
  42.  
  43.     button_t  *full_btn;
  44.     button_t  *minimize_btn;
  45.     button_t  *close_btn;
  46.  
  47. }caption_t;
  48.  
  49. typedef struct
  50. {
  51.     ctrl_t      ctrl;
  52.     ctx_t       ctx;
  53.     bitmap_t    bitmap;
  54.     rect_t      draw;
  55.     ctrl_t     *child_over;
  56.     int         layout;
  57.     progress_t *prg;
  58.     level_t    *lvl;
  59.     slider_t   *sld;
  60.     button_t   *play_btn;
  61.     button_t   *stop_btn;
  62. }panel_t;
  63.  
  64. enum win_state{
  65.       NORMAL, MINIMIZED, ROLLED, MAXIMIZED, FULLSCREEN
  66. };
  67.  
  68. typedef struct
  69. {
  70.     link_t       link;
  71.     link_t       child;
  72.  
  73.     handler_t   *handler;
  74.     ctrl_t      *parent;
  75.  
  76.     ctx_t       *ctx;
  77.     uint32_t     id;
  78.     uint32_t     style;
  79.  
  80.     rect_t       rc;
  81.     int          w;
  82.     int          h;
  83.  
  84.     rect_t       saved;
  85.     rect_t       client;
  86.  
  87. //    ctx_t        client_ctx;
  88. //    bitmap_t     bitmap;
  89.     bitmap_t     bitmap;
  90.  
  91.     char        *caption_txt;
  92.     ctrl_t      *child_over;
  93.     ctrl_t      *child_focus;
  94.  
  95.     caption_t    caption;
  96.     panel_t      panel;
  97.     frame_t      frame;
  98.  
  99.     enum win_state win_state;
  100.     enum win_state saved_state;
  101.  
  102.     enum win_command{
  103.         WIN_CLOSED=1
  104.     }win_command;
  105.  
  106. }window_t;
  107.  
  108. #define get_parent_window(x) ((window_t*)((x)->parent))
  109.  
  110. ctrl_t *win_get_child(window_t *win, int x, int y);
  111.  
  112. void init_winlib(void);
  113.  
  114. void draw_caption(caption_t *cpt);
  115. void draw_panel(panel_t *panel);
  116. void blit_caption(caption_t *cpt);
  117. int  init_caption(window_t *win);
  118. int  init_panel(window_t *win);
  119.  
  120.  
  121.  
  122. window_t  *create_window(char *caption, int style, int x, int y,
  123.                             int w, int h, handler_t handler);
  124.  
  125. int show_window(window_t *win, int state);
  126.  
  127. int def_window_proc(ctrl_t  *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2);
  128.  
  129. void frame_run(window_t *win);
  130.  
  131. button_t *create_button(char *caption, int id, int x, int y,
  132.                         int w, int h, ctrl_t *parent);
  133. progress_t *create_progress(char *caption, int id, int x, int y,
  134.                             int w, int h, ctrl_t *parent);
  135. level_t    *create_level(char *caption, int id, int x, int y,
  136.                          int w, int h, ctrl_t *parent);
  137. scroller_t *create_scroller(uint32_t style, int id, int x, int y,
  138.                             int w, int h, ctrl_t *parent);
  139. slider_t  *create_slider(char *caption, int id, int x, int y,
  140.                          int w, int h, ctrl_t *parent);
  141.  
  142.  
  143. //static uint32_t update_timers(uint32_t realtime);
  144.  
  145. int set_timer(ctrl_t *ctrl, ostimer_t *timer, uint32_t delay);
  146.  
  147. void update_rect(ctrl_t *ctrl);
  148.  
  149.  
  150. #endif
  151.