CMM. list_box.h: handle incorect values
font.h: finally ability to write into a buffer kolibri font viewer.c: write into a buffer git-svn-id: svn://kolibrios.org@5784 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8aee87f84f
commit
6f0e6671db
@ -1,10 +1,13 @@
|
|||||||
#define MEMSIZE 0xEE80
|
#define MEMSIZE 0x2EE80
|
||||||
|
|
||||||
#include "../lib/font.h"
|
#include "../lib/font.h"
|
||||||
#include "../lib/gui.h"
|
#include "../lib/gui.h"
|
||||||
|
|
||||||
|
#define PANELH 30
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
proc_info Form;
|
||||||
word i, y, btn;
|
word i, y, btn;
|
||||||
char line[256], title[4196];
|
char line[256], title[4196];
|
||||||
font.no_bg_copy = true;
|
font.no_bg_copy = true;
|
||||||
@ -23,24 +26,30 @@ void main()
|
|||||||
if (btn==1) ExitProcess();
|
if (btn==1) ExitProcess();
|
||||||
if (btn==2) font.weight ^=1;
|
if (btn==2) font.weight ^=1;
|
||||||
if (btn==3) font.italic ^=1;
|
if (btn==3) font.italic ^=1;
|
||||||
if (btn==4) font.no_bg_copy ^=1;
|
if (btn==4) font.smooth ^=1;
|
||||||
|
goto _DRAW_WINDOW_CONTENT;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
DefineAndDrawWindow(215,100,500,320,0x33,0xFFFFFF,#title);
|
DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
|
||||||
DrawBar(0, 0, 500-9, 30, 0xCCCccc);
|
GetProcessInfo(#Form, SelfInfo);
|
||||||
|
_DRAW_WINDOW_CONTENT:
|
||||||
|
DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
|
||||||
CheckBox2(10, 8, 2, "Bold", font.weight);
|
CheckBox2(10, 8, 2, "Bold", font.weight);
|
||||||
CheckBox2(70, 8, 3, "Italic", font.italic);
|
CheckBox2(70, 8, 3, "Italic", font.italic);
|
||||||
CheckBox2(140, 8, 4, "Smooth", font.no_bg_copy);
|
CheckBox2(140, 8, 4, "Smooth", font.smooth);
|
||||||
|
font.buffer_size = free(font.buffer);
|
||||||
if (!font.data)
|
if (!font.data)
|
||||||
{
|
{
|
||||||
|
DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
|
||||||
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
|
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
|
||||||
}
|
}
|
||||||
else for (i=10, y=40; i<22; i++, y+=font.height;)
|
else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
|
||||||
{
|
{
|
||||||
font.size.text = i;
|
font.size.text = i;
|
||||||
sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
|
sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
|
||||||
font.prepare(10,y,#line);
|
font.prepare_buf(10,y,Form.cwidth,Form.cheight-PANELH, #line);
|
||||||
font.show(10, y);
|
|
||||||
}
|
}
|
||||||
|
if (font.smooth) SmoothFont(font.buffer, font.size.width, font.size.height);
|
||||||
|
font.show(0, PANELH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
:struct FONT
|
:struct FONT
|
||||||
{
|
{
|
||||||
__SIZE size;
|
__SIZE size;
|
||||||
byte r,g,b,weight,italic;
|
byte r,g,b,weight,italic, smooth;
|
||||||
byte width,height;
|
byte width,height;
|
||||||
byte encoding;
|
byte encoding;
|
||||||
dword color;
|
dword color;
|
||||||
@ -30,9 +30,8 @@
|
|||||||
word block;
|
word block;
|
||||||
dword data;
|
dword data;
|
||||||
dword begin;
|
dword begin;
|
||||||
dword size_file;
|
|
||||||
byte load(...);
|
byte load(...);
|
||||||
byte symbol(word x;byte s;dword c);
|
byte symbol(word x,y;byte s;dword c);
|
||||||
byte symbol_size(byte s);
|
byte symbol_size(byte s);
|
||||||
dword prepare(word x,y;dword text1);
|
dword prepare(word x,y;dword text1);
|
||||||
void prepare_buf(word x,y,w,h;dword text1);
|
void prepare_buf(word x,y,w,h;dword text1);
|
||||||
@ -103,10 +102,8 @@ FONT font = 0;
|
|||||||
}
|
}
|
||||||
$neg size.offset_y
|
$neg size.offset_y
|
||||||
$neg size.offset_x
|
$neg size.offset_x
|
||||||
size.height++;
|
size.height += size.offset_y; size.height++;
|
||||||
size.height += size.offset_y;
|
size.width += size.offset_x; size.width++;
|
||||||
size.width += size.offset_x;
|
|
||||||
size.width++;
|
|
||||||
IF(italic)
|
IF(italic)
|
||||||
{
|
{
|
||||||
size.w_italic = size.height/3;
|
size.w_italic = size.height/3;
|
||||||
@ -142,33 +139,29 @@ FONT font = 0;
|
|||||||
ELSE IF(s==241)s=184; //yo
|
ELSE IF(s==241)s=184; //yo
|
||||||
ELSE IF(s==240)s=168; //YO
|
ELSE IF(s==240)s=168; //YO
|
||||||
}
|
}
|
||||||
yi = 0;
|
|
||||||
iii = 0;
|
iii = 0;
|
||||||
tmp = 4*block*s + data;
|
tmp = 4*block*s + data;
|
||||||
while(yi<height)
|
for(yi=0; yi<height; yi++)
|
||||||
{
|
{
|
||||||
xi = 0;
|
for(xi=0; xi<width; xi++)
|
||||||
WHILE(xi<width)
|
{
|
||||||
{
|
IF(iii%32) _ >>= 1;
|
||||||
IF(iii%32) _ >>= 1;
|
ELSE
|
||||||
ELSE
|
{
|
||||||
{
|
tmp += 4;
|
||||||
tmp += 4;
|
_ = DSDWORD[tmp];
|
||||||
_ = DSDWORD[tmp];
|
|
||||||
}
|
|
||||||
IF(_&1)
|
|
||||||
{
|
|
||||||
IF(xi>rw)rw=xi;
|
|
||||||
IF(size.height<yi)size.height = yi;
|
|
||||||
IF(size.offset_y<0)size.offset_y = yi;
|
|
||||||
ELSE IF(yi<size.offset_y)size.offset_y = yi;
|
|
||||||
IF(!X) X = xi;
|
|
||||||
ELSE IF(X>xi)X = xi;
|
|
||||||
}
|
|
||||||
xi++;
|
|
||||||
iii++;
|
|
||||||
}
|
}
|
||||||
yi++;
|
IF(_&1)
|
||||||
|
{
|
||||||
|
IF(xi>rw)rw=xi;
|
||||||
|
IF(size.height<yi)size.height = yi;
|
||||||
|
IF(size.offset_y<0)size.offset_y = yi;
|
||||||
|
ELSE IF(yi<size.offset_y)size.offset_y = yi;
|
||||||
|
IF(!X) X = xi;
|
||||||
|
ELSE IF(X>xi)X = xi;
|
||||||
|
}
|
||||||
|
iii++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
size.width += rw;
|
size.width += rw;
|
||||||
IF(weight) size.width+=size.TMP_WEIGHT;
|
IF(weight) size.width+=size.TMP_WEIGHT;
|
||||||
@ -218,7 +211,7 @@ FONT font = 0;
|
|||||||
WHILE(DSBYTE[text1])
|
WHILE(DSBYTE[text1])
|
||||||
{
|
{
|
||||||
IF(DSBYTE[text1]=='_') len--;
|
IF(DSBYTE[text1]=='_') len--;
|
||||||
len+=symbol(len,DSBYTE[text1]);
|
len+=symbol(len,0,DSBYTE[text1]);
|
||||||
IF(weight)len+=math.ceil(size.text/17);
|
IF(weight)len+=math.ceil(size.text/17);
|
||||||
text1++;
|
text1++;
|
||||||
}
|
}
|
||||||
@ -250,7 +243,7 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:byte FONT::symbol(signed x;byte s)
|
:byte FONT::symbol(signed x,y;byte s)
|
||||||
{
|
{
|
||||||
dword xi,yi;
|
dword xi,yi;
|
||||||
dword tmp,_;
|
dword tmp,_;
|
||||||
@ -269,15 +262,12 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
ELSE IF(s==241)s=184; //yo
|
ELSE IF(s==241)s=184; //yo
|
||||||
ELSE IF(s==240)s=168; //YO
|
ELSE IF(s==240)s=168; //YO
|
||||||
}
|
}
|
||||||
yi = 0;
|
|
||||||
iii = 0;
|
iii = 0;
|
||||||
tmp = 4*block*s;
|
tmp = 4*block*s + data;
|
||||||
tmp +=data;
|
for(yi=0; yi<height; yi++)
|
||||||
while(yi<height)
|
|
||||||
{
|
{
|
||||||
xi = 0;
|
TMP = size.offset_y+yi+y;
|
||||||
TMP = size.offset_y+yi;
|
for(xi=0; xi<width; xi++)
|
||||||
while(xi<width)
|
|
||||||
{
|
{
|
||||||
IF(iii%32) _ >>= 1;
|
IF(iii%32) _ >>= 1;
|
||||||
ELSE
|
ELSE
|
||||||
@ -291,17 +281,13 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
___x = x+xi;
|
___x = x+xi;
|
||||||
IF(italic)___x+=math.ceil(ital);
|
IF(italic)___x+=math.ceil(ital);
|
||||||
PixelRGB(___x,TMP);
|
PixelRGB(___x,TMP);
|
||||||
_TMP_WEIGHT = size.TMP_WEIGHT;
|
for(_TMP_WEIGHT=size.TMP_WEIGHT; _TMP_WEIGHT; _TMP_WEIGHT--)
|
||||||
WHILE(_TMP_WEIGHT)
|
|
||||||
{
|
{
|
||||||
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP);
|
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP);
|
||||||
_TMP_WEIGHT--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xi++;
|
|
||||||
iii++;
|
iii++;
|
||||||
}
|
}
|
||||||
yi++;
|
|
||||||
IF(italic) ital-=size.offset_i;
|
IF(italic) ital-=size.offset_i;
|
||||||
}
|
}
|
||||||
return rw;
|
return rw;
|
||||||
@ -312,8 +298,7 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
IF(data)free(data);
|
IF(data)free(data);
|
||||||
if (!io.readKPACK(path)) { debug("Error while loading font: "); debugln(path); return false; }
|
if (!io.readKPACK(path)) { debug("Error while loading font: "); debugln(path); return false; }
|
||||||
begin = data = io.buffer_data;
|
begin = data = io.buffer_data;
|
||||||
size_file = io.FILES_SIZE;
|
EBX = begin + io.FILES_SIZE;
|
||||||
EBX = begin + size_file;
|
|
||||||
height = DSBYTE[EBX - 1];
|
height = DSBYTE[EBX - 1];
|
||||||
width = DSBYTE[EBX - 2];
|
width = DSBYTE[EBX - 2];
|
||||||
block = math.ceil(height*width/32);
|
block = math.ceil(height*width/32);
|
||||||
@ -322,7 +307,6 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
|
|
||||||
:void FONT::prepare_buf(word x,y,w,h; dword text1)
|
:void FONT::prepare_buf(word x,y,w,h; dword text1)
|
||||||
{
|
{
|
||||||
signed len=0;
|
|
||||||
dword c;
|
dword c;
|
||||||
c = color;
|
c = color;
|
||||||
IF(!text1)return;
|
IF(!text1)return;
|
||||||
@ -333,14 +317,16 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
|
|
||||||
size.width = w;
|
size.width = w;
|
||||||
size.height = h;
|
size.height = h;
|
||||||
|
|
||||||
EDX = size.width*size.height*3;
|
EDX = size.width*size.height*3;
|
||||||
IF(!buffer_size)
|
if(buffer_size!=EDX)
|
||||||
{
|
{
|
||||||
buffer_size = EDX;
|
buffer_size = EDX;
|
||||||
|
free(buffer);
|
||||||
buffer = malloc(buffer_size);
|
buffer = malloc(buffer_size);
|
||||||
EBX = bg_color;
|
EBX = font.bg_color;
|
||||||
EDI = buffer;
|
EDI = font.buffer;
|
||||||
EAX = buffer_size+EDI;
|
EAX = font.buffer_size+font.buffer;
|
||||||
WHILE (EDI<EAX)
|
WHILE (EDI<EAX)
|
||||||
{
|
{
|
||||||
ESDWORD[EDI] = EBX;
|
ESDWORD[EDI] = EBX;
|
||||||
@ -349,12 +335,11 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
|
|||||||
}
|
}
|
||||||
WHILE(DSBYTE[text1])
|
WHILE(DSBYTE[text1])
|
||||||
{
|
{
|
||||||
x+=symbol(x,DSBYTE[text1]);
|
x+=symbol(x,y,DSBYTE[text1]);
|
||||||
IF(weight)x+=math.ceil(size.text/17);
|
IF(weight)x+=math.ceil(size.text/17);
|
||||||
text1++;
|
text1++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -59,7 +59,7 @@ void llist::SetSizes(int xx, yy, ww, hh, line_hh)
|
|||||||
text_y = line_h - font_h / 2;
|
text_y = line_h - font_h / 2;
|
||||||
visible = h / line_h;
|
visible = h / line_h;
|
||||||
wheel_size = 3;
|
wheel_size = 3;
|
||||||
//if (visible > count) visible=count;
|
CheckDoesValuesOkey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void llist::SetFont(dword font_ww, font_hh, font_tt)
|
void llist::SetFont(dword font_ww, font_hh, font_tt)
|
||||||
@ -214,8 +214,8 @@ int llist::KeyPgDown()
|
|||||||
|
|
||||||
void llist::CheckDoesValuesOkey()
|
void llist::CheckDoesValuesOkey()
|
||||||
{
|
{
|
||||||
if (first < 0) first = 0;
|
|
||||||
if (visible + first > count) first = count - visible;
|
if (visible + first > count) first = count - visible;
|
||||||
|
if (first < 0) first = 0;
|
||||||
if (current >= count) current = count - 1;
|
if (current >= count) current = count - 1;
|
||||||
if (current < 0) current = 0;
|
if (current < 0) current = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user