little change for c_word

This commit is contained in:
idea4good 2021-03-26 16:53:22 +08:00
parent 5fb9e44b92
commit 40ab2c5ed8
4 changed files with 125 additions and 134 deletions

109
GuiLite.h
View File

@ -828,6 +828,60 @@ public:
virtual void draw_value(c_surface* surface, int z_order, int value, int dot_position, int x, int y, const void* font, unsigned int font_color, unsigned int bg_color) = 0;
virtual void draw_value_in_rect(c_surface* surface, int z_order, int value, int dot_position, c_rect rect, const void* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT) = 0;
virtual int get_str_size(const void* string, const void* font, int& width, int& height) = 0;
void get_string_pos(const void* string, const void* font, c_rect rect, unsigned int align_type, int& x, int& y)
{
int x_size, y_size;
get_str_size(string, font, x_size, y_size);
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;
x = y = 0;
switch (align_type & ALIGN_HMASK)
{
case ALIGN_HCENTER:
//m_text_org_x=0
if (width > x_size)
{
x = (width - x_size) / 2;
}
break;
case ALIGN_LEFT:
x = 0;
break;
case ALIGN_RIGHT:
//m_text_org_x=0
if (width > x_size)
{
x = width - x_size;
}
break;
default:
ASSERT(0);
break;
}
switch (align_type & ALIGN_VMASK)
{
case ALIGN_VCENTER:
//m_text_org_y=0
if (height > y_size)
{
y = (height - y_size) / 2;
}
break;
case ALIGN_TOP:
y = 0;
break;
case ALIGN_BOTTOM:
//m_text_org_y=0
if (height > y_size)
{
y = height - y_size;
}
break;
default:
ASSERT(0);
break;
}
}
};
class c_lattice_font_op: public c_font_operator
{
@ -1004,60 +1058,7 @@ private:
}
return 0;
}
void get_string_pos(const char *s, const LATTICE_FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y)
{
int x_size, y_size;
get_str_size(s, font, x_size, y_size);
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;
x = y = 0;
switch (align_type & ALIGN_HMASK)
{
case ALIGN_HCENTER:
//m_text_org_x=0
if (width > x_size)
{
x = (width - x_size) / 2;
}
break;
case ALIGN_LEFT:
x = 0;
break;
case ALIGN_RIGHT:
//m_text_org_x=0
if (width > x_size)
{
x = width - x_size;
}
break;
default:
ASSERT(0);
break;
}
switch (align_type & ALIGN_VMASK)
{
case ALIGN_VCENTER:
//m_text_org_y=0
if (height > y_size)
{
y = (height - y_size) / 2;
}
break;
case ALIGN_TOP:
y = 0;
break;
case ALIGN_BOTTOM:
//m_text_org_y=0
if (height > y_size)
{
y = height - y_size;
}
break;
default:
ASSERT(0);
break;
}
}
static int get_utf8_code(const char* s, unsigned int& output_utf8_code)
{
static unsigned char s_utf8_length_table[256] =

View File

@ -42,5 +42,5 @@ curl --include --request POST --header "Content-Type: application/json" --data-b
\"city\" :\"$city\",
\"org\" :\"$org\",
\"log\" :\"$build_time\",
\"version\" :\"v2.0\"
\"version\" :\"v2.1\"
}]" $url > /dev/null

View File

@ -17,6 +17,61 @@ public:
virtual void draw_value(c_surface* surface, int z_order, int value, int dot_position, int x, int y, const void* font, unsigned int font_color, unsigned int bg_color) = 0;
virtual void draw_value_in_rect(c_surface* surface, int z_order, int value, int dot_position, c_rect rect, const void* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT) = 0;
virtual int get_str_size(const void* string, const void* font, int& width, int& height) = 0;
void get_string_pos(const void* string, const void* font, c_rect rect, unsigned int align_type, int& x, int& y)
{
int x_size, y_size;
get_str_size(string, font, x_size, y_size);
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;
x = y = 0;
switch (align_type & ALIGN_HMASK)
{
case ALIGN_HCENTER:
//m_text_org_x=0
if (width > x_size)
{
x = (width - x_size) / 2;
}
break;
case ALIGN_LEFT:
x = 0;
break;
case ALIGN_RIGHT:
//m_text_org_x=0
if (width > x_size)
{
x = width - x_size;
}
break;
default:
ASSERT(0);
break;
}
switch (align_type & ALIGN_VMASK)
{
case ALIGN_VCENTER:
//m_text_org_y=0
if (height > y_size)
{
y = (height - y_size) / 2;
}
break;
case ALIGN_TOP:
y = 0;
break;
case ALIGN_BOTTOM:
//m_text_org_y=0
if (height > y_size)
{
y = height - y_size;
}
break;
default:
ASSERT(0);
break;
}
}
};
class c_lattice_font_op: public c_font_operator
@ -204,72 +259,7 @@ private:
}
return 0;
}
void get_string_pos(const char *s, const LATTICE_FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y)
{
int x_size, y_size;
get_str_size(s, font, x_size, y_size);
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;
x = y = 0;
switch (align_type & ALIGN_HMASK)
{
case ALIGN_HCENTER:
//m_text_org_x=0
if (width > x_size)
{
x = (width - x_size) / 2;
}
break;
case ALIGN_LEFT:
x = 0;
break;
case ALIGN_RIGHT:
//m_text_org_x=0
if (width > x_size)
{
x = width - x_size;
}
break;
default:
ASSERT(0);
break;
}
switch (align_type & ALIGN_VMASK)
{
case ALIGN_VCENTER:
//m_text_org_y=0
if (height > y_size)
{
y = (height - y_size) / 2;
}
break;
case ALIGN_TOP:
y = 0;
break;
case ALIGN_BOTTOM:
//m_text_org_y=0
if (height > y_size)
{
y = height - y_size;
}
break;
default:
ASSERT(0);
break;
}
}
static int get_utf8_code(const char* s, unsigned int& output_utf8_code)
{
static unsigned char s_utf8_length_table[256] =

View File

@ -1,8 +1,8 @@
echo off
setlocal enabledelayedexpansion
setlocal
set argC=0
for %%x in (%*) do Set /A argC+=1
for %%x in (%*) do set /A argC+=1
if NOT "1" == "%argC%" (
echo "Invalidate arguments"
goto :eof
@ -15,16 +15,16 @@ for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do (
set %%x
)
Set Second=0%Second%
Set Second=%Second:~-2%
Set Minute=0%Minute%
Set Minute=%Minute:~-2%
Set Hour=0%Hour%
Set Hour=%Hour:~-2%
Set Day=0%Day%
Set Day=%Day:~-2%
Set Month=0%Month%
Set Month=%Month:~-2%
set Second=0%Second%
set Second=%Second:~-2%
set Minute=0%Minute%
set Minute=%Minute:~-2%
set Hour=0%Hour%
set Hour=%Hour:~-2%
set Day=0%Day%
set Day=%Day:~-2%
set Month=0%Month%
set Month=%Month:~-2%
set datetime=%Year%-%Month%-%Day%T%Hour%:%Minute%:%Second%.000+0000
::----------------- for GEO info -----------------
@ -66,7 +66,7 @@ set raw_data=[{^
\"city\" :\"%city%\",^
\"org\" :\"%org%\",^
\"log\" :\"%datetime%\",^
\"version\" :\"v2.0\"^
\"version\" :\"v2.1\"^
}]
curl.exe --include --request POST --header "Content-Type: application/json" --data-binary "%raw_data%" "%url%"