2020-05-26 03:17:12 +03:00
|
|
|
|
#define MEMSIZE 1024*30
|
2015-08-27 11:33:51 +03:00
|
|
|
|
|
2016-12-21 18:40:39 +03:00
|
|
|
|
#include "../lib/kfont.h"
|
2015-08-27 11:33:51 +03:00
|
|
|
|
#include "../lib/gui.h"
|
|
|
|
|
|
2018-04-11 21:32:00 +03:00
|
|
|
|
#define PANELH 28
|
2020-05-26 18:07:13 +03:00
|
|
|
|
#define WIN_W 520
|
2018-04-11 21:32:00 +03:00
|
|
|
|
#define WIN_H 315
|
2020-05-10 15:49:02 +03:00
|
|
|
|
#define BASE_TAB_BUTTON_ID 97
|
2016-02-20 16:06:19 +03:00
|
|
|
|
|
2020-05-10 15:49:02 +03:00
|
|
|
|
_tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
|
2018-04-11 21:32:00 +03:00
|
|
|
|
|
2018-04-16 01:44:36 +03:00
|
|
|
|
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
|
2018-04-19 23:12:07 +03:00
|
|
|
|
checkbox bold = { "Bold", false };
|
|
|
|
|
checkbox smooth = { "Smooth", true };
|
2019-05-10 15:51:47 +03:00
|
|
|
|
checkbox colored = { "Colored", true };
|
2015-09-02 16:15:32 +03:00
|
|
|
|
|
2015-08-27 11:33:51 +03:00
|
|
|
|
void main()
|
|
|
|
|
{
|
2020-05-26 03:17:12 +03:00
|
|
|
|
proc_info Form;
|
|
|
|
|
char title[1024];
|
2016-02-20 16:06:19 +03:00
|
|
|
|
int btn;
|
2020-05-26 03:17:12 +03:00
|
|
|
|
|
2015-12-17 22:15:49 +03:00
|
|
|
|
if (!param) strcpy(#param, DEFAULT_FONT);
|
2016-12-21 22:50:13 +03:00
|
|
|
|
kfont.init(#param);
|
2015-11-06 17:49:37 +03:00
|
|
|
|
strcpy(#title, "Font preview: ");
|
2015-08-27 11:33:51 +03:00
|
|
|
|
strcat(#title, #param);
|
2020-05-10 15:49:02 +03:00
|
|
|
|
|
|
|
|
|
tabs.add("Phrase", #DrawPreviewPhrase);
|
|
|
|
|
tabs.add("Chars", #DrawPreviewChars);
|
|
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
|
loop() switch(@WaitEvent())
|
2015-08-27 11:33:51 +03:00
|
|
|
|
{
|
|
|
|
|
case evButton:
|
2020-05-26 03:17:12 +03:00
|
|
|
|
btn = @GetButtonID();
|
|
|
|
|
if (btn==1) @ExitProcess();
|
2019-05-10 15:51:47 +03:00
|
|
|
|
bold.click(btn);
|
|
|
|
|
smooth.click(btn);
|
|
|
|
|
colored.click(btn);
|
2020-05-10 15:49:02 +03:00
|
|
|
|
tabs.click(btn);
|
2020-05-26 03:17:12 +03:00
|
|
|
|
GOTO _DRAW_WINDOW_CONTENT;
|
|
|
|
|
|
2015-08-27 11:33:51 +03:00
|
|
|
|
case evReDraw:
|
2020-04-18 02:52:24 +03:00
|
|
|
|
sc.get();
|
2018-04-11 21:32:00 +03:00
|
|
|
|
DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
|
2015-09-02 16:15:32 +03:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2015-12-19 00:10:45 +03:00
|
|
|
|
if (Form.status_window>2) break;
|
2015-09-02 16:15:32 +03:00
|
|
|
|
_DRAW_WINDOW_CONTENT:
|
2018-04-11 21:32:00 +03:00
|
|
|
|
|
2019-05-10 15:51:47 +03:00
|
|
|
|
kfont.bold = bold.checked;
|
|
|
|
|
kfont.smooth = smooth.checked;
|
|
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
|
DrawBar(0, 0, WIN_W, PANELH-1, sc.work);
|
|
|
|
|
DrawBar(0, PANELH-1,WIN_W,1,sc.work_graph);
|
2018-04-11 21:32:00 +03:00
|
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
|
if (!kfont.font) {
|
2018-04-11 21:32:00 +03:00
|
|
|
|
DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
|
2015-12-17 22:15:49 +03:00
|
|
|
|
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
|
2020-05-26 03:17:12 +03:00
|
|
|
|
} else {
|
|
|
|
|
bold.draw(10, 8);
|
|
|
|
|
smooth.draw(83,8);
|
|
|
|
|
colored.draw(170,8);
|
|
|
|
|
tabs.draw();
|
|
|
|
|
tabs.draw_active_tab();
|
2015-09-02 16:15:32 +03:00
|
|
|
|
}
|
2016-02-20 16:06:19 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-10 15:51:47 +03:00
|
|
|
|
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266,
|
2020-05-26 03:17:12 +03:00
|
|
|
|
0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 };
|
2019-05-10 15:51:47 +03:00
|
|
|
|
|
2016-02-20 16:06:19 +03:00
|
|
|
|
void DrawPreviewPhrase()
|
|
|
|
|
{
|
|
|
|
|
dword i, y;
|
2019-05-10 15:51:47 +03:00
|
|
|
|
dword c;
|
2016-02-20 16:06:19 +03:00
|
|
|
|
char line[256];
|
2016-12-21 22:50:13 +03:00
|
|
|
|
kfont.raw_size = free(kfont.raw);
|
2019-05-10 15:51:47 +03:00
|
|
|
|
for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
|
2016-02-20 16:06:19 +03:00
|
|
|
|
{
|
2019-05-10 15:51:47 +03:00
|
|
|
|
if (colored.checked) c = pal[i-10]; else c=0;
|
2020-05-26 03:17:12 +03:00
|
|
|
|
strcpy(#line, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/font size is ");
|
2020-04-05 22:29:24 +03:00
|
|
|
|
strcat(#line, itoa(i));
|
|
|
|
|
strcat(#line, " <20><><EFBFBD>ᥫ<EFBFBD><E1A5AB>/px.");
|
2020-05-26 03:17:12 +03:00
|
|
|
|
kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line);
|
2016-02-20 16:06:19 +03:00
|
|
|
|
}
|
2016-12-21 22:50:13 +03:00
|
|
|
|
if (kfont.smooth) kfont.ApplySmooth();
|
2018-04-11 21:32:00 +03:00
|
|
|
|
kfont.ShowBuffer(preview.x, preview.y);
|
2016-02-20 16:06:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawPreviewChars()
|
|
|
|
|
{
|
|
|
|
|
dword i, x=20, y=0;
|
2020-05-26 03:17:12 +03:00
|
|
|
|
char line[2]=0;
|
2016-12-21 22:50:13 +03:00
|
|
|
|
kfont.raw_size = free(kfont.raw);
|
2016-02-20 16:06:19 +03:00
|
|
|
|
for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
|
|
|
|
|
{
|
|
|
|
|
line[0]=i;
|
2020-05-26 03:17:12 +03:00
|
|
|
|
kfont.WriteIntoBuffer(x,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, 0, 16, #line);
|
2016-12-21 22:50:13 +03:00
|
|
|
|
x+= kfont.height+2;
|
2018-04-11 21:32:00 +03:00
|
|
|
|
if (x>=preview.w-30) {
|
2016-02-20 16:06:19 +03:00
|
|
|
|
x=20;
|
2016-12-21 22:50:13 +03:00
|
|
|
|
y+=kfont.height+2;
|
2016-02-20 16:06:19 +03:00
|
|
|
|
}
|
2015-08-27 11:33:51 +03:00
|
|
|
|
}
|
2016-12-21 22:50:13 +03:00
|
|
|
|
if (kfont.smooth) kfont.ApplySmooth();
|
2018-04-11 21:32:00 +03:00
|
|
|
|
kfont.ShowBuffer(preview.x, preview.y);
|
2015-08-27 11:33:51 +03:00
|
|
|
|
}
|