2015-02-14 15:47:18 +03:00
|
|
|
/*
|
2016-01-25 00:16:08 +03:00
|
|
|
SOFTWARE CENTER v2.8
|
2015-02-14 15:47:18 +03:00
|
|
|
*/
|
|
|
|
|
2016-12-05 22:20:57 +03:00
|
|
|
#define MEMSIZE 4096 * 15
|
2015-02-14 15:47:18 +03:00
|
|
|
#include "..\lib\strings.h"
|
|
|
|
#include "..\lib\mem.h"
|
2016-02-19 16:34:31 +03:00
|
|
|
#include "..\lib\io.h"
|
2015-03-05 23:55:28 +03:00
|
|
|
#include "..\lib\gui.h"
|
2015-02-15 13:54:50 +03:00
|
|
|
|
2015-03-05 23:55:28 +03:00
|
|
|
#include "..\lib\obj\libio_lib.h"
|
|
|
|
#include "..\lib\obj\libimg_lib.h"
|
|
|
|
#include "..\lib\obj\libini.h"
|
2016-12-21 18:40:39 +03:00
|
|
|
#include "..\lib\kfont.h"
|
2016-01-25 00:16:08 +03:00
|
|
|
#include "..\lib\list_box.h"
|
|
|
|
#include "..\lib\collection.h"
|
2015-02-15 13:54:50 +03:00
|
|
|
#include "..\lib\patterns\libimg_load_skin.h"
|
2015-02-14 16:38:05 +03:00
|
|
|
|
2015-02-14 15:47:18 +03:00
|
|
|
proc_info Form;
|
2016-01-25 00:16:08 +03:00
|
|
|
llist list;
|
|
|
|
collection app_path_collection;
|
2015-02-19 00:09:29 +03:00
|
|
|
byte kolibrios_mounted;
|
|
|
|
|
2015-02-14 16:38:05 +03:00
|
|
|
int window_width,
|
2016-01-25 00:16:08 +03:00
|
|
|
window_height;
|
|
|
|
|
|
|
|
int list_pos,
|
|
|
|
row,
|
|
|
|
col,
|
|
|
|
default_icon;
|
2015-02-14 15:47:18 +03:00
|
|
|
|
2015-02-14 16:38:05 +03:00
|
|
|
char window_title[128],
|
2016-01-25 00:16:08 +03:00
|
|
|
settings_ini_path[256] = "/sys/settings/";
|
2015-02-14 15:47:18 +03:00
|
|
|
|
|
|
|
#define LIST_BACKGROUND_COLOR 0xF3F3F3
|
|
|
|
|
|
|
|
void load_config()
|
|
|
|
{
|
|
|
|
ini_get_str stdcall (#settings_ini_path, "Config", "window_title", #window_title, sizeof(window_title), "Software widget");
|
|
|
|
ini_get_int stdcall (#settings_ini_path, "Config", "window_width", 690);
|
|
|
|
window_width = EAX;
|
2016-01-25 00:16:08 +03:00
|
|
|
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;
|
2015-02-14 16:38:05 +03:00
|
|
|
ini_get_int stdcall (#settings_ini_path, "Config", "default_icon", 0);
|
|
|
|
default_icon = EAX;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2016-01-25 00:16:08 +03:00
|
|
|
dword id;
|
2016-12-21 22:50:13 +03:00
|
|
|
kfont.init(DEFAULT_FONT);
|
2015-07-29 23:43:05 +03:00
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
load_dll(libini, #lib_init,1);
|
2015-02-15 13:54:50 +03:00
|
|
|
|
2015-02-19 00:58:18 +03:00
|
|
|
Libimg_LoadImage(#skin, "/sys/icons32.png");
|
2015-02-15 13:54:50 +03:00
|
|
|
Libimg_FillTransparent(skin.image, skin.w, skin.h, LIST_BACKGROUND_COLOR);
|
2016-02-19 03:33:21 +03:00
|
|
|
kolibrios_mounted = dir_exists("/kolibrios");
|
2015-02-14 15:47:18 +03:00
|
|
|
|
2015-02-15 05:46:18 +03:00
|
|
|
if (param)
|
2015-02-15 05:39:54 +03:00
|
|
|
{
|
|
|
|
strcpy(#settings_ini_path, #param);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-21 23:25:00 +03:00
|
|
|
strcat(#settings_ini_path, I_Path + strrchr(I_Path, '/'));
|
2015-02-15 05:39:54 +03:00
|
|
|
strcat(#settings_ini_path, ".ini");
|
|
|
|
}
|
2016-01-25 00:16:08 +03:00
|
|
|
|
2015-02-14 15:47:18 +03:00
|
|
|
load_config();
|
2016-01-25 00:16:08 +03:00
|
|
|
list.cur_y = -1;
|
|
|
|
list.y = 32;
|
2015-02-14 15:47:18 +03:00
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
DrawList();
|
|
|
|
window_height = row+1*list.item_h + list_pos + skin_height + 15;
|
|
|
|
|
|
|
|
loop() switch(WaitEvent())
|
2015-02-14 15:47:18 +03:00
|
|
|
{
|
2016-01-25 00:16:08 +03:00
|
|
|
// case evKey:
|
|
|
|
// GetKeys();
|
|
|
|
// if (list.ProcessKey(key_scancode)) DrawList();
|
|
|
|
// break;
|
|
|
|
|
|
|
|
case evButton:
|
|
|
|
id=GetButtonID();
|
|
|
|
if (id==1) ExitProcess();
|
2016-02-19 16:34:31 +03:00
|
|
|
if (id>=100) EventRunApp(id-100);
|
2015-02-14 15:47:18 +03:00
|
|
|
break;
|
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
case evReDraw:
|
2015-08-04 17:36:07 +03:00
|
|
|
system.color.get();
|
2016-11-23 14:37:13 +03:00
|
|
|
DefineAndDrawWindow(screen.width-window_width/2,screen.height-window_height/2,window_width,window_height,0x74,system.color.work,"",0);
|
2015-02-14 15:47:18 +03:00
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2015-02-15 05:39:54 +03:00
|
|
|
if (Form.status_window>2) { DrawTitle(#window_title); break; } else DrawTitle("");
|
2015-12-26 14:03:17 +03:00
|
|
|
draw_top_bar();
|
2016-01-25 00:16:08 +03:00
|
|
|
DrawList();
|
|
|
|
DrawBar(0, row + 1 * list.item_h + list_pos, Form.cwidth, -row - 1 * list.item_h - list_pos + Form.cheight, LIST_BACKGROUND_COLOR);
|
2015-02-14 15:47:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
void DrawList() {
|
|
|
|
list.count = 0;
|
|
|
|
row = -1;
|
|
|
|
app_path_collection.drop();
|
|
|
|
list_pos = list.y;
|
|
|
|
list.column_max = window_width - 10 / list.item_w;
|
|
|
|
ini_enum_sections stdcall (#settings_ini_path, #process_sections);
|
|
|
|
list.visible = list.count;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name)
|
|
|
|
{
|
2015-02-14 16:38:05 +03:00
|
|
|
int tmp,
|
2016-01-25 00:16:08 +03:00
|
|
|
icon_id,
|
|
|
|
icon_char_pos;
|
2015-02-14 15:47:18 +03:00
|
|
|
|
2016-02-11 04:18:47 +03:00
|
|
|
//do not show items located in /kolibrios/ if this directory not mounted
|
|
|
|
if (!strncmp(key_value, "/kolibrios/", 11)) && (!kolibrios_mounted) return true;
|
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
if (col==list.column_max) {
|
2015-02-14 15:47:18 +03:00
|
|
|
row++;
|
|
|
|
col=0;
|
|
|
|
}
|
2015-02-19 00:09:29 +03:00
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
if (col==0) DrawBar(0, row * list.item_h + list_pos, Form.cwidth, list.item_h, LIST_BACKGROUND_COLOR);
|
|
|
|
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;
|
2015-02-14 16:38:05 +03:00
|
|
|
|
|
|
|
icon_char_pos = strchr(key_value, ',');
|
2015-07-29 20:44:24 +03:00
|
|
|
if (icon_char_pos) icon_id = atoi(icon_char_pos+1); else icon_id = default_icon;
|
2016-01-25 00:16:08 +03:00
|
|
|
img_draw stdcall(skin.image, col*list.item_w+tmp-10, row*list.item_h+5 + list_pos, 32, 32, 0, icon_id*32);
|
|
|
|
if (icon_char_pos) ESBYTE[icon_char_pos] = '\0'; //delete icon from string
|
|
|
|
app_path_collection.add(key_value);
|
2016-12-21 22:50:13 +03:00
|
|
|
//kfont.WriteIntoWindowCenter(col*list.item_w+7,row*list.item_h+47 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0xDCDCDC, 12, key_name);
|
|
|
|
kfont.WriteIntoWindowCenter(col*list.item_w+6,row*list.item_h+46 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0x000000, 12, key_name);
|
2016-01-25 00:16:08 +03:00
|
|
|
if (list.cur_y == list.count) DrawWideRectangle(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-5, 2, 0x0080FF);
|
|
|
|
list.count++;
|
2015-02-14 15:47:18 +03:00
|
|
|
col++;
|
2015-08-03 01:22:52 +03:00
|
|
|
return true;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
int old_row; //to detect empty sections
|
2015-02-19 00:09:29 +03:00
|
|
|
byte process_sections(dword sec_name, f_name)
|
2015-02-14 15:47:18 +03:00
|
|
|
{
|
2015-09-07 17:50:42 +03:00
|
|
|
int text_len;
|
2015-08-03 01:22:52 +03:00
|
|
|
if (!strcmp(sec_name, "Config")) return true;
|
2015-02-14 15:47:18 +03:00
|
|
|
|
2016-01-25 00:16:08 +03:00
|
|
|
if ((col==0) && (row==old_row))
|
2015-02-14 15:47:18 +03:00
|
|
|
{
|
2016-01-25 00:16:08 +03:00
|
|
|
list_pos -= 28;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-25 00:16:08 +03:00
|
|
|
row++;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
2016-01-25 00:16:08 +03:00
|
|
|
col = 0;
|
|
|
|
old_row = row;
|
|
|
|
DrawBar(0, row * list.item_h + list_pos, Form.cwidth , 29, LIST_BACKGROUND_COLOR);
|
2016-12-21 22:50:13 +03:00
|
|
|
text_len = kfont.WriteIntoWindow(10, row * list.item_h + 10 + list_pos, LIST_BACKGROUND_COLOR, 0, 15, sec_name);
|
2016-01-25 00:16:08 +03:00
|
|
|
DrawBar(text_len+20, row * list.item_h + list_pos + 20, Form.cwidth-text_len-20, 1, 0xDCDCDC);
|
|
|
|
DrawBar(text_len+20, row * list.item_h + list_pos + 21, Form.cwidth-text_len-20, 1, 0xFCFCFC);
|
|
|
|
list_pos += 29;
|
|
|
|
ini_enum_keys stdcall (f_name, sec_name, #draw_icons_from_section);
|
2015-08-03 01:22:52 +03:00
|
|
|
return true;
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void draw_top_bar()
|
|
|
|
{
|
2016-01-25 00:16:08 +03:00
|
|
|
DrawBar(0,0,Form.cwidth, list.y-2, system.color.work);
|
2016-02-09 04:48:21 +03:00
|
|
|
DrawBar(0,list.y-2, Form.cwidth, 1, MixColors(system.color.work, system.color.work_graph, 180));
|
2016-01-25 00:16:08 +03:00
|
|
|
DrawBar(0,list.y-1, Form.cwidth, 1, system.color.work_graph);
|
2016-12-21 22:50:13 +03:00
|
|
|
kfont.WriteIntoWindowCenter(0,5, Form.cwidth, list.y, system.color.work, system.color.work_text, 16, #window_title);
|
2015-02-14 15:47:18 +03:00
|
|
|
}
|
|
|
|
|
2016-02-19 16:34:31 +03:00
|
|
|
void EventRunApp(dword appid)
|
|
|
|
{
|
2017-09-06 19:55:37 +03:00
|
|
|
dword app_path = app_path_collection.get(appid);
|
|
|
|
|
|
|
|
dword param_pos = strchr(app_path, '|');
|
|
|
|
if (param_pos) {
|
|
|
|
ESBYTE[param_pos] = NULL;
|
|
|
|
param_pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_exists(app_path))
|
|
|
|
{
|
|
|
|
io.run(app_path, param_pos); //0 or offset
|
|
|
|
if (param_pos) ESBYTE[param_pos - 1] = '|';
|
2016-02-19 16:34:31 +03:00
|
|
|
}
|
2017-09-06 19:55:37 +03:00
|
|
|
else
|
|
|
|
{
|
2016-02-19 16:34:31 +03:00
|
|
|
notify("'Application not found' -E");
|
|
|
|
}
|
2017-09-06 19:55:37 +03:00
|
|
|
|
2016-02-19 16:34:31 +03:00
|
|
|
}
|
|
|
|
|
2015-02-14 15:47:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
stop:
|