//11.03.12 - start! //ver 2.2 #ifndef AUTOBUILD ?include "lang.h--" #endif #define MEMSIZE 0xFE800 #include "..\lib\mem.h" #include "..\lib\strings.h" #include "..\lib\io.h" #include "..\lib\list_box.h" #include "..\lib\gui.h" #include "..\lib\obj\box_lib.h" #include "..\lib\obj\proc_lib.h" #include "..\lib\patterns\select_list.h" #include "..\lib\patterns\simple_open_dialog.h" #include "ini.h" //===================================================// // // // DATA // // // //===================================================// #ifdef LANG_RUS ?define WINDOW_HEADER "Настройки оформления" ?define T_SKINS "Стиль окон" ?define T_WALLPAPERS "Обои" ?define T_SELECT_FOLDER "Выбрать папку" ?define MENU_LIST "Открыть файл Enter\nУдалить файл Del" #else ?define WINDOW_HEADER "Appearance" ?define T_SKINS "Skins" ?define T_WALLPAPERS "Wallpapers" ?define T_SELECT_FOLDER "Select wallpapers" ?define MENU_LIST "Open file Enter\nDelete file Del" #endif #define PANEL_H 40 #define LP 10 //LIST_PADDING char skins_folder_path[4096] = "/kolibrios/res/skins"; char wallp_folder_path[4096] = "/kolibrios/res/wallpapers"; signed int active_skin=-1, active_wallpaper=-1; enum { SKINS=2, WALLPAPERS, BTN_SELECT_WALLP_FOLDER }; char folder_path[4096]; char cur_file_path[4096]; char temp_filename[4096]; int files_mas[400]; int cur; proc_info Form; block skp; _tabs tabs = { LP, LP, NULL, NULL, SKINS }; checkbox checkbox1 = { "Checkbox", true }; more_less_box spinbox1 = { 23, 0, 999, "SpinBox" }; edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff, 0x10000000,sizeof(param)-2,#param,0, 0b}; char st_str[16]; edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff, 0x10000000,sizeof(st_str)-2,#st_str,0, 0b}; char default_dir[] = "/rd/1"; od_filter filter2 = { 8, "TXT\0\0" }; //===================================================// // // // CODE // // // //===================================================// void main() { int id, mouse_clicked; load_dll(boxlib, #box_lib_init,0); load_dll(libini, #lib_init,1); load_dll(Proc_lib, #OpenDialog_init,0); o_dialog.type = 2; //select folder OpenDialog_init stdcall (#o_dialog); EventTabClick(SKINS); SetEventMask(0x27); loop() switch(WaitEvent()) { case evMouse: if (!CheckActiveProcess(Form.ID)) break; SelectList_ProcessMouse(); if (tabs.active_tab == SKINS) { edit_box_mouse stdcall (#edit_cmm); edit_box_mouse stdcall (#edit_st); } if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) { select_list.ProcessMouse(mouse.x, mouse.y); SelectList_Draw(); EventSetNewCurrent(); menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 146, MENU_LIST, 10); } break; case evButton: id=GetButtonID(); if (id==1) ExitProcess(); if (id==SKINS) EventTabClick(SKINS); if (id==WALLPAPERS) EventTabClick(WALLPAPERS); if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder(); checkbox1.click(id); spinbox1.click(id); break; case evKey: GetKeys(); if (select_list.ProcessKey(key_scancode)) EventApply(); if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); if (key_scancode==SCAN_CODE_TAB) { if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS); } if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus) for (id=select_list.cur_y+1; id=2) return; DrawWindowContent(); } void DrawWindowContent() { int id; incn y; int list_w; if (tabs.active_tab == SKINS) list_w=250; else list_w=370; DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work); tabs.w = Form.cwidth-LP-LP; tabs.h = Form.cheight-LP-LP; tabs.draw_wrapper(); tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS); tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS); id = select_list.cur_y; SelectList_Init( tabs.x+TAB_PADDING, tabs.y+TAB_HEIGHT+TAB_PADDING, list_w, tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, false ); select_list.cur_y = id; skp.set_size( select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20, select_list.y + 30, list_w, select_list.h - 50 ); SelectList_Draw(); SelectList_DrawBorder(); if (tabs.active_tab == SKINS) { DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work); DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph); y.n = skp.y; DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview "); checkbox1.draw(skp.x+20, y.inc(30)); spinbox1.draw(skp.x+20, y.inc(30)); WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "C-- Edit"); DrawEditBoxPos(skp.x+20, y.inc(20), #edit_cmm); WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit"); DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st); DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1"); DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2"); } if (tabs.active_tab == WALLPAPERS) { DrawStandartCaptButton(select_list.x + select_list.w + scroll1.size_x + 17, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER); } } :void DrawStEditBoxPos(dword x,y, edit_box_pointer) { dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128); dword c_active = MixColors(system.color.work_graph, 0, 128); ESI = edit_box_pointer; ESI.edit_box.left = x; ESI.edit_box.top = y; ESI.edit_box.blur_border_color = c_inactive; ESI.edit_box.focus_border_color = c_active; edit_box_draw stdcall (edit_box_pointer); } void Open_Dir() { int j; select_list.count = 0; if(io.dir.buffer)free(io.dir.buffer); io.dir.load(#folder_path,DIR_ONLYREAL); for (j=0; jselect_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); if (select_list.w) DrawWindowContent(); } void EventDeleteFile() { io.del(#cur_file_path); Open_Dir(); EventApply(); } void EventSetNewCurrent() { cur = select_list.cur_y; sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); } void EventSelectWallpFolder() { OpenDialog_start stdcall (#o_dialog); if (o_dialog.status) { strcpy(#wallp_folder_path, #opendir_path); EventTabClick(WALLPAPERS); } } void EventApply() { char kivpath[4096+10]; EventSetNewCurrent(); if (tabs.active_tab==SKINS) { cur = select_list.cur_y; SetSystemSkin(#cur_file_path); SaveSkinSettings(#cur_file_path); } if (tabs.active_tab==WALLPAPERS) { strcpy(#kivpath, "\\S__"); strcat(#kivpath, #cur_file_path); RunProgram("/sys/media/kiv", #kivpath); SelectList_Draw(); } } void EventOpenFile() { if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); } stop: