kolibrios-gitea/programs/cmm/kf_font_viewer/font_viewer.c
Kirill Lipatov (Leency) dcbcccc75e cmm gui: simplier api, text shadow for capt button
git-svn-id: svn://kolibrios.org@6176 a494cfbc-eb01-0410-851d-a64ba20cac60
2016-02-09 01:43:58 +00:00

53 lines
1.5 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);
CheckBox(10, 8, 2, "Bold", label.bold);
CheckBox(70, 8, 3, "Italic", label.italic);
CheckBox(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);
}
}
}