mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-28 20:13:07 +00:00
seems to work
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@243 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
CC = cl
|
CC = cl
|
||||||
LD = link
|
LD = link
|
||||||
|
|
||||||
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\font.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\entry.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\unicode.obj src\font.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
||||||
OOOBJS = oosrc\base.obj oosrc\widget\button.obj oosrc\widget\frame.obj oosrc\widget\image.obj oosrc\widget\menu.obj oosrc\widget\opengl.obj oosrc\widget\scrollbar.obj oosrc\widget\submenu.obj oosrc\widget\window.obj oosrc\widget\checkbox.obj oosrc\widget\text.obj oosrc\widget\label.obj oosrc\widget\entry.obj
|
OOOBJS = oosrc\base.obj oosrc\widget\button.obj oosrc\widget\frame.obj oosrc\widget\image.obj oosrc\widget\menu.obj oosrc\widget\opengl.obj oosrc\widget\scrollbar.obj oosrc\widget\submenu.obj oosrc\widget\window.obj oosrc\widget\checkbox.obj oosrc\widget\label.obj oosrc\widget\entry.obj
|
||||||
CFLAGS = /nologo /DSTBI_NO_SIMD /D_MILSKO /DUSE_GDI /DUSE_STB_IMAGE /Iinclude
|
CFLAGS = /nologo /DSTBI_NO_SIMD /D_MILSKO /DUSE_GDI /DUSE_STB_IMAGE /Iinclude
|
||||||
CXXFLAGS = /nologo /Iinclude
|
CXXFLAGS = /nologo /Iinclude
|
||||||
LDFLAGS = /nologo /DLL /LIBPATH:src /LIBPATH:oosrc
|
LDFLAGS = /nologo /DLL /LIBPATH:src /LIBPATH:oosrc
|
||||||
|
|||||||
@@ -203,6 +203,18 @@
|
|||||||
<dt>
|
<dt>
|
||||||
<a href="#Mw_TypeDefs_h">Mw/TypeDefs.h</a>
|
<a href="#Mw_TypeDefs_h">Mw/TypeDefs.h</a>
|
||||||
</dt>
|
</dt>
|
||||||
|
<dt>
|
||||||
|
<a href="#Mw_Unicode_h">Mw/Unicode.h</a>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<a href="#Mw_Unicode_h__MwUTF8ToUTF32">MwUTF8ToUTF32</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a href="#Mw_Unicode_h__MwUTF8Length">MwUTF8Length</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a href="#Mw_Unicode_h__MwUTF8Copy">MwUTF8Copy</a>
|
||||||
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
<a href="#Mw_Widget_Button_h">Mw/Widget/Button.h</a>
|
<a href="#Mw_Widget_Button_h">Mw/Widget/Button.h</a>
|
||||||
</dt>
|
</dt>
|
||||||
@@ -1655,6 +1667,63 @@
|
|||||||
</dt>
|
</dt>
|
||||||
</dl>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
|
<h2 align="center" id="Mw_Unicode_h">Mw/Unicode.h</h2>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
Handles UTF8 stuff.
|
||||||
|
</dt>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
<pre id="Mw_Unicode_h__MwUTF8ToUTF32">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8ToUTF32</FONT></B> (
|
||||||
|
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* input,
|
||||||
|
<B><FONT COLOR="#228B22">int</FONT></B>* output
|
||||||
|
);</pre>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
output Output.
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Returns
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Bytes this multibyte takes.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
<pre id="Mw_Unicode_h__MwUTF8Length">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8Length</FONT></B> (
|
||||||
|
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* input
|
||||||
|
);</pre>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
input Input.
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Returns
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Length.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
<pre id="Mw_Unicode_h__MwUTF8Copy">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8Copy</FONT></B> (
|
||||||
|
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* src,
|
||||||
|
<B><FONT COLOR="#228B22">int</FONT></B> srcskip,
|
||||||
|
<B><FONT COLOR="#228B22">char</FONT></B>* dst,
|
||||||
|
<B><FONT COLOR="#228B22">int</FONT></B> dstskip,
|
||||||
|
<B><FONT COLOR="#228B22">int</FONT></B> len
|
||||||
|
);</pre>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
len Length.
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Returns
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Copied length in bytes.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
<h2 align="center" id="Mw_Widget_Button_h">Mw/Widget/Button.h</h2>
|
<h2 align="center" id="Mw_Widget_Button_h">Mw/Widget/Button.h</h2>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>
|
<dt>
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||||
int i, x, y, sx, sy;
|
int i = 0, x, y, sx, sy;
|
||||||
MwRect r;
|
MwRect r;
|
||||||
|
|
||||||
sx = point->x;
|
sx = point->x;
|
||||||
@@ -374,7 +374,7 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int
|
|||||||
|
|
||||||
while(text[i] != 0) {
|
while(text[i] != 0) {
|
||||||
int out;
|
int out;
|
||||||
i += MwUTF8ToUTF32(text, &out);
|
i += MwUTF8ToUTF32(text + i, &out);
|
||||||
|
|
||||||
if(out >= 0x80) out = 0;
|
if(out >= 0x80) out = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -75,14 +75,17 @@ int MwUTF8Length(const char* input) {
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len){
|
int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len) {
|
||||||
int i;
|
int i;
|
||||||
int out;
|
int out;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for(i = 0; i < srcskip; i++) src += MwUTF8ToUTF32(src, &out);
|
for(i = 0; i < srcskip; i++) src += MwUTF8ToUTF32(src, &out);
|
||||||
for(i = 0; i < dstskip; i++) dst += MwUTF8ToUTF32(dst, &out);
|
for(i = 0; i < dstskip; i++) dst += MwUTF8ToUTF32(dst, &out);
|
||||||
for(i = 0; i < len; i++){
|
for(i = 0; i < len; i++) {
|
||||||
int len = MwUTF8ToUTF32(src, &out);
|
int len;
|
||||||
|
if(src[0] == 0) break;
|
||||||
|
|
||||||
|
len = MwUTF8ToUTF32(src, &out);
|
||||||
|
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
|
|
||||||
@@ -90,7 +93,7 @@ int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len){
|
|||||||
dst += len;
|
dst += len;
|
||||||
total += len;
|
total += len;
|
||||||
}
|
}
|
||||||
dst[total] = 0;
|
dst[0] = 0;
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ static int create(MwWidget handle) {
|
|||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetText(handle, MwNtext, "こんにちは、世界 Hello, World");
|
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -53,14 +52,12 @@ static void draw(MwWidget handle) {
|
|||||||
|
|
||||||
len = (r.width - p.x * 2) / w;
|
len = (r.width - p.x * 2) / w;
|
||||||
|
|
||||||
show = malloc(len + 1);
|
show = malloc(len * 4 + 1);
|
||||||
memset(show, 0, len + 1);
|
memset(show, 0, len * 4 + 1);
|
||||||
|
|
||||||
start = (t->cursor - 1) / len;
|
start = (t->cursor - 1) / len;
|
||||||
start *= len;
|
start *= len;
|
||||||
for(i = start; i < (int)strlen(str) && i < start + len; i++) {
|
MwUTF8Copy(str, start, show, 0, len);
|
||||||
show[i - start] = str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
||||||
|
|
||||||
@@ -88,18 +85,13 @@ static void key(MwWidget handle, int code) {
|
|||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
if(code == MwLLKeyBackSpace) {
|
if(code == MwLLKeyBackSpace) {
|
||||||
int i, incr = 0;
|
|
||||||
if(t->cursor == 0) return;
|
if(t->cursor == 0) return;
|
||||||
out = malloc(strlen(str) + 1);
|
out = malloc(strlen(str) + 1);
|
||||||
|
|
||||||
t->cursor--;
|
t->cursor--;
|
||||||
|
|
||||||
for(i = 0; str[i] != 0; i++) {
|
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||||
if(i != t->cursor) {
|
MwUTF8Copy(str, t->cursor + 1, out, t->cursor, MwUTF8Length(str) - (t->cursor + 1));
|
||||||
out[incr++] = str[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out[incr++] = 0;
|
|
||||||
|
|
||||||
MwSetText(handle, MwNtext, out);
|
MwSetText(handle, MwNtext, out);
|
||||||
|
|
||||||
@@ -108,11 +100,11 @@ static void key(MwWidget handle, int code) {
|
|||||||
if(t->cursor == 0) return;
|
if(t->cursor == 0) return;
|
||||||
t->cursor--;
|
t->cursor--;
|
||||||
} else if(code == MwLLKeyRight) {
|
} else if(code == MwLLKeyRight) {
|
||||||
if(t->cursor == (int)strlen(str)) return;
|
if(t->cursor == MwUTF8Length(str)) return;
|
||||||
t->cursor++;
|
t->cursor++;
|
||||||
} else {
|
} else {
|
||||||
int incr = 0;
|
int incr = 0;
|
||||||
out = malloc(strlen(str) + 1 + 1);
|
out = malloc(strlen(str) + 1 + 1);
|
||||||
incr += MwUTF8Copy(str, 0, out, 0, t->cursor);
|
incr += MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||||
out[incr++] = code;
|
out[incr++] = code;
|
||||||
MwUTF8Copy(str, t->cursor, out, t->cursor + 1, MwUTF8Length(str) - t->cursor);
|
MwUTF8Copy(str, t->cursor, out, t->cursor + 1, MwUTF8Length(str) - t->cursor);
|
||||||
|
|||||||
Reference in New Issue
Block a user