Rev 7244 | Rev 7254 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4078 | leency | 1 | //11.03.12 - start! |
6212 | leency | 2 | //ver 2.0 |
4078 | leency | 3 | |
4085 | leency | 4 | #ifndef AUTOBUILD |
5 | ?include "lang.h--" |
||
6 | #endif |
||
7 | |||
4078 | leency | 8 | #define MEMSIZE 0xFE800 |
9 | #include "..\lib\mem.h" |
||
4085 | leency | 10 | #include "..\lib\strings.h" |
5654 | leency | 11 | #include "..\lib\io.h" |
4078 | leency | 12 | #include "..\lib\list_box.h" |
6212 | leency | 13 | #include "..\lib\menu.h" |
5499 | leency | 14 | #include "..\lib\gui.h" |
15 | #include "..\lib\obj\box_lib.h" |
||
6651 | leency | 16 | #include "..\lib\patterns\select_list.h" |
4078 | leency | 17 | |
6212 | leency | 18 | |
19 | //===================================================// |
||
20 | // // |
||
21 | // DATA // |
||
22 | // // |
||
23 | //===================================================// |
||
24 | |||
4085 | leency | 25 | #ifdef LANG_RUS |
6212 | leency | 26 | ?define WINDOW_HEADER "Настройки оформления" |
6264 | leency | 27 | ?define T_SKINS "Стиль окон" |
28 | ?define T_WALLPAPERS "Обои" |
||
4085 | leency | 29 | #else |
30 | ?define WINDOW_HEADER "Appearance" |
||
6264 | leency | 31 | ?define T_SKINS "Skins" |
32 | ?define T_WALLPAPERS "Wallpappers" |
||
4085 | leency | 33 | #endif |
4078 | leency | 34 | |
6212 | leency | 35 | #define PANEL_H 40 |
7225 | leency | 36 | #define LP 10 //LIST_PADDING |
5765 | leency | 37 | #define SKINS_STANDART_PATH "/kolibrios/res/skins" |
4885 | leency | 38 | #define WALP_STANDART_PATH "/kolibrios/res/wallpapers" |
4078 | leency | 39 | |
6264 | leency | 40 | signed int active_skin=-1, active_wallpaper=-1; |
6212 | leency | 41 | enum { SKINS=2, WALLPAPERS }; |
4078 | leency | 42 | |
43 | char folder_path[4096]; |
||
44 | char cur_file_path[4096]; |
||
45 | char temp_filename[4096]; |
||
6096 | leency | 46 | int files_mas[400]; |
4078 | leency | 47 | |
48 | int cur; |
||
49 | |||
50 | proc_info Form; |
||
7244 | leency | 51 | block skp; |
4078 | leency | 52 | |
7225 | leency | 53 | _tabs tabs = { LP, LP, NULL, NULL, SKINS }; |
54 | |||
7244 | leency | 55 | checkbox checkbox1 = { "Checkbox", true }; |
7252 | leency | 56 | more_less_box spinbox1 = { 23, 0, 999, "SpinBox" }; |
57 | edit_box edit1 = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
||
58 | 0x10000000,sizeof(param),#param,0, 0b}; |
||
7244 | leency | 59 | |
60 | #define MENU_LIST "Open file Enter\nDelete Del" |
||
61 | |||
6212 | leency | 62 | //===================================================// |
63 | // // |
||
64 | // CODE // |
||
65 | // // |
||
66 | //===================================================// |
||
5548 | leency | 67 | |
4078 | leency | 68 | void main() |
69 | { |
||
5705 | punk_joker | 70 | int id, mouse_clicked; |
4078 | leency | 71 | |
4410 | leency | 72 | SetEventMask(0x27); |
5626 | leency | 73 | load_dll(boxlib, #box_lib_init,0); |
6212 | leency | 74 | EventTabClick(SKINS); |
6096 | leency | 75 | loop() switch(WaitEvent()) |
4078 | leency | 76 | { |
77 | case evMouse: |
||
4085 | leency | 78 | if (!CheckActiveProcess(Form.ID)) break; |
6653 | leency | 79 | SelectList_ProcessMouse(); |
7252 | leency | 80 | edit_box_mouse stdcall (#edit1); |
4410 | leency | 81 | |
7244 | leency | 82 | if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) { |
6651 | leency | 83 | select_list.ProcessMouse(mouse.x, mouse.y); |
6653 | leency | 84 | SelectList_Draw(); |
7244 | leency | 85 | menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10); |
6212 | leency | 86 | } |
4078 | leency | 87 | break; |
88 | |||
89 | case evButton: |
||
90 | id=GetButtonID(); |
||
91 | if (id==1) ExitProcess(); |
||
6212 | leency | 92 | if (id==SKINS) EventTabClick(SKINS); |
93 | if (id==WALLPAPERS) EventTabClick(WALLPAPERS); |
||
7244 | leency | 94 | checkbox1.click(id); |
7252 | leency | 95 | spinbox1.click(id); |
4078 | leency | 96 | break; |
97 | |||
98 | case evKey: |
||
5706 | leency | 99 | GetKeys(); |
6651 | leency | 100 | if (select_list.ProcessKey(key_scancode)) EventApply(); |
6212 | leency | 101 | if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); |
7225 | leency | 102 | if (key_scancode==SCAN_CODE_TAB) |
103 | if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); |
||
104 | else EventTabClick(SKINS); |
||
6212 | leency | 105 | if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); |
6651 | leency | 106 | for (id=select_list.cur_y+1; id |
4078 | leency | 107 | { |
6212 | leency | 108 | strcpy(#temp_filename, io.dir.position(files_mas[id])); |
109 | if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32) |
||
110 | { |
||
6651 | leency | 111 | select_list.cur_y = id - 1; |
112 | select_list.KeyDown(); |
||
6212 | leency | 113 | EventApply(); |
114 | break; |
||
115 | } |
||
4078 | leency | 116 | } |
7252 | leency | 117 | EAX= key_ascii << 8; |
118 | edit_box_key stdcall (#edit1); |
||
4078 | leency | 119 | break; |
120 | |||
121 | case evReDraw: |
||
5674 | pavelyakov | 122 | system.color.get(); |
7252 | leency | 123 | DefineAndDrawWindow(screen.width-600/2,80,630,404+skin_height,0x74,0xE4DFE1,WINDOW_HEADER,0); |
4078 | leency | 124 | GetProcessInfo(#Form, SelfInfo); |
125 | IF (Form.status_window>=2) break; |
||
6212 | leency | 126 | DrawWindowContent(); |
127 | if (menu.list.cur_y) { |
||
128 | if (menu.list.cur_y == 10) EventOpenFile(); |
||
129 | if (menu.list.cur_y == 11) EventDeleteFile(); |
||
130 | menu.list.cur_y = 0; |
||
131 | }; |
||
4078 | leency | 132 | } |
133 | } |
||
134 | |||
7244 | leency | 135 | |
6212 | leency | 136 | void DrawWindowContent() |
137 | { |
||
138 | int id; |
||
7252 | leency | 139 | incn y; |
7225 | leency | 140 | |
141 | DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work); |
||
142 | |||
143 | tabs.w = Form.cwidth-LP-LP; |
||
144 | tabs.h = Form.cheight-LP-LP; |
||
145 | tabs.draw_wrapper(); |
||
146 | |||
7226 | leency | 147 | tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS); |
148 | tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS); |
||
7225 | leency | 149 | |
6651 | leency | 150 | id = select_list.cur_y; |
6653 | leency | 151 | SelectList_Init( |
7225 | leency | 152 | tabs.x+TAB_PADDING, |
153 | tabs.y+TAB_HEIGHT+TAB_PADDING, |
||
7244 | leency | 154 | 250, |
7225 | leency | 155 | tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, |
6653 | leency | 156 | false |
157 | ); |
||
6651 | leency | 158 | select_list.cur_y = id; |
7244 | leency | 159 | |
160 | skp.set_size( |
||
7252 | leency | 161 | select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20, |
162 | select_list.y + 30, |
||
7244 | leency | 163 | 250, |
7252 | leency | 164 | select_list.h - 50 |
7244 | leency | 165 | ); |
166 | |||
6653 | leency | 167 | SelectList_Draw(); |
6662 | leency | 168 | SelectList_DrawBorder(); |
7244 | leency | 169 | |
170 | if (tabs.active_tab == SKINS) |
||
171 | { |
||
7252 | leency | 172 | DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work); |
173 | DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph); |
||
174 | y.n = skp.y; |
||
7244 | leency | 175 | DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview "); |
7252 | leency | 176 | checkbox1.draw(skp.x+20, y.inc(30)); |
177 | spinbox1.draw(skp.x+20, y.inc(30)); |
||
178 | WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "Edit box"); |
||
179 | DrawEditBoxPos(skp.x+20, y.inc(20), #edit1); |
||
180 | DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1"); |
||
181 | DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2"); |
||
7244 | leency | 182 | } |
6212 | leency | 183 | } |
184 | |||
4410 | leency | 185 | |
6212 | leency | 186 | |
187 | void Open_Dir() |
||
4078 | leency | 188 | { |
6212 | leency | 189 | int j; |
6651 | leency | 190 | select_list.count = 0; |
6212 | leency | 191 | if(io.dir.buffer)free(io.dir.buffer); |
192 | io.dir.load(#folder_path,DIR_ONLYREAL); |
||
193 | for (j=0; j |
||
4410 | leency | 194 | { |
6212 | leency | 195 | strcpy(#temp_filename, io.dir.position(j)); |
196 | strlwr(#temp_filename); |
||
6264 | leency | 197 | if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue; |
198 | if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue; |
||
6651 | leency | 199 | cur = select_list.count; |
6212 | leency | 200 | files_mas[cur]=j; |
6651 | leency | 201 | if (!strcmpi("default.skn",#temp_filename)) files_mas[0]> |
202 | select_list.count++; |
||
4410 | leency | 203 | } |
6212 | leency | 204 | } |
205 | |||
6653 | leency | 206 | void SelectList_DrawLine(dword i) |
6212 | leency | 207 | { |
6651 | leency | 208 | int yyy, list_last; |
6212 | leency | 209 | |
6651 | leency | 210 | cur = select_list.first + i; |
211 | strcpy(#temp_filename, io.dir.position(files_mas[cur])); |
||
212 | temp_filename[strlen(#temp_filename)-4] = 0; |
||
213 | yyy = i*select_list.item_h+select_list.y; |
||
214 | |||
215 | if (select_list.cur_y-select_list.first==i) |
||
4410 | leency | 216 | { |
6651 | leency | 217 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button); |
218 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename); |
||
4410 | leency | 219 | } |
6651 | leency | 220 | else |
221 | { |
||
222 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
||
223 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename); |
||
224 | } |
||
4078 | leency | 225 | } |
226 | |||
6653 | leency | 227 | void SelectList_LineChanged() |
228 | { |
||
229 | EventApply(); |
||
230 | } |
||
231 | |||
6212 | leency | 232 | //===================================================// |
233 | // // |
||
234 | // EVENTS // |
||
235 | // // |
||
236 | //===================================================// |
||
4078 | leency | 237 | |
6212 | leency | 238 | void EventTabClick(int N) |
4085 | leency | 239 | { |
6264 | leency | 240 | tabs.click(N); |
241 | if (tabs.active_tab == SKINS) |
||
6212 | leency | 242 | { |
6651 | leency | 243 | active_wallpaper = select_list.cur_y; |
6212 | leency | 244 | strcpy(#folder_path, SKINS_STANDART_PATH); |
6651 | leency | 245 | select_list.ClearList(); |
6212 | leency | 246 | Open_Dir(); |
6651 | leency | 247 | if (!select_list.count) notify("'No skins were found' -E"); |
248 | select_list.cur_y = active_skin; |
||
6212 | leency | 249 | } |
6264 | leency | 250 | if (tabs.active_tab == WALLPAPERS) |
6212 | leency | 251 | { |
6651 | leency | 252 | active_skin = select_list.cur_y; |
6212 | leency | 253 | strcpy(#folder_path, WALP_STANDART_PATH); |
6651 | leency | 254 | select_list.ClearList(); |
6212 | leency | 255 | Open_Dir(); |
6651 | leency | 256 | if (!select_list.count) notify("'No wallpapers were found' -E"); |
257 | select_list.cur_y = active_wallpaper; |
||
6212 | leency | 258 | } |
6651 | leency | 259 | if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); |
260 | if (select_list.w) DrawWindowContent(); |
||
6212 | leency | 261 | } |
4078 | leency | 262 | |
6212 | leency | 263 | void EventDeleteFile() |
264 | { |
||
265 | io.del(#cur_file_path); |
||
266 | Open_Dir(); |
||
267 | EventApply(); |
||
268 | } |
||
4078 | leency | 269 | |
6212 | leency | 270 | void EventApply() |
271 | { |
||
6264 | leency | 272 | if (tabs.active_tab==SKINS) |
6212 | leency | 273 | { |
6651 | leency | 274 | cur = select_list.cur_y; |
6212 | leency | 275 | sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
276 | SetSystemSkin(#cur_file_path); |
||
277 | } |
||
6264 | leency | 278 | if (tabs.active_tab==WALLPAPERS) |
6212 | leency | 279 | { |
6651 | leency | 280 | cur = select_list.cur_y; |
6212 | leency | 281 | sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
282 | RunProgram("/sys/media/kiv", #cur_file_path); |
||
6653 | leency | 283 | SelectList_Draw(); |
6212 | leency | 284 | } |
285 | } |
||
4085 | leency | 286 | |
6212 | leency | 287 | void EventOpenFile() |
288 | { |
||
6264 | leency | 289 | if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); |
290 | if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); |
||
4085 | leency | 291 | } |
292 | |||
4078 | leency | 293 | stop: |