Subversion Repositories Kolibri OS

Rev

Rev 8492 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7771 leency 1
 
2
//                                                   //
3
//                      MODULE                       //
4
//                                                   //
5
//===================================================//
6
7
 
8
9
 
8490 leency 10
_history tabstory[TABS_MAX+1]=0;
7972 leency 11
7771 leency 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
7791 leency 38
		tabdata[i] = tabdata[i+1];
8490 leency 39
		tabstory[i] = tabstory[i+1];
7771 leency 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
	tabdata[active] = WB1;
8490 leency 51
}
7771 leency 52
53
 
54
{
55
	tab.active = _id;
56
	WB1 = tabdata[_id];
8490 leency 57
	history = tabstory[_id];
7771 leency 58
}
59
60
 
61
//                                                   //
62
//                 WebView Actions                   //
63
//                                                   //
64
//===================================================//
65
66
 
67
int tab_w = DEFAULT_TABW;
68
69
 
70
{
71
	if (tab.count == TABS_MAX) return Form.cwidth / tab.count;
7775 theonlymir 72
	if (tab.count * DEFAULT_TABW + TAB_H < Form.cwidth) return DEFAULT_TABW; else
7771 leency 73
	return Form.cwidth - TAB_H - 2 / tab.count;
74
}
75
76
 
77
{
78
	#define CLOSE_S 13
79
	dword bgcol, border_bottom_color;
80
	char header_no_version[sizeof(TWebBrowser.header)];
81
	char name[DEFAULT_TABW/6];
82
	int xxx = _id * tab_w;
83
84
 
85
		tab.save_state();
86
		bgcol = sc.work_light;
7806 leency 87
		border_bottom_color = sc.work_light;
88
	} else {
7771 leency 89
		bgcol=sc.work;
7806 leency 90
		border_bottom_color = sc.work_graph;
91
	}
7771 leency 92
	if (tabdata[_id].header) {
8490 leency 93
		strncpy(#header_no_version, #tabdata[_id].header, strlen(#tabdata[_id].header)-sizeof(version)-2);
94
		strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2);
7771 leency 95
	}
96
	DrawBar(xxx, TOOLBAR_H, 1, TAB_H, sc.work_dark);
7806 leency 97
	DrawBar(xxx+1, TOOLBAR_H, tab_w-1, TAB_H-1, bgcol);
7771 leency 98
	DrawBar(xxx+1, TOOLBAR_H+TAB_H-1, tab_w-1, 1, border_bottom_color);
99
	DefineHiddenButton(xxx, TOOLBAR_H-1, tab_w, TAB_H, TAB_ID+_id);
100
	WriteTextCenter(xxx, TOOLBAR_H+6, tab_w-CLOSE_S, sc.work_text, #name);
7806 leency 101
7771 leency 102
 
103
	DrawBar(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S, CLOSE_S, sc.work_dark);
7806 leency 104
	WriteText(xxx+tab_w-CLOSE_S+1, TOOLBAR_H+5, 0x80, sc.work_light, "x");
105
}
7771 leency 106
107
 
108
{
109
	if (tab_w == GetTabWidth())	DrawTab(tab.active);
110
	else DrawTabsBar();
111
}
112
113
 
7778 leency 114
{
7771 leency 115
	dword btn_light = MixColors(sc.button, 0xFFFfff, 220);
7806 leency 116
	dword btn_dark = MixColors(sc.button, 0, 180);
117
	int xxx = tab.count * tab_w;
7771 leency 118
7775 theonlymir 119
 
120
		DrawBar(xxx, TOOLBAR_H, 1, TAB_H, sc.work_graph);
7806 leency 121
		DrawBar(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, sc.button);
122
		DrawRectangle3D(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, btn_light, btn_dark);
7775 theonlymir 123
		PutPixel(xxx+1+TAB_H, TOOLBAR_H, btn_dark);
124
		DefineHiddenButton(xxx+1, TOOLBAR_H, TAB_H-1, TAB_H-1, NEW_TAB);
125
		WriteText(xxx+7, TOOLBAR_H+2, 0x90, sc.button_text, "+");
7806 leency 126
		return xxx + TAB_H + 2;
7778 leency 127
	} else {
128
		return xxx;
129
	}
7775 theonlymir 130
}
7771 leency 131
132
 
133
{
134
	dword i;
135
	tab_w = GetTabWidth();
136
	for (i=0; i
7799 leency 137
	i = DrawNewTabButton();
7778 leency 138
	DrawBar(i, TOOLBAR_H, Form.cwidth-i, TAB_H-1, MixColors(sc.work_dark, sc.work, 128));
7806 leency 139
	DrawBar(i, TOOLBAR_H+TAB_H-1, Form.cwidth-i, 1, sc.work_graph);
140
}
7771 leency 141
142
 
143
{
144
	DeleteButton(TAB_ID + tab.count-1);
7799 leency 145
	if (_id == tab.active) {
7771 leency 146
		tab.close(_id);
147
		tab.restore(tab.active);
148
		SetElementSizes();
8457 leency 149
		WB1.Reparse();
8500 leency 150
		WB1.DrawPage();
7771 leency 151
		SetOmniboxText(history.current());
152
	} else {
153
		tab.close(_id);
154
	}
155
	DrawTabsBar();
156
	DrawStatusBar(NULL);
8492 leency 157
}
7771 leency 158
159
 
160
{
161
	EventTabClose(tab.active);
162
}
163
164
 
165
{
166
	if (_id>=tab.count) _id = 0;
167
	if (_id==-1) _id = tab.count-1;
168
	tab.save_state();
169
	tab.restore(_id);
170
	DrawTabsBar();
8457 leency 171
	SetElementSizes();
172
	WB1.Reparse();
8500 leency 173
	WB1.DrawPage();
8457 leency 174
	SetOmniboxText(history.current());
7771 leency 175
	DrawStatusBar(NULL);
8492 leency 176
}
7771 leency 177
178
 
179
{
180
	tab.add();
181
	OpenPage(_url);
182
	DrawTabsBar();
183
}
184
185
 
186
{
187
	EventTabClick(tab.active+1);
188
}
189
190
 
191
{
192
	EventTabClick(tab.active-1);
193
}
194