Subversion Repositories Kolibri OS

Rev

Rev 6746 | Rev 6805 | 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
 
3
#include "../lib/font.h"
5776 leency 4
#include "../lib/gui.h"
5730 pavelyakov 5
 
5784 leency 6
#define PANELH 30
6264 leency 7
proc_info Form;
5784 leency 8
 
6264 leency 9
enum {
6803 leency 10
	STRONG_BTN=10, SMOOTH_BTN,
6264 leency 11
	PHRASE_TAB=20, CHARS_TAB
12
};
13
 
14
 
5730 pavelyakov 15
void main()
16
{
6264 leency 17
	int btn;
18
	char title[4196];
5981 leency 19
	if (!param) strcpy(#param, DEFAULT_FONT);
5987 leency 20
	label.init(#param);
6264 leency 21
	tabs.active_tab=PHRASE_TAB;
5885 pavelyakov 22
	strcpy(#title, "Font preview: ");
5776 leency 23
	strcat(#title, #param);
6264 leency 24
	loop() switch(WaitEvent())
5776 leency 25
	{
26
		case evButton:
27
			btn = GetButtonID();
28
			if (btn==1) ExitProcess();
6264 leency 29
			if (btn==STRONG_BTN) label.bold ^=1;
30
			if (btn==SMOOTH_BTN) label.smooth ^=1;
31
			if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn);
5784 leency 32
			goto _DRAW_WINDOW_CONTENT;
5776 leency 33
		case evReDraw:
6197 leency 34
			system.color.get();
6746 leency 35
			DefineAndDrawWindow(215,100,500,320+skin_height,0x74,0xFFFFFF,#title,0);
5784 leency 36
			GetProcessInfo(#Form, SelfInfo);
5987 leency 37
			if (Form.status_window>2) break;
5784 leency 38
			_DRAW_WINDOW_CONTENT:
6264 leency 39
			DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work);
40
			CheckBox(10, 8, STRONG_BTN, "Bold",  label.bold);
6803 leency 41
			CheckBox(83,8, SMOOTH_BTN, "Smooth",  label.smooth);
6264 leency 42
			tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase");
43
			tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars");
44
			DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph);
5987 leency 45
			if (!label.font)
5776 leency 46
			{
5981 leency 47
				DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
48
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
6264 leency 49
				break;
5784 leency 50
			}
6264 leency 51
			if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase();
52
			if (tabs.active_tab==CHARS_TAB) DrawPreviewChars();
5776 leency 53
	}
54
}
6264 leency 55
 
56
void DrawPreviewPhrase()
57
{
58
	dword i, y;
59
	char line[256];
60
	label.raw_size = free(label.raw);
61
	for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length
62
	{
63
		sprintf(#line,"Размер шрифта/size font %d пикселей.",i);
6803 leency 64
		label.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
6264 leency 65
	}
6803 leency 66
	if (label.smooth) label.ApplySmooth();
6264 leency 67
	label.show_buf(0, PANELH);
68
}
69
 
70
void DrawPreviewChars()
71
{
72
	dword i, x=20, y=0;
73
	char line[2];
74
	line[1]=NULL;
75
	label.raw_size = free(label.raw);
76
	for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
77
	{
78
		line[0]=i;
6803 leency 79
		label.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
6264 leency 80
		x+= label.height+2;
81
		if (x>=Form.cwidth-30) {
82
			x=20;
83
			y+=label.height+2;
84
		}
85
	}
6803 leency 86
	if (label.smooth) label.ApplySmooth();
6264 leency 87
	label.show_buf(0, PANELH);
88
}