From 40ab2c5ed86cd07ae038f0edda4b6dfa1d62fca4 Mon Sep 17 00:00:00 2001 From: idea4good Date: Fri, 26 Mar 2021 16:53:22 +0800 Subject: [PATCH] little change for c_word --- GuiLite.h | 109 +++++++++++++++--------------- workspace/.sync.sh | 2 +- workspace/core_include/word.h | 122 ++++++++++++++++------------------ workspace/sync_build.bat | 26 ++++---- 4 files changed, 125 insertions(+), 134 deletions(-) diff --git a/GuiLite.h b/GuiLite.h index 10036f6..8f36e48 100644 --- a/GuiLite.h +++ b/GuiLite.h @@ -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] = diff --git a/workspace/.sync.sh b/workspace/.sync.sh index 68b43ca..368cba8 100755 --- a/workspace/.sync.sh +++ b/workspace/.sync.sh @@ -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 diff --git a/workspace/core_include/word.h b/workspace/core_include/word.h index 9aac08d..18055f1 100644 --- a/workspace/core_include/word.h +++ b/workspace/core_include/word.h @@ -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] = diff --git a/workspace/sync_build.bat b/workspace/sync_build.bat index 6541350..2a978cc 100644 --- a/workspace/sync_build.bat +++ b/workspace/sync_build.bat @@ -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%"