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