Subversion Repositories Kolibri OS

Rev

Rev 7775 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7771 leency 1
 
2
//                                                   //
3
//                      MODULE                       //
4
//                                                   //
5
//===================================================//
6
7
 
8
9
 
10
_history tabstory[TABS_MAX+1];
11
12
 
13
{
14
	int count;
15
	signed int active;
16
	bool add();
17
	bool close();
18
	void save_state();
19
	void restore();
20
} tab = {1,0};
21
22
 
23
 
24
{
25
	if (count==TABS_MAX) return false;
26
	save_state();
27
	count++;
28
	active = count-1;
29
	history = tabstory[active];
30
	return true;
31
}
32
33
 
34
{
35
	int i;
36
	if (count==1) return false;
37
	for (i=_tab_number; i<=TABS_MAX; i++) {
38
		data[i] = data[i+1];
39
		tabstory[i] = tabstory[i+1];
40
	}
41
	if (_tab_number0) active--;
42
	if (active==count-1) && (active>0) active--;
43
	count--;
44
	return true;
45
}
46
47
 
48
{
49
	tabstory[active] = history;
50
	data[active] = WB1;
51
}
52
53
 
54
{
55
	tab.active = _id;
56
	WB1 = data[_id];
57
	history = tabstory[_id];
58
}
59
60
 
61
//                                                   //
62
//                 WebView Actions                   //
63
//                                                   //
64
//===================================================//
65
66
 
67
int tab_w = DEFAULT_TABW;
68
69
 
70
{
71
	if (tab.count * DEFAULT_TABW + TAB_H < Form.cwidth) return DEFAULT_TABW; else
72
	return Form.cwidth - TAB_H - 2 / tab.count;
73
}
74
75
 
76
{
77
	#define CLOSE_S 13
78
	dword bgcol, border_bottom_color;
79
	char header_no_version[sizeof(TWebBrowser.header)];
80
	char name[DEFAULT_TABW/6];
81
	int xxx = _id * tab_w;
82
83
 
84
		tab.save_state();
85
		bgcol = system.color.work_light;
86
		border_bottom_color = system.color.work_light;
87
	} else {
88
		bgcol=system.color.work;
89
		border_bottom_color = system.color.work_graph;
90
	}
91
	if (data[_id].header) {
92
		strncpy(#header_no_version, #data[_id].header, strlen(#data[_id].header)-sizeof(version)-2);
93
		strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2);
94
	}
95
	DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_dark);
96
	DrawBar(xxx+1, TOOLBAR_H, tab_w-1, TAB_H-1, bgcol);
97
	DrawBar(xxx+1, TOOLBAR_H+TAB_H-1, tab_w-1, 1, border_bottom_color);
98
	DefineHiddenButton(xxx, TOOLBAR_H-1, tab_w, TAB_H, TAB_ID+_id);
99
	WriteTextCenter(xxx, TOOLBAR_H+6, tab_w-CLOSE_S, system.color.work_text, #name);
100
101
 
102
	DrawBar(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S, CLOSE_S, system.color.work_dark);
103
	WriteText(xxx+tab_w-CLOSE_S+1, TOOLBAR_H+5, 0x80, system.color.work_light, "x");
104
}
105
106
 
107
{
108
	if (tab_w == GetTabWidth())	DrawTab(tab.active);
109
	else DrawTabsBar();
110
}
111
112
 
113
{
114
	dword btn_light = MixColors(system.color.work_button, 0xFFFfff, 220);
115
	dword btn_dark = MixColors(system.color.work_button, 0, 180);
116
	int xxx = tab.count * tab_w;
117
	DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_graph);
118
	DrawBar(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, system.color.work_button);
119
	DrawRectangle3D(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, btn_light, btn_dark);
120
	PutPixel(xxx+1+TAB_H, TOOLBAR_H, btn_dark);
121
	DefineHiddenButton(xxx+1, TOOLBAR_H, TAB_H-1, TAB_H-1, NEW_TAB);
122
	WriteText(xxx+7, TOOLBAR_H+2, 0x90, system.color.work_button_text, "+");
123
}
124
125
 
126
{
127
	dword i;
128
	tab_w = GetTabWidth();
129
	for (i=0; i
130
	DrawNewTabButton();
131
	i = tab_w * i + TAB_H + 2;
132
	DrawBar(i, TOOLBAR_H, Form.cwidth-i, TAB_H-1, MixColors(system.color.work_dark, system.color.work, 128));
133
	DrawBar(i, TOOLBAR_H+TAB_H-1, Form.cwidth-i, 1, system.color.work_graph);
134
}
135
136
 
137
{
138
	DeleteButton(tab.count);
139
	if (_id == tab.active) {
140
		tab.close(_id);
141
		tab.restore(tab.active);
142
		WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
143
		WB1.DrawPage();
144
		SetOmniboxText(history.current());
145
	} else {
146
		tab.close(_id);
147
	}
148
	DrawTabsBar();
149
}
150
151
 
152
{
153
	EventTabClose(tab.active);
154
}
155
156
 
157
{
158
	if (_id>=tab.count) _id = 0;
159
	if (_id==-1) _id = tab.count-1;
160
	tab.save_state();
161
	tab.restore(_id);
162
	SetElementSizes();
163
	if (!BrowserWidthChanged()) {
164
		DrawTabsBar();
165
		WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
166
		WB1.DrawPage();
167
	}
168
	SetOmniboxText(history.current());
169
}
170
171
 
172
{
173
	tab.add();
174
	OpenPage(_url);
175
	DrawTabsBar();
176
}
177
178
 
179
{
180
	EventTabClick(tab.active+1);
181
}
182
183
 
184
{
185
	EventTabClick(tab.active-1);
186
}
187
188
 
189
 
190
{
191
	debugln("\n\n\nHISTORY==========================");
192
	history.add("history");
193
	history.debug();
194
195
 
196
	tabstory[0].add("tabstory0");
197
	tabstory[0].debug();
198
199
 
200
	tabstory[1].add("tabstory1");
201
	tabstory[1].debug();
202
203
 
204
	debugval("history.items.data_start", history.items.data_start);
205
	debugval("tabstory[0].items.data_start", tabstory[0].items.data_start);
206
	debugval("tabstory[1].items.data_start", tabstory[1].items.data_start);
207
	debugln("\n\n\n\n");
208
}
209