Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5784 leency 1
#define MEMSIZE 0x2EE80
5730 pavelyakov 2
 
6805 leency 3
#include "../lib/kfont.h"
5776 leency 4
#include "../lib/gui.h"
5730 pavelyakov 5
 
7226 leency 6
#define PANELH 28
7
#define WIN_W 490
8
#define WIN_H 315
7909 leency 9
#define BASE_TAB_BUTTON_ID 97
6264 leency 10
proc_info Form;
5784 leency 11
 
7909 leency 12
_tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
6264 leency 13
 
7227 leency 14
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
7244 leency 15
checkbox bold = { "Bold", false };
16
checkbox smooth = { "Smooth", true };
7647 leency 17
checkbox colored = { "Colored", true };
7226 leency 18
 
5730 pavelyakov 19
void main()
20
{
6264 leency 21
	int btn;
22
	char title[4196];
5981 leency 23
	if (!param) strcpy(#param, DEFAULT_FONT);
6806 leency 24
	kfont.init(#param);
5885 pavelyakov 25
	strcpy(#title, "Font preview: ");
5776 leency 26
	strcat(#title, #param);
7909 leency 27
 
28
	tabs.add("Phrase", #DrawPreviewPhrase);
29
	tabs.add("Chars", #DrawPreviewChars);
30
 
6264 leency 31
	loop() switch(WaitEvent())
5776 leency 32
	{
33
		case evButton:
34
			btn = GetButtonID();
35
			if (btn==1) ExitProcess();
7647 leency 36
			bold.click(btn);
37
			smooth.click(btn);
38
			colored.click(btn);
7909 leency 39
			tabs.click(btn);
5784 leency 40
			goto _DRAW_WINDOW_CONTENT;
5776 leency 41
		case evReDraw:
7806 leency 42
			sc.get();
7226 leency 43
			DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
5784 leency 44
			GetProcessInfo(#Form, SelfInfo);
5987 leency 45
			if (Form.status_window>2) break;
5784 leency 46
			_DRAW_WINDOW_CONTENT:
7226 leency 47
 
7647 leency 48
			kfont.bold = bold.checked;
49
			kfont.smooth = smooth.checked;
50
 
7806 leency 51
			DrawBar(0, 0, Form.cwidth, PANELH-1, sc.work);
52
			DrawBar(0, PANELH-1,Form.cwidth,1,sc.work_graph);
7244 leency 53
			bold.draw(10, 8);
54
			smooth.draw(83,8);
7647 leency 55
			colored.draw(170,8);
7226 leency 56
 
7909 leency 57
			tabs.draw();
58
			tabs.draw_active_tab();
7226 leency 59
 
6806 leency 60
			if (!kfont.font)
5776 leency 61
			{
7226 leency 62
				DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
5981 leency 63
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
6264 leency 64
				break;
5784 leency 65
			}
5776 leency 66
	}
67
}
6264 leency 68
 
7647 leency 69
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266,
70
	0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA,
71
	0,0,0,0,0 };
72
 
6264 leency 73
void DrawPreviewPhrase()
74
{
75
	dword i, y;
7647 leency 76
	dword c;
6264 leency 77
	char line[256];
6806 leency 78
	kfont.raw_size = free(kfont.raw);
7647 leency 79
	for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
6264 leency 80
	{
7647 leency 81
		if (colored.checked) c = pal[i-10]; else c=0;
7768 leency 82
		strcpy(#line, "Размер шрифта/forn size is ");
83
		strcat(#line, itoa(i));
84
		strcat(#line, " пикселей/px.");
7647 leency 85
		kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line);
6264 leency 86
	}
6806 leency 87
	if (kfont.smooth) kfont.ApplySmooth();
7226 leency 88
	kfont.ShowBuffer(preview.x, preview.y);
6264 leency 89
}
90
 
91
void DrawPreviewChars()
92
{
93
	dword i, x=20, y=0;
94
	char line[2];
95
	line[1]=NULL;
6806 leency 96
	kfont.raw_size = free(kfont.raw);
6264 leency 97
	for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
98
	{
99
		line[0]=i;
6806 leency 100
		kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
101
		x+= kfont.height+2;
7226 leency 102
		if (x>=preview.w-30) {
6264 leency 103
			x=20;
6806 leency 104
			y+=kfont.height+2;
6264 leency 105
		}
106
	}
6806 leency 107
	if (kfont.smooth) kfont.ApplySmooth();
7226 leency 108
	kfont.ShowBuffer(preview.x, preview.y);
6264 leency 109
}