Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7795 → Rev 7796

/programs/cmm/menu/menu.c
7,6 → 7,7
#include "../lib/fs.h"
 
#define ITEM_H 19
#define SEP_H 4
 
llist menu1;
collection names;
16,6 → 17,7
 
int max_name_len;
int max_hotkey_len;
int menu_w, menu_h;
 
void GetWindowPosition()
{
70,6 → 72,33
if (next_name) GetMenuItems(next_name+2);
}
 
int GetSeparatorsCount()
{
int i, count=0;
for (i=0; i<names.count; i++) {
if (streq(names.get(i), "-")) count++;
}
return count;
}
 
int MoveMouseToHandleSeparators(int _mouse_y)
{
int i, item_y=menu1.y;
int item_i=0;
for (i=0; i<menu1.count; i++;)
{
if (streq(names.get(i), "-")) {
item_y += SEP_H;
} else {
item_y += ITEM_H;
item_i++;
}
if (_mouse_y >= item_y) && (_mouse_y < item_y + ITEM_H) {
return item_i * ITEM_H + menu1.y;
}
}
}
 
void main()
{
proc_info Form;
79,9 → 108,13
GetMenuItems(#param);
GetMenuWidths();
 
menu_w = max_name_len + max_hotkey_len + 23;
menu_h = GetSeparatorsCount() * SEP_H
+ calc(names.count - GetSeparatorsCount() * ITEM_H);
 
menu1.count = names.count;
menu1.SetFont(6, 9, 0x80);
menu1.SetSizes(2,2, max_name_len + max_hotkey_len + 23, menu1.count*ITEM_H, ITEM_H);
menu1.SetSizes(2,2, menu_w, menu_h, ITEM_H);
menu1.cur_y = -1;
 
GetWindowPosition();
93,8 → 126,11
GetProcessInfo(#Form, SelfInfo);
if (!CheckActiveProcess(Form.ID)) exit();
mouse.get();
if (menu1.MouseOver(mouse.x, mouse.y)) {
mouse.y = MoveMouseToHandleSeparators(mouse.y);
if (menu1.ProcessMouse(mouse.x, mouse.y)) draw_list();
if (mouse.lkm)&&(mouse.up) click();
}
break;
 
case evKey:
121,7 → 157,8
click();
 
case SCAN_CODE_DOWN:
if (!menu1.KeyDown()) menu1.KeyHome();
if (!menu1.KeyDown())
|| (menu1.count - menu1.cur_y - GetSeparatorsCount() -1 < 0) menu1.KeyHome();
draw_list();
break;
 
137,7 → 174,7
 
void draw_list()
{
int i, item_y;
int i, item_y=menu1.y, item_i=0;
dword name_color;
dword hotkey_color;
 
159,8 → 196,14
 
for (i=0; i<menu1.count; i++;)
{
item_y = i*ITEM_H+menu1.y;
if (i==menu1.cur_y) {
if (streq(names.get(i), "-")) {
DrawBar(menu1.x, item_y+0, menu1.w, 1, inactive_background_color);
DrawBar(menu1.x, item_y+1, menu1.w, 1, system.color.work_dark);
DrawBar(menu1.x, item_y+2, menu1.w, 1, system.color.work_light);
DrawBar(menu1.x, item_y+3, menu1.w, 1, inactive_background_color);
item_y += SEP_H;
} else {
if (item_i==menu1.cur_y) {
hotkey_color = name_color = system.color.work_button_text;
DrawBar(menu1.x, item_y+1, menu1.w, ITEM_H-2, active_background_color);
DrawBar(menu1.x, item_y, menu1.w, 1, active_top_border_color);
175,7 → 218,10
WriteText(-strlen(hotkeys.get(i))*6 + 13 + max_name_len + max_hotkey_len,
item_y + menu1.text_y, 0x80, hotkey_color, hotkeys.get(i));
WriteText(13, item_y + menu1.text_y, 0x80, name_color, names.get(i));
item_y += ITEM_H;
item_i++;
}
}
if (selected) WriteText(5, selected-1*ITEM_H + menu1.y + menu1.text_y, 0x80, 0xEE0000, "\x10");
}