2020-05-26 02:17:12 +02:00
|
|
|
|
#define MEMSIZE 1024*30
|
2022-01-08 23:36:47 +01:00
|
|
|
|
#define ENTRY_POINT #main
|
2015-08-27 10:33:51 +02:00
|
|
|
|
|
2016-12-21 16:40:39 +01:00
|
|
|
|
#include "../lib/kfont.h"
|
2015-08-27 10:33:51 +02:00
|
|
|
|
#include "../lib/gui.h"
|
|
|
|
|
|
2022-01-08 23:36:47 +01:00
|
|
|
|
#define BARH 28
|
|
|
|
|
#define WINW 528
|
|
|
|
|
#define WINH 315
|
2016-02-20 14:06:19 +01:00
|
|
|
|
|
2022-01-08 23:36:47 +01:00
|
|
|
|
char active_tab = 0;
|
|
|
|
|
char colored = true;
|
|
|
|
|
dword checkbox_flag;
|
2015-09-02 15:15:32 +02:00
|
|
|
|
|
2015-08-27 10:33:51 +02:00
|
|
|
|
void main()
|
|
|
|
|
{
|
2020-05-26 02:17:12 +02:00
|
|
|
|
proc_info Form;
|
2022-01-08 23:36:47 +01:00
|
|
|
|
|
|
|
|
|
mem_init();
|
|
|
|
|
checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ);
|
2020-05-26 02:17:12 +02:00
|
|
|
|
|
2015-12-17 20:15:49 +01:00
|
|
|
|
if (!param) strcpy(#param, DEFAULT_FONT);
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.init(#param);
|
2015-11-06 15:49:37 +01:00
|
|
|
|
strcpy(#title, "Font preview: ");
|
2015-08-27 10:33:51 +02:00
|
|
|
|
strcat(#title, #param);
|
2020-05-10 14:49:02 +02:00
|
|
|
|
|
2020-05-26 02:17:12 +02:00
|
|
|
|
loop() switch(@WaitEvent())
|
2015-08-27 10:33:51 +02:00
|
|
|
|
{
|
2022-01-08 23:36:47 +01:00
|
|
|
|
case evKey:
|
|
|
|
|
@GetKey();
|
|
|
|
|
EAX >>= 16;
|
|
|
|
|
if (AL == SCAN_CODE_ESC) ExitProcess();
|
|
|
|
|
if (AL == SCAN_CODE_TAB) {
|
|
|
|
|
active_tab^=1;
|
|
|
|
|
goto _DRAW_WINDOW_CONTENT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2015-08-27 10:33:51 +02:00
|
|
|
|
case evButton:
|
2022-01-08 23:36:47 +01:00
|
|
|
|
@GetButtonID();
|
|
|
|
|
if (EAX==1) ExitProcess();
|
|
|
|
|
if (EAX==2) kfont.bold^=1;
|
|
|
|
|
if (EAX==3) kfont.smooth^=1;
|
|
|
|
|
if (EAX==4) colored^=1;
|
|
|
|
|
if (EAX==5) active_tab=0;
|
|
|
|
|
if (EAX==6) active_tab=1;
|
2020-05-26 02:17:12 +02:00
|
|
|
|
GOTO _DRAW_WINDOW_CONTENT;
|
|
|
|
|
|
2015-08-27 10:33:51 +02:00
|
|
|
|
case evReDraw:
|
2020-04-18 01:52:24 +02:00
|
|
|
|
sc.get();
|
2022-01-08 23:36:47 +01:00
|
|
|
|
DefineAndDrawWindow(215,100,WINW+9,WINH+GetSkinHeight()+4,0x74,0xFFFFFF,#title,0);
|
2015-09-02 15:15:32 +02:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2021-06-26 09:59:13 +02:00
|
|
|
|
if (Form.status_window&ROLLED_UP) break;
|
2015-09-02 15:15:32 +02:00
|
|
|
|
_DRAW_WINDOW_CONTENT:
|
2018-04-11 20:32:00 +02:00
|
|
|
|
|
2022-01-08 23:36:47 +01:00
|
|
|
|
DrawBar(0, 0, WINW, BARH-1, sc.work);
|
|
|
|
|
DrawBar(0, BARH-1,WINW,1,sc.work_graph);
|
2018-04-11 20:32:00 +02:00
|
|
|
|
|
2020-05-26 02:17:12 +02:00
|
|
|
|
if (!kfont.font) {
|
2022-01-08 23:36:47 +01:00
|
|
|
|
DrawBar(0, BARH, WINW, WINH - BARH, 0xFFFfff);
|
2015-12-17 20:15:49 +01:00
|
|
|
|
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
|
2020-05-26 02:17:12 +02:00
|
|
|
|
} else {
|
2022-01-08 23:36:47 +01:00
|
|
|
|
draw_checkbox(9, kfont.bold);
|
|
|
|
|
draw_checkbox(81, kfont.smooth);
|
|
|
|
|
draw_checkbox(169, colored);
|
|
|
|
|
WriteText(30, 8, 0x90, sc.work_text, "Bold Smooth Colored Phrase Chars");
|
|
|
|
|
UnsafeDefineButton(0, 3, 70, 24, 2+BT_HIDE+BT_NOFRAME, ESI);
|
|
|
|
|
$inc edx //11
|
|
|
|
|
$add ebx, 80 << 16
|
|
|
|
|
$int 64
|
|
|
|
|
$inc edx //12
|
|
|
|
|
$add ebx, 88 << 16
|
|
|
|
|
$int 64
|
|
|
|
|
$inc edx //13
|
|
|
|
|
$add ebx, 162 << 16
|
|
|
|
|
$int 64
|
|
|
|
|
$inc edx //14
|
|
|
|
|
$add ebx, 70 << 16
|
|
|
|
|
$int 64
|
|
|
|
|
DrawBar(active_tab*70+335, BARH-4, 60, 4, 0xE44C9C);
|
|
|
|
|
if (!active_tab) DrawPreviewPhrase(); else DrawPreviewChars();
|
2015-09-02 15:15:32 +02:00
|
|
|
|
}
|
2016-02-20 14:06:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-10 14:51:47 +02:00
|
|
|
|
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266,
|
2020-05-26 02:17:12 +02:00
|
|
|
|
0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 };
|
2019-05-10 14:51:47 +02:00
|
|
|
|
|
2016-02-20 14:06:19 +01:00
|
|
|
|
void DrawPreviewPhrase()
|
|
|
|
|
{
|
2022-01-08 23:36:47 +01:00
|
|
|
|
dword i, y=12;
|
|
|
|
|
dword line[64];
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.raw_size = free(kfont.raw);
|
2022-01-08 23:36:47 +01:00
|
|
|
|
for (i=10; i<22; i++) //not flexible, need to calculate font count and max line length
|
2016-02-20 14:06:19 +01:00
|
|
|
|
{
|
2020-05-26 02:17:12 +02:00
|
|
|
|
strcpy(#line, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/font size is ");
|
2022-01-08 23:36:47 +01:00
|
|
|
|
itoa_(#line+27, i);
|
2020-04-05 21:29:24 +02:00
|
|
|
|
strcat(#line, " <20><><EFBFBD>ᥫ<EFBFBD><E1A5AB>/px.");
|
2022-01-08 23:36:47 +01:00
|
|
|
|
kfont.WriteIntoBuffer(14,y,WINW,WINH-BARH, 0xFFFFFF, pal[i-10]*colored, i, #line);
|
|
|
|
|
y+=kfont.height+3;
|
2016-02-20 14:06:19 +01:00
|
|
|
|
}
|
2022-01-08 23:36:47 +01:00
|
|
|
|
DrawBuf();
|
2016-02-20 14:06:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawPreviewChars()
|
|
|
|
|
{
|
|
|
|
|
dword i, x=20, y=0;
|
2022-01-08 23:36:47 +01:00
|
|
|
|
char line[2];
|
2016-12-21 20:50:13 +01:00
|
|
|
|
kfont.raw_size = free(kfont.raw);
|
2022-01-08 23:36:47 +01:00
|
|
|
|
for (i=0; i<255; i++)
|
2016-02-20 14:06:19 +01:00
|
|
|
|
{
|
|
|
|
|
line[0]=i;
|
2022-01-08 23:36:47 +01:00
|
|
|
|
kfont.WriteIntoBuffer(x,y,WINW,WINH-BARH, 0xFFFFFF, 0, 16, #line);
|
2016-12-21 20:50:13 +01:00
|
|
|
|
x+= kfont.height+2;
|
2022-01-08 23:36:47 +01:00
|
|
|
|
if (x>=WINW-30) {
|
2016-02-20 14:06:19 +01:00
|
|
|
|
x=20;
|
2016-12-21 20:50:13 +01:00
|
|
|
|
y+=kfont.height+2;
|
2016-02-20 14:06:19 +01:00
|
|
|
|
}
|
2015-08-27 10:33:51 +02:00
|
|
|
|
}
|
2022-01-08 23:36:47 +01:00
|
|
|
|
DrawBuf();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawBuf()
|
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
|
if (kfont.smooth) kfont.ApplySmooth();
|
2022-01-08 23:36:47 +01:00
|
|
|
|
kfont.ShowBuffer(0, BARH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_checkbox(dword _x, _checked)
|
|
|
|
|
{
|
|
|
|
|
#define SIZE 14
|
|
|
|
|
#define CHBOXY 7
|
|
|
|
|
DrawRectangle3D(_x, CHBOXY, SIZE, SIZE, sc.work_graph, sc.work_graph);
|
|
|
|
|
if (_checked == false)
|
|
|
|
|
{
|
|
|
|
|
DrawRectangle3D(_x+1, CHBOXY+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff);
|
|
|
|
|
DrawBar(_x+2, CHBOXY+2, SIZE-3, SIZE-3, 0xffffff);
|
|
|
|
|
} else {
|
|
|
|
|
if (checkbox_flag) _PutImage(_x+1, CHBOXY+1, 13, 13, checkbox_flag);
|
|
|
|
|
}
|
|
|
|
|
DrawRectangle3D(_x-1,CHBOXY-1,SIZE+2,SIZE+2,sc.work_dark,sc.work_light);
|
2015-08-27 10:33:51 +02:00
|
|
|
|
}
|
2022-01-08 23:36:47 +01:00
|
|
|
|
|
|
|
|
|
char title[PATHLEN];
|