kolibrios-fun/programs/cmm/kolibri font viewer/kolibri font viewer.c
Kirill Lipatov (Leency) 377ac5168b font.h: global refactoring, simplify API
git-svn-id: svn://kolibrios.org@5987 a494cfbc-eb01-0410-851d-a64ba20cac60
2015-12-18 21:10:45 +00:00

56 lines
1.6 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#define MEMSIZE 0x2EE80
#include "../lib/font.h"
#include "../lib/gui.h"
#define PANELH 30
void main()
{
proc_info Form;
int i, y, btn;
char line[256], title[4196];
if (!param) strcpy(#param, DEFAULT_FONT);
label.init(#param);
strcpy(#title, "Font preview: ");
strcat(#title, #param);
loop()
{
switch(WaitEvent())
{
case evButton:
btn = GetButtonID();
if (btn==1) ExitProcess();
if (btn==2) label.bold ^=1;
if (btn==3) label.italic ^=1;
if (btn==4) label.smooth ^=1;
goto _DRAW_WINDOW_CONTENT;
case evReDraw:
DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break;
_DRAW_WINDOW_CONTENT:
DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
CheckBox2(10, 8, 2, "Bold", label.bold);
CheckBox2(70, 8, 3, "Italic", label.italic);
CheckBox2(140, 8, 4, "Smooth", label.smooth);
label.raw_size = free(label.raw);
if (!label.font)
{
DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
}
else for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length
{
sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
}
if (label.smooth) label.apply_smooth();
label.show_buf(0, PANELH);
}
}
}
void CheckBox2(dword x, y, id, text, byte value) {
CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
}