Subversion Repositories Kolibri OS

Rev

Rev 6535 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef KOLIBRI_MENUBAR_H
  2. #define KOLIBRI_MENUBAR_H
  3.  
  4. typedef struct
  5. {
  6.         uint32_t type;   // 1 ���� ��� �������, ������ �����
  7.  
  8.         uint32_t x_w;   // ������� �����
  9.         uint32_t y_h;
  10.  
  11.         char* text_pointer;
  12.         char* pos_pointer;
  13.         char* text_end;
  14.         uint32_t mouse_pos;
  15.         uint32_t mouse_keys;
  16.  
  17.         uint32_t x_w1;  // �������
  18.         uint32_t y_h1;
  19.  
  20.         color_t bckg_col;  // ��� �������� �����
  21.         color_t frnt_col;  // ��� ���������� �������� ������
  22.         color_t menu_col;  // ��� ���������� ����� (��������)
  23.         uint32_t select;
  24.         uint32_t out_select;
  25.         char* buf_adress;
  26.         char* procinfo;
  27.         uint32_t click;
  28.         uint32_t cursor;
  29.         uint32_t cursor_old;
  30.         uint32_t interval;
  31.         uint32_t cursor_max;
  32.         uint32_t extended_key;
  33.         color_t menu_sel_col;  // ���� ���� ���������� ���������
  34.         color_t bckg_text_col; // ���� ������ ������������ ������
  35.         color_t frnt_text_col;  // ���� ������ ���������� ������
  36.         uint32_t mouse_keys_old;
  37.         uint32_t font_height;
  38.         uint32_t cursor_out;
  39.         uint32_t get_mouse_flag;
  40. } menubar;
  41.  
  42.  
  43. static inline menubar* kolibri_menubar(menubar* bar, uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext,
  44.                                 color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select)
  45. {
  46.     static char procinfo[1024];
  47.     memset(bar, 0, sizeof(menubar));
  48.     bar->type = 0;
  49.     bar->x_w = x_w;
  50.     bar->y_h = y_h;
  51.  
  52.     // count summary length
  53.     char *pc, **mitem;
  54.     int len = 0;
  55.     for(mitem = menutext; *mitem; mitem++) len += strlen(*mitem) + 1;
  56.  
  57.     // copy menu items in needed format
  58.     bar->text_pointer = malloc(len + 1);   // need to be freed manual at closing secondary windows with menu
  59.     for (pc = bar->text_pointer, mitem = menutext; *mitem; pc += strlen(*mitem++) + 1)
  60.         strcpy(pc, *mitem);
  61.     *pc = 0;
  62.     bar->text_end = pc;
  63.     bar->pos_pointer = strchr(bar->text_pointer, 0) + 1;
  64.  
  65.     bar->x_w1 = X_Y(x_w >> 16, sub_w);
  66.     bar->y_h1 = X_Y((y_h >> 16) + (y_h & 0xFFFF), sub_h);
  67.  
  68.     bar->interval = 16;
  69.     bar->font_height = 8;
  70.  
  71.     bar->bckg_col = top_bg;
  72.     bar->frnt_col = top_select;
  73.     bar->menu_col = sub_bg;
  74.     bar->menu_sel_col = sub_select;
  75.     bar->bckg_text_col = unsel_font;
  76.     bar->frnt_text_col = sel_font;
  77.     bar->procinfo = procinfo;
  78.  
  79.     return bar;
  80. }
  81.  
  82. static inline menubar* kolibri_new_menubar(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext,
  83.                                 color_t sel_font, color_t unsel_font, color_t top_bg, color_t top_select, color_t sub_bg, color_t sub_select)
  84. {
  85.     menubar *new_bar = (menubar*)malloc(sizeof(menubar));
  86.     return kolibri_menubar(new_bar, x_w, y_h, sub_w, sub_h, menutext, sel_font, unsel_font, top_bg, top_select, sub_bg, sub_select);
  87. }
  88.  
  89. static inline menubar* kolibri_menubar_def(menubar* bar, uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext)
  90. {
  91.     return kolibri_menubar(bar, x_w, y_h, sub_w, sub_h, menutext,
  92.                            kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
  93.                            kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button);
  94. }
  95.  
  96. static inline menubar* kolibri_new_menubar_def(uint32_t x_w, uint32_t y_h, uint16_t sub_w, uint16_t sub_h, char **menutext)
  97. {
  98.     return kolibri_new_menubar(x_w, y_h, sub_w, sub_h, menutext,
  99.                            kolibri_color_table.color_work_button_text, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area,
  100.                            kolibri_color_table.color_work_button, kolibri_color_table.color_grab_bar_button, kolibri_color_table.color_work_button);
  101. }
  102.  
  103. static inline void gui_add_menubar(kolibri_window *wnd, menubar* bar)
  104. {
  105.     kolibri_window_add_element(wnd, KOLIBRI_MENU_BAR, bar);
  106. }
  107.  
  108.  
  109. extern void (*menu_bar_draw)(menubar *) __attribute__((__stdcall__));
  110. extern void (*menu_bar_mouse)(menubar *) __attribute__((__stdcall__));
  111. extern void (*menu_bar_activate)(menubar *) __attribute__((__stdcall__));
  112.  
  113. #endif /* KOLIBRI_MENUBAR_H */
  114.