Rev 7226 | Rev 7252 | 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 }; |
56 | |||
57 | #define MENU_LIST "Open file Enter\nDelete Del" |
||
58 | |||
6212 | leency | 59 | //===================================================// |
60 | // // |
||
61 | // CODE // |
||
62 | // // |
||
63 | //===================================================// |
||
5548 | leency | 64 | |
4078 | leency | 65 | void main() |
66 | { |
||
5705 | punk_joker | 67 | int id, mouse_clicked; |
4078 | leency | 68 | |
4410 | leency | 69 | SetEventMask(0x27); |
5626 | leency | 70 | load_dll(boxlib, #box_lib_init,0); |
6212 | leency | 71 | EventTabClick(SKINS); |
6096 | leency | 72 | loop() switch(WaitEvent()) |
4078 | leency | 73 | { |
74 | case evMouse: |
||
4085 | leency | 75 | if (!CheckActiveProcess(Form.ID)) break; |
6653 | leency | 76 | SelectList_ProcessMouse(); |
4410 | leency | 77 | |
7244 | leency | 78 | if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) { |
6651 | leency | 79 | select_list.ProcessMouse(mouse.x, mouse.y); |
6653 | leency | 80 | SelectList_Draw(); |
7244 | leency | 81 | menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10); |
6212 | leency | 82 | } |
4078 | leency | 83 | break; |
84 | |||
85 | case evButton: |
||
86 | id=GetButtonID(); |
||
87 | if (id==1) ExitProcess(); |
||
6212 | leency | 88 | if (id==SKINS) EventTabClick(SKINS); |
89 | if (id==WALLPAPERS) EventTabClick(WALLPAPERS); |
||
7244 | leency | 90 | checkbox1.click(id); |
4078 | leency | 91 | break; |
92 | |||
93 | case evKey: |
||
5706 | leency | 94 | GetKeys(); |
6651 | leency | 95 | if (select_list.ProcessKey(key_scancode)) EventApply(); |
6212 | leency | 96 | if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); |
7225 | leency | 97 | if (key_scancode==SCAN_CODE_TAB) |
98 | if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); |
||
99 | else EventTabClick(SKINS); |
||
6212 | leency | 100 | if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); |
6651 | leency | 101 | for (id=select_list.cur_y+1; id |
4078 | leency | 102 | { |
6212 | leency | 103 | strcpy(#temp_filename, io.dir.position(files_mas[id])); |
104 | if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32) |
||
105 | { |
||
6651 | leency | 106 | select_list.cur_y = id - 1; |
107 | select_list.KeyDown(); |
||
6212 | leency | 108 | EventApply(); |
109 | break; |
||
110 | } |
||
4078 | leency | 111 | } |
112 | break; |
||
113 | |||
114 | case evReDraw: |
||
5674 | pavelyakov | 115 | system.color.get(); |
7244 | leency | 116 | DefineAndDrawWindow(screen.width-600/2,80,600,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
4078 | leency | 117 | GetProcessInfo(#Form, SelfInfo); |
118 | IF (Form.status_window>=2) break; |
||
6212 | leency | 119 | DrawWindowContent(); |
120 | if (menu.list.cur_y) { |
||
121 | if (menu.list.cur_y == 10) EventOpenFile(); |
||
122 | if (menu.list.cur_y == 11) EventDeleteFile(); |
||
123 | menu.list.cur_y = 0; |
||
124 | }; |
||
4078 | leency | 125 | } |
126 | } |
||
127 | |||
7244 | leency | 128 | |
6212 | leency | 129 | void DrawWindowContent() |
130 | { |
||
131 | int id; |
||
7225 | leency | 132 | |
133 | DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work); |
||
134 | |||
135 | tabs.w = Form.cwidth-LP-LP; |
||
136 | tabs.h = Form.cheight-LP-LP; |
||
137 | tabs.draw_wrapper(); |
||
138 | |||
7226 | leency | 139 | tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS); |
140 | tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS); |
||
7225 | leency | 141 | |
6651 | leency | 142 | id = select_list.cur_y; |
6653 | leency | 143 | SelectList_Init( |
7225 | leency | 144 | tabs.x+TAB_PADDING, |
145 | tabs.y+TAB_HEIGHT+TAB_PADDING, |
||
7244 | leency | 146 | 250, |
7225 | leency | 147 | tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, |
6653 | leency | 148 | false |
149 | ); |
||
6651 | leency | 150 | select_list.cur_y = id; |
7244 | leency | 151 | |
152 | skp.set_size( |
||
153 | select_list.x + select_list.w + TAB_PADDING + scroll1.size_x, |
||
154 | select_list.y, |
||
155 | 250, |
||
156 | 250 |
||
157 | ); |
||
158 | |||
6653 | leency | 159 | SelectList_Draw(); |
6662 | leency | 160 | SelectList_DrawBorder(); |
7244 | leency | 161 | |
162 | if (tabs.active_tab == SKINS) |
||
163 | { |
||
164 | DrawBar(skp.x, skp.y, skp.w, skp.h, system.color.work); |
||
165 | DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview "); |
||
166 | WriteText(skp.x+20, skp.y+30, 0x90, system.color.work_text, "Lorem ipsum"); |
||
167 | checkbox1.draw(skp.x+20, skp.y+70); |
||
168 | DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Apply"); |
||
169 | DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Close"); |
||
170 | } |
||
6212 | leency | 171 | } |
172 | |||
4410 | leency | 173 | |
6212 | leency | 174 | |
175 | void Open_Dir() |
||
4078 | leency | 176 | { |
6212 | leency | 177 | int j; |
6651 | leency | 178 | select_list.count = 0; |
6212 | leency | 179 | if(io.dir.buffer)free(io.dir.buffer); |
180 | io.dir.load(#folder_path,DIR_ONLYREAL); |
||
181 | for (j=0; j |
||
4410 | leency | 182 | { |
6212 | leency | 183 | strcpy(#temp_filename, io.dir.position(j)); |
184 | strlwr(#temp_filename); |
||
6264 | leency | 185 | if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue; |
186 | if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue; |
||
6651 | leency | 187 | cur = select_list.count; |
6212 | leency | 188 | files_mas[cur]=j; |
6651 | leency | 189 | if (!strcmpi("default.skn",#temp_filename)) files_mas[0]> |
190 | select_list.count++; |
||
4410 | leency | 191 | } |
6212 | leency | 192 | } |
193 | |||
6653 | leency | 194 | void SelectList_DrawLine(dword i) |
6212 | leency | 195 | { |
6651 | leency | 196 | int yyy, list_last; |
6212 | leency | 197 | |
6651 | leency | 198 | cur = select_list.first + i; |
199 | strcpy(#temp_filename, io.dir.position(files_mas[cur])); |
||
200 | temp_filename[strlen(#temp_filename)-4] = 0; |
||
201 | yyy = i*select_list.item_h+select_list.y; |
||
202 | |||
203 | if (select_list.cur_y-select_list.first==i) |
||
4410 | leency | 204 | { |
6651 | leency | 205 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button); |
206 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename); |
||
4410 | leency | 207 | } |
6651 | leency | 208 | else |
209 | { |
||
210 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
||
211 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename); |
||
212 | } |
||
4078 | leency | 213 | } |
214 | |||
6653 | leency | 215 | void SelectList_LineChanged() |
216 | { |
||
217 | EventApply(); |
||
218 | } |
||
219 | |||
6212 | leency | 220 | //===================================================// |
221 | // // |
||
222 | // EVENTS // |
||
223 | // // |
||
224 | //===================================================// |
||
4078 | leency | 225 | |
6212 | leency | 226 | void EventTabClick(int N) |
4085 | leency | 227 | { |
6264 | leency | 228 | tabs.click(N); |
229 | if (tabs.active_tab == SKINS) |
||
6212 | leency | 230 | { |
6651 | leency | 231 | active_wallpaper = select_list.cur_y; |
6212 | leency | 232 | strcpy(#folder_path, SKINS_STANDART_PATH); |
6651 | leency | 233 | select_list.ClearList(); |
6212 | leency | 234 | Open_Dir(); |
6651 | leency | 235 | if (!select_list.count) notify("'No skins were found' -E"); |
236 | select_list.cur_y = active_skin; |
||
6212 | leency | 237 | } |
6264 | leency | 238 | if (tabs.active_tab == WALLPAPERS) |
6212 | leency | 239 | { |
6651 | leency | 240 | active_skin = select_list.cur_y; |
6212 | leency | 241 | strcpy(#folder_path, WALP_STANDART_PATH); |
6651 | leency | 242 | select_list.ClearList(); |
6212 | leency | 243 | Open_Dir(); |
6651 | leency | 244 | if (!select_list.count) notify("'No wallpapers were found' -E"); |
245 | select_list.cur_y = active_wallpaper; |
||
6212 | leency | 246 | } |
6651 | leency | 247 | if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); |
248 | if (select_list.w) DrawWindowContent(); |
||
6212 | leency | 249 | } |
4078 | leency | 250 | |
6212 | leency | 251 | void EventDeleteFile() |
252 | { |
||
253 | io.del(#cur_file_path); |
||
254 | Open_Dir(); |
||
255 | EventApply(); |
||
256 | } |
||
4078 | leency | 257 | |
6212 | leency | 258 | void EventApply() |
259 | { |
||
6264 | leency | 260 | if (tabs.active_tab==SKINS) |
6212 | leency | 261 | { |
6651 | leency | 262 | cur = select_list.cur_y; |
6212 | leency | 263 | sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
264 | SetSystemSkin(#cur_file_path); |
||
265 | } |
||
6264 | leency | 266 | if (tabs.active_tab==WALLPAPERS) |
6212 | leency | 267 | { |
6651 | leency | 268 | cur = select_list.cur_y; |
6212 | leency | 269 | sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
270 | RunProgram("/sys/media/kiv", #cur_file_path); |
||
6653 | leency | 271 | SelectList_Draw(); |
6212 | leency | 272 | } |
273 | } |
||
4085 | leency | 274 | |
6212 | leency | 275 | void EventOpenFile() |
276 | { |
||
6264 | leency | 277 | if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); |
278 | if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); |
||
4085 | leency | 279 | } |
280 | |||
4078 | leency | 281 | stop: |