Rev 6662 | Rev 7225 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6662 | Rev 6782 | ||
---|---|---|---|
1 | //11.03.12 - start! |
1 | //11.03.12 - start! |
2 | //ver 2.0 |
2 | //ver 2.0 |
3 | 3 | ||
4 | #ifndef AUTOBUILD |
4 | #ifndef AUTOBUILD |
5 | ?include "lang.h--" |
5 | ?include "lang.h--" |
6 | #endif |
6 | #endif |
7 | 7 | ||
8 | #define MEMSIZE 0xFE800 |
8 | #define MEMSIZE 0xFE800 |
9 | #include "..\lib\mem.h" |
9 | #include "..\lib\mem.h" |
10 | #include "..\lib\strings.h" |
10 | #include "..\lib\strings.h" |
11 | #include "..\lib\io.h" |
11 | #include "..\lib\io.h" |
12 | #include "..\lib\list_box.h" |
12 | #include "..\lib\list_box.h" |
13 | #include "..\lib\menu.h" |
13 | #include "..\lib\menu.h" |
14 | #include "..\lib\gui.h" |
14 | #include "..\lib\gui.h" |
15 | #include "..\lib\obj\box_lib.h" |
15 | #include "..\lib\obj\box_lib.h" |
16 | #include "..\lib\patterns\select_list.h" |
16 | #include "..\lib\patterns\select_list.h" |
17 | 17 | ||
18 | 18 | ||
19 | //===================================================// |
19 | //===================================================// |
20 | // // |
20 | // // |
21 | // DATA // |
21 | // DATA // |
22 | // // |
22 | // // |
23 | //===================================================// |
23 | //===================================================// |
24 | 24 | ||
25 | #ifdef LANG_RUS |
25 | #ifdef LANG_RUS |
26 | ?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥¨ï" |
26 | ?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥¨ï" |
27 | ?define T_SKINS "â¨«ì ®ª®" |
27 | ?define T_SKINS "â¨«ì ®ª®" |
28 | ?define T_WALLPAPERS "¡®¨" |
28 | ?define T_WALLPAPERS "¡®¨" |
29 | #else |
29 | #else |
30 | ?define WINDOW_HEADER "Appearance" |
30 | ?define WINDOW_HEADER "Appearance" |
31 | ?define T_SKINS "Skins" |
31 | ?define T_SKINS "Skins" |
32 | ?define T_WALLPAPERS "Wallpappers" |
32 | ?define T_WALLPAPERS "Wallpappers" |
33 | #endif |
33 | #endif |
34 | 34 | ||
35 | #define PANEL_H 40 |
35 | #define PANEL_H 40 |
36 | #define LIST_PADDING 20 |
36 | #define LIST_PADDING 20 |
37 | #define SKINS_STANDART_PATH "/kolibrios/res/skins" |
37 | #define SKINS_STANDART_PATH "/kolibrios/res/skins" |
38 | #define WALP_STANDART_PATH "/kolibrios/res/wallpapers" |
38 | #define WALP_STANDART_PATH "/kolibrios/res/wallpapers" |
39 | 39 | ||
40 | signed int active_skin=-1, active_wallpaper=-1; |
40 | signed int active_skin=-1, active_wallpaper=-1; |
41 | enum { SKINS=2, WALLPAPERS }; |
41 | enum { SKINS=2, WALLPAPERS }; |
42 | 42 | ||
43 | char folder_path[4096]; |
43 | char folder_path[4096]; |
44 | char cur_file_path[4096]; |
44 | char cur_file_path[4096]; |
45 | char temp_filename[4096]; |
45 | char temp_filename[4096]; |
46 | int files_mas[400]; |
46 | int files_mas[400]; |
47 | 47 | ||
48 | int cur; |
48 | int cur; |
49 | 49 | ||
50 | proc_info Form; |
50 | proc_info Form; |
51 | 51 | ||
52 | //===================================================// |
52 | //===================================================// |
53 | // // |
53 | // // |
54 | // CODE // |
54 | // CODE // |
55 | // // |
55 | // // |
56 | //===================================================// |
56 | //===================================================// |
57 | 57 | ||
58 | void main() |
58 | void main() |
59 | { |
59 | { |
60 | int id, mouse_clicked; |
60 | int id, mouse_clicked; |
61 | 61 | ||
62 | SetEventMask(0x27); |
62 | SetEventMask(0x27); |
63 | load_dll(boxlib, #box_lib_init,0); |
63 | load_dll(boxlib, #box_lib_init,0); |
64 | EventTabClick(SKINS); |
64 | EventTabClick(SKINS); |
65 | loop() switch(WaitEvent()) |
65 | loop() switch(WaitEvent()) |
66 | { |
66 | { |
67 | case evMouse: |
67 | case evMouse: |
68 | if (!CheckActiveProcess(Form.ID)) break; |
68 | if (!CheckActiveProcess(Form.ID)) break; |
69 | SelectList_ProcessMouse(); |
69 | SelectList_ProcessMouse(); |
70 | 70 | ||
71 | if (mouse.down)&&(mouse.pkm) { |
71 | if (mouse.down)&&(mouse.pkm) { |
72 | select_list.ProcessMouse(mouse.x, mouse.y); |
72 | select_list.ProcessMouse(mouse.x, mouse.y); |
73 | SelectList_Draw(); |
73 | SelectList_Draw(); |
74 | menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 136, "Open file Enter\nDelete Del", 10); |
74 | menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, "Open file Enter\nDelete Del", 10); |
75 | } |
75 | } |
76 | break; |
76 | break; |
77 | 77 | ||
78 | case evButton: |
78 | case evButton: |
79 | id=GetButtonID(); |
79 | id=GetButtonID(); |
80 | if (id==1) ExitProcess(); |
80 | if (id==1) ExitProcess(); |
81 | if (id==SKINS) EventTabClick(SKINS); |
81 | if (id==SKINS) EventTabClick(SKINS); |
82 | if (id==WALLPAPERS) EventTabClick(WALLPAPERS); |
82 | if (id==WALLPAPERS) EventTabClick(WALLPAPERS); |
83 | break; |
83 | break; |
84 | 84 | ||
85 | case evKey: |
85 | case evKey: |
86 | GetKeys(); |
86 | GetKeys(); |
87 | if (select_list.ProcessKey(key_scancode)) EventApply(); |
87 | if (select_list.ProcessKey(key_scancode)) EventApply(); |
88 | if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); |
88 | if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); |
89 | if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS); |
89 | if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS); |
90 | if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); |
90 | if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); |
91 | for (id=select_list.cur_y+1; id |
91 | for (id=select_list.cur_y+1; id |
92 | { |
92 | { |
93 | strcpy(#temp_filename, io.dir.position(files_mas[id])); |
93 | strcpy(#temp_filename, io.dir.position(files_mas[id])); |
94 | if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32) |
94 | if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32) |
95 | { |
95 | { |
96 | select_list.cur_y = id - 1; |
96 | select_list.cur_y = id - 1; |
97 | select_list.KeyDown(); |
97 | select_list.KeyDown(); |
98 | EventApply(); |
98 | EventApply(); |
99 | break; |
99 | break; |
100 | } |
100 | } |
101 | } |
101 | } |
102 | break; |
102 | break; |
103 | 103 | ||
104 | case evReDraw: |
104 | case evReDraw: |
105 | system.color.get(); |
105 | system.color.get(); |
106 | DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
106 | DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
107 | GetProcessInfo(#Form, SelfInfo); |
107 | GetProcessInfo(#Form, SelfInfo); |
108 | IF (Form.status_window>=2) break; |
108 | IF (Form.status_window>=2) break; |
109 | DrawWindowContent(); |
109 | DrawWindowContent(); |
110 | if (menu.list.cur_y) { |
110 | if (menu.list.cur_y) { |
111 | if (menu.list.cur_y == 10) EventOpenFile(); |
111 | if (menu.list.cur_y == 10) EventOpenFile(); |
112 | if (menu.list.cur_y == 11) EventDeleteFile(); |
112 | if (menu.list.cur_y == 11) EventDeleteFile(); |
113 | menu.list.cur_y = 0; |
113 | menu.list.cur_y = 0; |
114 | }; |
114 | }; |
115 | } |
115 | } |
116 | } |
116 | } |
117 | 117 | ||
118 | void DrawWindowContent() |
118 | void DrawWindowContent() |
119 | { |
119 | { |
120 | int id; |
120 | int id; |
121 | id = select_list.cur_y; |
121 | id = select_list.cur_y; |
122 | SelectList_Init( |
122 | SelectList_Init( |
123 | LIST_PADDING, |
123 | LIST_PADDING, |
124 | PANEL_H, |
124 | PANEL_H, |
125 | Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, |
125 | Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, |
126 | Form.cheight-PANEL_H-LIST_PADDING, |
126 | Form.cheight-PANEL_H-LIST_PADDING, |
127 | false |
127 | false |
128 | ); |
128 | ); |
129 | select_list.cur_y = id; |
129 | select_list.cur_y = id; |
130 | DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work); |
130 | DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work); |
131 | DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, |
131 | DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, |
132 | LIST_PADDING*2+select_list.h, LIST_PADDING-2, system.color.work); |
132 | LIST_PADDING*2+select_list.h, LIST_PADDING-2, system.color.work); |
133 | tabs.draw(select_list.x+10, select_list.y, SKINS, T_SKINS); |
133 | tabs.draw(select_list.x+10, select_list.y, SKINS, T_SKINS); |
134 | if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+select_list.x+21, select_list.y, |
134 | if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+select_list.x+21, select_list.y, |
135 | WALLPAPERS, T_WALLPAPERS); |
135 | WALLPAPERS, T_WALLPAPERS); |
136 | SelectList_Draw(); |
136 | SelectList_Draw(); |
137 | SelectList_DrawBorder(); |
137 | SelectList_DrawBorder(); |
138 | } |
138 | } |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | void Open_Dir() |
142 | void Open_Dir() |
143 | { |
143 | { |
144 | int j; |
144 | int j; |
145 | select_list.count = 0; |
145 | select_list.count = 0; |
146 | if(io.dir.buffer)free(io.dir.buffer); |
146 | if(io.dir.buffer)free(io.dir.buffer); |
147 | io.dir.load(#folder_path,DIR_ONLYREAL); |
147 | io.dir.load(#folder_path,DIR_ONLYREAL); |
148 | for (j=0; j |
148 | for (j=0; j |
149 | { |
149 | { |
150 | strcpy(#temp_filename, io.dir.position(j)); |
150 | strcpy(#temp_filename, io.dir.position(j)); |
151 | strlwr(#temp_filename); |
151 | strlwr(#temp_filename); |
152 | if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue; |
152 | if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue; |
153 | if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue; |
153 | if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue; |
154 | cur = select_list.count; |
154 | cur = select_list.count; |
155 | files_mas[cur]=j; |
155 | files_mas[cur]=j; |
156 | if (!strcmpi("default.skn",#temp_filename)) files_mas[0]> |
156 | if (!strcmpi("default.skn",#temp_filename)) files_mas[0]> |
157 | select_list.count++; |
157 | select_list.count++; |
158 | } |
158 | } |
159 | } |
159 | } |
160 | 160 | ||
161 | void SelectList_DrawLine(dword i) |
161 | void SelectList_DrawLine(dword i) |
162 | { |
162 | { |
163 | int yyy, list_last; |
163 | int yyy, list_last; |
164 | 164 | ||
165 | cur = select_list.first + i; |
165 | cur = select_list.first + i; |
166 | strcpy(#temp_filename, io.dir.position(files_mas[cur])); |
166 | strcpy(#temp_filename, io.dir.position(files_mas[cur])); |
167 | temp_filename[strlen(#temp_filename)-4] = 0; |
167 | temp_filename[strlen(#temp_filename)-4] = 0; |
168 | yyy = i*select_list.item_h+select_list.y; |
168 | yyy = i*select_list.item_h+select_list.y; |
169 | 169 | ||
170 | if (select_list.cur_y-select_list.first==i) |
170 | if (select_list.cur_y-select_list.first==i) |
171 | { |
171 | { |
172 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button); |
172 | DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button); |
173 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename); |
173 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename); |
174 | } |
174 | } |
175 | else |
175 | else |
176 | { |
176 | { |
177 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
177 | DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff); |
178 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename); |
178 | WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename); |
179 | } |
179 | } |
180 | } |
180 | } |
181 | 181 | ||
182 | void SelectList_LineChanged() |
182 | void SelectList_LineChanged() |
183 | { |
183 | { |
184 | EventApply(); |
184 | EventApply(); |
185 | } |
185 | } |
186 | 186 | ||
187 | //===================================================// |
187 | //===================================================// |
188 | // // |
188 | // // |
189 | // EVENTS // |
189 | // EVENTS // |
190 | // // |
190 | // // |
191 | //===================================================// |
191 | //===================================================// |
192 | 192 | ||
193 | void EventTabClick(int N) |
193 | void EventTabClick(int N) |
194 | { |
194 | { |
195 | tabs.click(N); |
195 | tabs.click(N); |
196 | if (tabs.active_tab == SKINS) |
196 | if (tabs.active_tab == SKINS) |
197 | { |
197 | { |
198 | active_wallpaper = select_list.cur_y; |
198 | active_wallpaper = select_list.cur_y; |
199 | strcpy(#folder_path, SKINS_STANDART_PATH); |
199 | strcpy(#folder_path, SKINS_STANDART_PATH); |
200 | select_list.ClearList(); |
200 | select_list.ClearList(); |
201 | Open_Dir(); |
201 | Open_Dir(); |
202 | if (!select_list.count) notify("'No skins were found' -E"); |
202 | if (!select_list.count) notify("'No skins were found' -E"); |
203 | select_list.cur_y = active_skin; |
203 | select_list.cur_y = active_skin; |
204 | } |
204 | } |
205 | if (tabs.active_tab == WALLPAPERS) |
205 | if (tabs.active_tab == WALLPAPERS) |
206 | { |
206 | { |
207 | active_skin = select_list.cur_y; |
207 | active_skin = select_list.cur_y; |
208 | strcpy(#folder_path, WALP_STANDART_PATH); |
208 | strcpy(#folder_path, WALP_STANDART_PATH); |
209 | select_list.ClearList(); |
209 | select_list.ClearList(); |
210 | Open_Dir(); |
210 | Open_Dir(); |
211 | if (!select_list.count) notify("'No wallpapers were found' -E"); |
211 | if (!select_list.count) notify("'No wallpapers were found' -E"); |
212 | select_list.cur_y = active_wallpaper; |
212 | select_list.cur_y = active_wallpaper; |
213 | } |
213 | } |
214 | if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); |
214 | if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); |
215 | if (select_list.w) DrawWindowContent(); |
215 | if (select_list.w) DrawWindowContent(); |
216 | } |
216 | } |
217 | 217 | ||
218 | void EventDeleteFile() |
218 | void EventDeleteFile() |
219 | { |
219 | { |
220 | io.del(#cur_file_path); |
220 | io.del(#cur_file_path); |
221 | Open_Dir(); |
221 | Open_Dir(); |
222 | EventApply(); |
222 | EventApply(); |
223 | } |
223 | } |
224 | 224 | ||
225 | void EventApply() |
225 | void EventApply() |
226 | { |
226 | { |
227 | if (tabs.active_tab==SKINS) |
227 | if (tabs.active_tab==SKINS) |
228 | { |
228 | { |
229 | cur = select_list.cur_y; |
229 | cur = select_list.cur_y; |
230 | sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
230 | sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
231 | SetSystemSkin(#cur_file_path); |
231 | SetSystemSkin(#cur_file_path); |
232 | } |
232 | } |
233 | if (tabs.active_tab==WALLPAPERS) |
233 | if (tabs.active_tab==WALLPAPERS) |
234 | { |
234 | { |
235 | cur = select_list.cur_y; |
235 | cur = select_list.cur_y; |
236 | sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
236 | sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur])); |
237 | RunProgram("/sys/media/kiv", #cur_file_path); |
237 | RunProgram("/sys/media/kiv", #cur_file_path); |
238 | SelectList_Draw(); |
238 | SelectList_Draw(); |
239 | } |
239 | } |
240 | } |
240 | } |
241 | 241 | ||
242 | void EventOpenFile() |
242 | void EventOpenFile() |
243 | { |
243 | { |
244 | if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); |
244 | if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path); |
245 | if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); |
245 | if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); |
246 | } |
246 | } |
247 | 247 | ||
248 | stop: |
248 | stop: |
249 | > |
249 | > |