Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7768 → Rev 7769

/programs/cmm/lib/kfont.h
103,12 → 103,12
return true;
}
 
:dword KFONT::getsize(byte fontSizePoints, dword text1)
:dword KFONT::getsize(byte font_size, dword text1)
{
size.height = size.width = 0;
size.offset_x = size.offset_y = -1;
if (size.pt != fontSizePoints) {
size.pt = fontSizePoints;
if (size.pt != font_size) {
size.pt = font_size;
if(!changeSIZE())return 0;
}
WHILE(DSBYTE[text1])
123,7 → 123,7
return size.width;
}
 
//WILL NOT WORK if requested fontSizePoints
//WILL NOT WORK if requested font_size
//is differ from precalculated kfont_char_width[]
:int KFONT::get_label_width(dword _label)
{
242,13 → 242,13
}
}
 
:void KFONT::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
:void KFONT::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte font_size; dword text1)
{
dword new_raw_size;
if(!text1)return;
if (size.pt != fontSizePoints) {
getsize(fontSizePoints, text1);
if (size.pt != font_size) {
getsize(font_size, text1);
y -= size.offset_y;
}
color = _color;
277,22 → 277,22
return;
}
 
:int KFONT::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1)
:int KFONT::WriteIntoWindow(int x,y; dword _background, _color; byte font_size; dword text1)
{
if(!text1)return 0;
getsize(fontSizePoints, text1);
getsize(font_size, text1);
raw_size = NULL;
WriteIntoBuffer(0, -size.offset_y, size.width-size.offset_x,
size.height-size.offset_y, _background, _color, fontSizePoints, text1);
size.height-size.offset_y, _background, _color, font_size, text1);
if (smooth) ApplySmooth();
ShowBuffer(x,y);
return size.offset_x + size.width;
}
 
:int KFONT::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
:int KFONT::WriteIntoWindowCenter(dword x, _y,w,h, _background, _color; byte font_size; dword text1)
{
getsize(fontSizePoints, text1);
return WriteIntoWindow(w-size.width/2+x-1,y, _background, _color, fontSizePoints, text1);
getsize(font_size, text1);
return WriteIntoWindow(w-size.width/2+x-1, _y, _background, _color, font_size, text1);
}
 
:void KFONT::ShowBuffer(dword _x, _y)
/programs/cmm/software_widget/software_widget.c
18,7 → 18,7
proc_info Form;
llist list;
collection app_path_collection;
byte kolibrios_mounted;
bool kolibrios_mounted;
 
int window_width,
window_height;
29,7 → 29,7
default_icon;
 
char window_title[128],
settings_ini_path[256] = "/sys/settings/";
settings_ini_path[256];
 
bool small_screen = false;
 
42,22 → 42,20
dword light;
} swc;
 
block ipos[128];
block selection[128];
 
void load_config()
void load_ini_config(dword _ini_path)
{
ini_get_str stdcall (#settings_ini_path, "Config", "title", #window_title, sizeof(window_title), "Software widget");
ini_get_int stdcall (#settings_ini_path, "Config", "win_width", 690);
window_width = EAX;
ini_get_int stdcall (#settings_ini_path, "Config", "cell_w", 73);
list.item_w = EAX;
ini_get_int stdcall (#settings_ini_path, "Config", "cell_h", 71);
list.item_h = EAX;
ini_get_int stdcall (#settings_ini_path, "Config", "default_icon", 2);
default_icon = EAX;
_ini ini;
ini.path = _ini_path;
ini.section = "Config";
ini.GetString("title", #window_title, sizeof(window_title), "Software widget");
window_width = ini.GetInt("win_width", 690);
list.item_w = ini.GetInt("cell_w", 73);
list.item_h = ini.GetInt("cell_h", 71);
default_icon = ini.GetInt("default_icon", 2);
}
 
 
void main()
{
dword id;
68,17 → 66,15
 
kolibrios_mounted = dir_exists("/kolibrios");
 
if (param)
{
if (param) {
strcpy(#settings_ini_path, #param);
}
else
{
} else {
strcpy(#settings_ini_path, "/sys/settings/");
strcat(#settings_ini_path, I_Path + strrchr(I_Path, '/'));
strcat(#settings_ini_path, ".ini");
}
load_config();
load_ini_config(#settings_ini_path);
list.cur_y = -1;
list.y = 32;
 
98,13 → 94,13
if (SCAN_CODE_LEFT == key_scancode) key_scancode = SCAN_CODE_UP;
if (SCAN_CODE_RIGHT == key_scancode) key_scancode = SCAN_CODE_DOWN;
if (list.ProcessKey(key_scancode)) DrawSelection();
if (SCAN_CODE_ENTER == key_scancode) EventRunApp(list.cur_y);
if (SCAN_CODE_ENTER == key_scancode) EventIconClick(list.cur_y);
break;
 
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
if (id>=100) EventRunApp(id-100);
if (id>=100) EventIconClick(id-100);
break;
 
case evReDraw:
120,7 → 116,7
list.y = 0;
} else {
DrawTitle(NULL);
draw_top_bar();
DrawTopBar();
}
DrawList();
DrawBar(0, row +1 * list.item_h + list_pos, Form.cwidth, -row - 1 * list.item_h - list_pos + Form.cheight, swc.list_bg);
169,11 → 165,12
 
byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name)
{
int tmp,
icon_id,
int icon_id = default_icon,
icon_char_pos;
int text_w;
int space_pos;
 
dword icon_x, icon_y, text_x, text_y;
 
//do not show items located in /kolibrios/ if this directory not mounted
if (!strncmp(key_value, "/kolibrios/", 11)) || (!strncmp(key_value, "/k/", 3))
if (!kolibrios_mounted) return true;
184,19 → 181,28
}
 
if (col==0) DrawBar(0, row * list.item_h + list_pos, Form.cwidth, list.item_h, swc.list_bg);
DefineButton(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-5,list.count + 100 + BT_HIDE,0);
tmp = list.item_w/2;
DefineButton(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-3,list.count + 100 + BT_HIDE,0);
 
icon_char_pos = strchr(key_value, ',');
if (icon_char_pos) icon_id = atoi(icon_char_pos+1); else icon_id = default_icon;
img_draw stdcall(skin.image, col*list.item_w+tmp-10, row*list.item_h+5 + list_pos, 32, 32, 0, icon_id*32);
icon_x = col*list.item_w+calc(list.item_w/2)-10;
icon_y = row*list.item_h+5 + list_pos;
selection[list.count].x = icon_x-2;
selection[list.count].y = icon_y-2;
if (icon_char_pos) ESBYTE[icon_char_pos] = '\0'; //delete icon from string
app_path_collection.add(key_value);
//kfont.WriteIntoWindowCenter(col*list.item_w+7,row*list.item_h+47 + list_pos, list.item_w,0, swc.list_bg, swc.dark, 12, key_name);
text_w = kfont.WriteIntoWindowCenter(col*list.item_w+5,row*list.item_h+46 + list_pos, list.item_w,0, swc.list_bg, swc.text, 12, key_name);
ipos[list.count].x = list.item_w-text_w/2+calc(col*list.item_w)+5;
ipos[list.count].y = row*list.item_h+46 + list_pos + 16;
ipos[list.count].w = text_w;
 
text_x = col*list.item_w+5;
text_y = list.item_h - 40 / 2;
if (kfont.getsize(key_name)+30<list.item_w) || (!strchr(key_name, ' ')) {
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos, list.item_w,0, swc.list_bg, swc.text, 12, key_name);
} else {
space_pos = strrchr(key_name, ' ');
ESBYTE[key_name+space_pos-1] = '\0';
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos - 2, list.item_w,0, swc.list_bg, swc.text, 12, key_name);
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos + 14, list.item_w,0, swc.list_bg, swc.text, 12, key_name+space_pos);
}
if (icon_char_pos) icon_id = atoi(icon_char_pos+1);
img_draw stdcall(skin.image, icon_x, icon_y, 32, 32, 0, icon_id*32);
list.count++;
col++;
return true;
231,7 → 237,7
return true;
}
 
void draw_top_bar()
void DrawTopBar()
{
DrawBar(0,0,Form.cwidth, list.y-2, system.color.work);
DrawBar(0,list.y-2, Form.cwidth, 1, MixColors(system.color.work, system.color.work_graph, 180));
239,7 → 245,7
kfont.WriteIntoWindowCenter(0,5, Form.cwidth, list.y, system.color.work, system.color.work_text, 16, #window_title);
}
 
void EventRunApp(dword appid)
void EventIconClick(dword appid)
{
char run_app_path[4096]=0;
dword app_path = app_path_collection.get(appid);
264,13 → 270,10
strcat(#run_app_path, app_path);
// }end
 
if (file_exists(#run_app_path))
{
if (file_exists(#run_app_path)) {
io.run(#run_app_path, param_pos); //0 or offset
if (param_pos) ESBYTE[param_pos - 1] = '|';
}
else
{
} else {
notify("'Application not found' -E");
}
}
281,7 → 284,7
dword col;
for (i=0; i<list.count; i++) {
if (i==list.cur_y) col=0x0080FF; else col=swc.list_bg;
DrawBar(ipos[i].x, ipos[i].y, ipos[i].w+2, 3, col);
DrawWideRectangle(selection[i].x, selection[i].y, 36, 36, 2, col);
}
}