Subversion Repositories Kolibri OS

Rev

Rev 9489 | Rev 9524 | 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!
9516 leency 2
//TODO: select current value at startap
4078 leency 3
 
9465 leency 4
#define MEMSIZE 1024*70
7909 leency 5
#include "../lib/mem.h"
6
#include "../lib/strings.h"
7
#include "../lib/io.h"
8
#include "../lib/list_box.h"
9
#include "../lib/gui.h"
7353 leency 10
 
7909 leency 11
#include "../lib/obj/box_lib.h"
12
#include "../lib/obj/proc_lib.h"
13
#include "../lib/obj/libini.h"
7353 leency 14
 
7909 leency 15
#include "../lib/patterns/select_list.h"
16
#include "../lib/patterns/simple_open_dialog.h"
9453 leency 17
#include "../lib/patterns/restart_process.h"
4078 leency 18
 
7614 leency 19
#include "ui_elements_preview.h"
9455 leency 20
#include "const.h"
7614 leency 21
 
6212 leency 22
//===================================================//
23
//                                                   //
24
//                       DATA                        //
25
//                                                   //
26
//===================================================//
27
 
9469 leency 28
int active_skin, active_wallpaper, active_screensaver;
29
 
7612 leency 30
checkbox update_docky = { T_UPDATE_DOCK, false };
7244 leency 31
 
9465 leency 32
checkbox optionbox_stretch = { T_CHECKBOX_STRETCH, false };
7611 leency 33
checkbox optionbox_tiled = { T_CHECKBOX_TILED, false };
9465 leency 34
checkbox optionbox_auto = { T_CHECKBOX_AUTO, true };
7611 leency 35
 
9516 leency 36
char ss_available[200];
37
 
9465 leency 38
collection list;
9461 leency 39
 
6212 leency 40
//===================================================//
41
//                                                   //
42
//                       CODE                        //
43
//                                                   //
44
//===================================================//
5548 leency 45
 
4078 leency 46
void main()
47
{
9461 leency 48
	int id, i;
5626 leency 49
	load_dll(boxlib, #box_lib_init,0);
7533 leency 50
	load_dll(libini, #lib_init,1);
7353 leency 51
	load_dll(Proc_lib, #OpenDialog_init,0);
52
	OpenDialog_init stdcall (#o_dialog);
53
 
9469 leency 54
	GetIniSettings();
55
 
9453 leency 56
	tabs.add(#t_skins, #EventTabSkinsClick);
57
	tabs.add(#t_wallpapers, #EventTabWallpappersClick);
58
	tabs.add(#t_screensaver, #EventTabScreensaverClick);
7909 leency 59
	tabs.draw_active_tab();
7353 leency 60
 
7551 leency 61
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
6096 leency 62
	loop() switch(WaitEvent())
4078 leency 63
	{
64
	  	case evMouse:
6653 leency 65
			SelectList_ProcessMouse();
9516 leency 66
			if (tabs.active_tab == TAB_SCREENSAVERS) {
67
				scrollbar_h_mouse stdcall (#ss_timeout);
68
				if (ss_timeout.redraw) {
69
					draw_timeout();
70
					ss_timeout.redraw = false; //reset flag
71
				}
72
			}
4078 leency 73
	  		break;
74
 
75
		case evButton:
76
			id=GetButtonID();
7551 leency 77
			if (id==1) EventExit();
7909 leency 78
			tabs.click(id);
9465 leency 79
			if (tabs.active_tab == TAB_SKINS) {
80
				checkbox1.click(id);
81
				spinbox1.click(id);
82
				if (update_docky.click(id)) EventUpdateDocky();
83
			}
84
			if (tabs.active_tab == TAB_WALLPAPERS) {
85
				if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
86
				if (optionbox_stretch.click(id)) EventSetWallpMode(1,0,0);
87
				if (optionbox_tiled.click(id)) EventSetWallpMode(0,1,0);
88
				if (optionbox_auto.click(id)) EventSetWallpMode(0,0,1);
89
			}
90
			if (tabs.active_tab == TAB_SCREENSAVERS) {
91
				if (id==BTN_TEST_SCREENSAVER) EventOpenFile();
9489 leency 92
				if (id==BTN_SET_SCREENSAVER) EventSetSs();
9465 leency 93
			}
4078 leency 94
			break;
95
 
96
		case evKey:
5706 leency 97
			GetKeys();
9516 leency 98
			if (select_list.ProcessKey(key_scancode)) { EventApply(); break; }
99
			if (key_scancode==SCAN_CODE_ENTER) { EventOpenFile(); break; }
100
			if (key_scancode==SCAN_CODE_DEL) { EventDeleteFile(); break; }
9453 leency 101
			if (key_scancode==SCAN_CODE_TAB) {
102
				id = tabs.active_tab+1;
103
				if(id==3)id=0;
104
				tabs.click(id + tabs.base_id);
105
				break;
106
			}
9461 leency 107
			for (i=select_list.cur_y+1; i
4078 leency 108
			{
9481 leency 109
				id = list.get(i) + strrchr(list.get(i), '/');
110
				if (ESBYTE[id]==key_ascii) || (ESBYTE[id]==key_ascii-32)
6212 leency 111
				{
9461 leency 112
					select_list.cur_y = i - 1;
6651 leency 113
					select_list.KeyDown();
6212 leency 114
					EventApply();
115
					break;
116
				}
4078 leency 117
			}
118
			break;
119
 
7353 leency 120
		 case evReDraw:
121
			draw_window();
4078 leency 122
   }
123
}
124
 
7353 leency 125
void draw_window()
126
{
7909 leency 127
	sc.get();
9461 leency 128
	DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x34,sc.work,WINDOW_HEADER,0);
7244 leency 129
 
7909 leency 130
	tabs.draw();
9516 leency 131
	draw_icon_16w(tabs.x + TAB_P, LP+5, 17);
132
	draw_icon_16w(sizeof(t_skins)-1*8 + TAB_P + TAB_P + tabs.x, LP+5, 6);
133
	draw_icon_16w(sizeof(t_wallpapers)+sizeof(t_skins)-2*8 + TAB_P + TAB_P + TAB_P + tabs.x, LP+5, 61);
7225 leency 134
 
9461 leency 135
	$push select_list.cur_y
6653 leency 136
	SelectList_Init(
9516 leency 137
		LP,
9453 leency 138
		PANEL_H,
139
		LIST_W,
9516 leency 140
		WIN_H - LP - PANEL_H
6653 leency 141
		);
9461 leency 142
	$pop select_list.cur_y
7244 leency 143
 
9461 leency 144
	DrawBar(RIGHTx, PANEL_H, RIGHTw, WIN_H-PANEL_H-LP, sc.work);
7244 leency 145
 
6653 leency 146
	SelectList_Draw();
6662 leency 147
	SelectList_DrawBorder();
7244 leency 148
 
9461 leency 149
	if (tabs.active_tab == TAB_SKINS)
7244 leency 150
	{
9461 leency 151
		DrawFrame(RIGHTx, PANEL_H+5, RIGHTw, RIGHTh, T_UI_PREVIEW);
152
		DrawUiElementsPreview(RIGHTx+20, PANEL_H+5, RIGHTh);
153
		if (CheckProcessExists("@DOCKY")) update_docky.draw(RIGHTx, PANEL_H+250);
7244 leency 154
	}
9461 leency 155
	if (tabs.active_tab == TAB_WALLPAPERS)
7353 leency 156
	{
9465 leency 157
		DrawFrame(RIGHTx, PANEL_H+5, 180, 105, T_PICTURE_MODE);
9461 leency 158
		optionbox_stretch.draw(RIGHTx+14, PANEL_H+25);
159
		optionbox_tiled.draw(RIGHTx+14, PANEL_H+52);
9465 leency 160
		optionbox_auto.draw(RIGHTx+14, PANEL_H+79);
161
		DrawStandartCaptButton(RIGHTx, PANEL_H+130, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
7353 leency 162
	}
9461 leency 163
	if (tabs.active_tab == TAB_SCREENSAVERS)
9453 leency 164
	{
9516 leency 165
		draw_timeout();
166
		ss_timeout.line_col = sc.work_graph;
167
		ss_timeout.frnt_col = sc.work;
168
		scrollbar_h_draw stdcall (#ss_timeout);
169
		DrawRectangle(RIGHTx, RIGHTy+25, RIGHTw-20, 15, sc.work_graph);
170
		ESI = DrawStandartCaptButton(RIGHTx, PANEL_H + 65, BTN_TEST_SCREENSAVER, T_SS_PREVIEW);
171
		DrawStandartCaptButton(RIGHTx+ESI, PANEL_H + 65, BTN_SET_SCREENSAVER, T_SS_SET);
9453 leency 172
	}
6212 leency 173
}
174
 
9516 leency 175
void draw_timeout()
176
{
177
	miniprintf(#param, T_SS_TIMEOUT, ss_timeout.position+1);
178
	WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);
179
}
180
 
9455 leency 181
bool strreqi(dword _left, _right)
182
{
9461 leency 183
	return strcmp(_left+strrchr(_left,'.'), _right);
9455 leency 184
}
4410 leency 185