mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
build: update x64 build configuration, clear compiler warnings
This commit is contained in:
@@ -75,4 +75,7 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {78989A38-C6FB-434B-ABF9-BC6961DD13FB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
@@ -49,7 +49,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -76,8 +76,8 @@
|
||||
<CodeAnalysisRuleAssemblies />
|
||||
<EmbedManifest>false</EmbedManifest>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
<LinkKeyFile>
|
||||
</LinkKeyFile>
|
||||
</PropertyGroup>
|
||||
@@ -89,14 +89,16 @@
|
||||
<CodeAnalysisRuleAssemblies />
|
||||
<EmbedManifest>false</EmbedManifest>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules />
|
||||
<CodeAnalysisRuleAssemblies />
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<LinkKeyFile>
|
||||
</LinkKeyFile>
|
||||
@@ -107,7 +109,9 @@
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules />
|
||||
<CodeAnalysisRuleAssemblies />
|
||||
<TargetName>$(ProjectName)_D</TargetName>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -150,7 +154,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>LCUI_EXPORTS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)LCUI;$(SolutionDir)include;$(SolutionDir)include\freetype2;$(SolutionDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\vendor\include\;$(SolutionDir)..\..\vendor\include\freetype2\;$(SolutionDir)..\..\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<DisableSpecificWarnings>4819;4244;4996;</DisableSpecificWarnings>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
@@ -165,9 +169,10 @@
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libxml2.lib;libpng16.lib;jpeg.lib;freetype271.lib;zlib.lib;kernel32.lib;user32.lib;gdi32.lib;</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT;LIBCMTD;MSVCRT;</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalDependencies>libxml2.lib;freetype.lib;libpng16.lib;zlib.lib;jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\..\vendor\lib\$(PlatformTarget)-windows\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
<LinkStatus>false</LinkStatus>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
@@ -229,7 +234,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>LCUI_EXPORTS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)LCUI;$(SolutionDir)include;$(SolutionDir)include\freetype2;$(SolutionDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\vendor\include\;$(SolutionDir)..\..\vendor\include\freetype2\;$(SolutionDir)..\..\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<DisableSpecificWarnings>4819;4244;4996</DisableSpecificWarnings>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
@@ -241,9 +246,10 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libxml2.lib;libpng16.lib;jpeg.lib;freetype271.lib;zlib.lib;kernel32.lib;user32.lib;gdi32.lib;</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT;LIBCMTD;</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalDependencies>libxml2.lib;freetype.lib;libpng16.lib;zlib.lib;jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\..\vendor\lib\$(PlatformTarget)-windows\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>libpng15.lib;jpeg.lib;libfreetype2411MT.lib;zlib.lib;</AdditionalDependencies>
|
||||
|
||||
@@ -45,13 +45,13 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -81,6 +81,14 @@
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\..\bin\$(PlatformTarget)-windows\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\$(Platform)\objs\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
@@ -101,6 +109,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\vendor\include\;$(SolutionDir)..\..\vendor\include\freetype2\;$(SolutionDir)..\..\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -132,6 +141,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\vendor\include\;$(SolutionDir)..\..\vendor\include\freetype2\;$(SolutionDir)..\..\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@@ -34,33 +34,33 @@
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
typedef struct LCUI_TextCharRec_ {
|
||||
wchar_t code; /**< 字符码 */
|
||||
LCUI_TextStyle style; /**< 该字符使用的样式数据 */
|
||||
const LCUI_FontBitmap *bitmap; /**< 字体位图数据(只读) */
|
||||
wchar_t code; /**< 字符码 */
|
||||
LCUI_TextStyle style; /**< 该字符使用的样式数据 */
|
||||
const LCUI_FontBitmap *bitmap; /**< 字体位图数据(只读) */
|
||||
} LCUI_TextCharRec, *LCUI_TextChar;
|
||||
|
||||
/** End Of Line character */
|
||||
typedef enum LCUI_EOLChar {
|
||||
LCUI_EOL_NONE, /**< 无换行 */
|
||||
LCUI_EOL_CR, /**< Mac OS 格式换行,CF = Carriage-Return,字符:\r */
|
||||
LCUI_EOL_LF, /**< UNIX/Linux 格式换行,LF = Line-Feed,字符:\r */
|
||||
LCUI_EOL_CR_LF /**< Windows 格式换行: \r\n */
|
||||
LCUI_EOL_NONE, /**< 无换行 */
|
||||
LCUI_EOL_CR, /**< Mac OS 格式换行,CF = Carriage-Return,字符:\r */
|
||||
LCUI_EOL_LF, /**< UNIX/Linux 格式换行,LF = Line-Feed,字符:\r */
|
||||
LCUI_EOL_CR_LF /**< Windows 格式换行: \r\n */
|
||||
} LCUI_EOLChar;
|
||||
|
||||
/* 文本行 */
|
||||
typedef struct TextRowRec_ {
|
||||
int width; /**< 宽度 */
|
||||
int height; /**< 高度 */
|
||||
int text_height; /**< 当前行中最大字体的高度 */
|
||||
int length; /**< 该行文本长度 */
|
||||
LCUI_TextChar *string; /**< 该行文本的数据 */
|
||||
LCUI_EOLChar eol; /**< 行尾结束类型 */
|
||||
int width; /**< 宽度 */
|
||||
int height; /**< 高度 */
|
||||
int text_height; /**< 当前行中最大字体的高度 */
|
||||
int length; /**< 该行文本长度 */
|
||||
LCUI_TextChar *string; /**< 该行文本的数据 */
|
||||
LCUI_EOLChar eol; /**< 行尾结束类型 */
|
||||
} LCUI_TextRowRec, *LCUI_TextRow;
|
||||
|
||||
/* 文本行列表 */
|
||||
typedef struct LCUI_TextRowListRec_ {
|
||||
int length; /**< 当前总行数 */
|
||||
LCUI_TextRow *rows; /**< 每一行文本的数据 */
|
||||
int length; /**< 当前总行数 */
|
||||
LCUI_TextRow *rows; /**< 每一行文本的数据 */
|
||||
} LCUI_TextRowListRec, *LCUI_TextRowList;
|
||||
|
||||
/**
|
||||
@@ -70,18 +70,19 @@ typedef struct LCUI_TextRowListRec_ {
|
||||
* content box.
|
||||
*/
|
||||
typedef enum LCUI_WordBreakMode {
|
||||
LCUI_WORD_BREAK_NORMAL, /**< 默认的断行规则,将宽度溢出的单词放到下一行 */
|
||||
LCUI_WORD_BREAK_BREAK_ALL /**< 任意字符间断行 */
|
||||
LCUI_WORD_BREAK_NORMAL, /**< 默认的断行规则,将宽度溢出的单词放到下一行
|
||||
*/
|
||||
LCUI_WORD_BREAK_BREAK_ALL /**< 任意字符间断行 */
|
||||
} LCUI_WordBreakMode;
|
||||
|
||||
typedef struct LCUI_TextLayerRec_ {
|
||||
int offset_x; /**< X轴坐标偏移量 */
|
||||
int offset_y; /**< Y轴坐标偏移量 */
|
||||
int new_offset_x; /**< 新的X轴坐标偏移量 */
|
||||
int new_offset_y; /**< 新的Y轴坐标偏移量 */
|
||||
int insert_x; /**< 光标所在列数 */
|
||||
int insert_y; /**< 光标所在行数 */
|
||||
int width; /**< 实际文本宽度 */
|
||||
int offset_x; /**< X轴坐标偏移量 */
|
||||
int offset_y; /**< Y轴坐标偏移量 */
|
||||
int new_offset_x; /**< 新的X轴坐标偏移量 */
|
||||
int new_offset_y; /**< 新的Y轴坐标偏移量 */
|
||||
int insert_x; /**< 光标所在列数 */
|
||||
int insert_y; /**< 光标所在行数 */
|
||||
int width; /**< 实际文本宽度 */
|
||||
|
||||
/**
|
||||
* 固定宽高
|
||||
@@ -95,25 +96,25 @@ typedef struct LCUI_TextLayerRec_ {
|
||||
*/
|
||||
int max_width, max_height;
|
||||
|
||||
size_t length; /**< 文本长度 */
|
||||
int line_height; /**< 全局文本行高度 */
|
||||
int text_align; /**< 文本的对齐方式 */
|
||||
LCUI_WordBreakMode word_break; /**< 单词内断行模式 */
|
||||
LCUI_BOOL enable_mulitiline; /**< 是否启用多行文本模式 */
|
||||
LCUI_BOOL enable_autowrap; /**< 是否启用自动换行模式 */
|
||||
LCUI_BOOL enable_style_tags; /**< 是否使用文本样式标签 */
|
||||
LCUI_BOOL enable_canvas; /**< 是否使用缓存空间来存储文本位图 */
|
||||
LinkedList dirty_rects; /**< 脏矩形记录 */
|
||||
LinkedList text_styles; /**< 样式缓存 */
|
||||
LCUI_TextStyleRec text_default_style; /**< 文本全局样式 */
|
||||
LCUI_TextRowListRec text_rows; /**< 文本行列表 */
|
||||
size_t length; /**< 文本长度 */
|
||||
int line_height; /**< 全局文本行高度 */
|
||||
int text_align; /**< 文本的对齐方式 */
|
||||
LCUI_WordBreakMode word_break; /**< 单词内断行模式 */
|
||||
LCUI_BOOL enable_mulitiline; /**< 是否启用多行文本模式 */
|
||||
LCUI_BOOL enable_autowrap; /**< 是否启用自动换行模式 */
|
||||
LCUI_BOOL enable_style_tags; /**< 是否使用文本样式标签 */
|
||||
LCUI_BOOL enable_canvas; /**< 是否使用缓存空间来存储文本位图 */
|
||||
LinkedList dirty_rects; /**< 脏矩形记录 */
|
||||
LinkedList text_styles; /**< 样式缓存 */
|
||||
LCUI_TextStyleRec text_default_style; /**< 文本全局样式 */
|
||||
LCUI_TextRowListRec text_rows; /**< 文本行列表 */
|
||||
struct {
|
||||
LCUI_BOOL update_bitmap; /**< 更新文本的字体位图 */
|
||||
LCUI_BOOL update_typeset; /**< 重新对文本进行排版 */
|
||||
int typeset_start_row; /**< 排版处理的起始行 */
|
||||
LCUI_BOOL redraw_all; /**< 重绘所有字体位图 */
|
||||
} task; /**< 待处理的任务 */
|
||||
LCUI_Graph canvas; /**< 文本位图缓存 */
|
||||
LCUI_BOOL update_bitmap; /**< 更新文本的字体位图 */
|
||||
LCUI_BOOL update_typeset; /**< 重新对文本进行排版 */
|
||||
int typeset_start_row; /**< 排版处理的起始行 */
|
||||
LCUI_BOOL redraw_all; /**< 重绘所有字体位图 */
|
||||
} task; /**< 待处理的任务 */
|
||||
LCUI_Graph canvas; /**< 文本位图缓存 */
|
||||
} LCUI_TextLayerRec, *LCUI_TextLayer;
|
||||
|
||||
/** 获取文本行总数 */
|
||||
@@ -132,7 +133,8 @@ LCUI_API void TextLayer_AddUpdateTypeset(LCUI_TextLayer layer, int start_row);
|
||||
LCUI_API void TextLayer_SetTextAlign(LCUI_TextLayer layer, int align);
|
||||
|
||||
/** 设置坐标偏移量 */
|
||||
LCUI_API void TextLayer_SetOffset(LCUI_TextLayer layer, int offset_x, int offset_y);
|
||||
LCUI_API void TextLayer_SetOffset(LCUI_TextLayer layer, int offset_x,
|
||||
int offset_y);
|
||||
|
||||
LCUI_API LCUI_TextLayer TextLayer_New(void);
|
||||
|
||||
@@ -140,21 +142,23 @@ LCUI_API LCUI_TextLayer TextLayer_New(void);
|
||||
LCUI_API void TextLayer_Destroy(LCUI_TextLayer layer);
|
||||
|
||||
/** 标记指定范围内容的文本行的矩形为无效 */
|
||||
LCUI_API void TextLayer_InvalidateRowsRect(LCUI_TextLayer layer,
|
||||
int start_row, int end_row);
|
||||
LCUI_API void TextLayer_InvalidateRowsRect(LCUI_TextLayer layer, int start_row,
|
||||
int end_row);
|
||||
|
||||
/** 设置插入点的行列坐标 */
|
||||
LCUI_API void TextLayer_SetCaretPos(LCUI_TextLayer layer, int row, int col);
|
||||
|
||||
/** 根据像素坐标设置文本光标的行列坐标 */
|
||||
LCUI_API int TextLayer_SetCaretPosByPixelPos(LCUI_TextLayer layer, int x, int y);
|
||||
LCUI_API int TextLayer_SetCaretPosByPixelPos(LCUI_TextLayer layer, int x,
|
||||
int y);
|
||||
|
||||
/** 获取指定行列的文字的像素坐标 */
|
||||
LCUI_API int TextLayer_GetCharPixelPos(LCUI_TextLayer layer, int row,
|
||||
int col, LCUI_Pos *pixel_pos);
|
||||
LCUI_API int TextLayer_GetCharPixelPos(LCUI_TextLayer layer, int row, int col,
|
||||
LCUI_Pos *pixel_pos);
|
||||
|
||||
/** 获取文本光标的像素坐标 */
|
||||
LCUI_API int TextLayer_GetCaretPixelPos(LCUI_TextLayer layer, LCUI_Pos *pixel_pos);
|
||||
LCUI_API int TextLayer_GetCaretPixelPos(LCUI_TextLayer layer,
|
||||
LCUI_Pos *pixel_pos);
|
||||
|
||||
/** 清空文本 */
|
||||
LCUI_API void TextLayer_ClearText(LCUI_TextLayer layer);
|
||||
@@ -174,7 +178,8 @@ LCUI_API int TextLayer_AppendTextW(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
LinkedList *tag_stack);
|
||||
|
||||
/** 追加文本内容 */
|
||||
LCUI_API int TextLayer_AppendTextA(LCUI_TextLayer layer, const char *ascii_text);
|
||||
LCUI_API int TextLayer_AppendTextA(LCUI_TextLayer layer,
|
||||
const char *ascii_text);
|
||||
|
||||
/** 追加文本内容(UTF-8版) */
|
||||
LCUI_API int TextLayer_AppendText(LCUI_TextLayer layer, const char *utf8_text);
|
||||
@@ -190,11 +195,11 @@ LCUI_API int TextLayer_SetTextA(LCUI_TextLayer layer, const char *ascii_text);
|
||||
LCUI_API int TextLayer_SetText(LCUI_TextLayer layer, const char *utf8_text);
|
||||
|
||||
/** 获取文本图层中的文本(宽字符版) */
|
||||
LCUI_API int TextLayer_GetTextW(LCUI_TextLayer layer, int start_pos,
|
||||
int max_len, wchar_t *wstr_buff);
|
||||
LCUI_API size_t TextLayer_GetTextW(LCUI_TextLayer layer, size_t start_pos,
|
||||
size_t max_len, wchar_t *wstr_buff);
|
||||
|
||||
/** 获取文本位图缓存 */
|
||||
LCUI_API LCUI_Graph* TextLayer_GetGraphBuffer(LCUI_TextLayer layer);
|
||||
LCUI_API LCUI_Graph *TextLayer_GetGraphBuffer(LCUI_TextLayer layer);
|
||||
|
||||
/** 计算并获取文本的宽度 */
|
||||
LCUI_API int TextLayer_GetWidth(LCUI_TextLayer layer);
|
||||
@@ -203,7 +208,8 @@ LCUI_API int TextLayer_GetWidth(LCUI_TextLayer layer);
|
||||
LCUI_API int TextLayer_GetHeight(LCUI_TextLayer layer);
|
||||
|
||||
/** 设置固定尺寸 */
|
||||
LCUI_API int TextLayer_SetFixedSize(LCUI_TextLayer layer, int width, int height);
|
||||
LCUI_API int TextLayer_SetFixedSize(LCUI_TextLayer layer, int width,
|
||||
int height);
|
||||
|
||||
/** 设置最大尺寸 */
|
||||
LCUI_API int TextLayer_SetMaxSize(LCUI_TextLayer layer, int width, int height);
|
||||
@@ -221,10 +227,12 @@ LCUI_API int TextLayer_TextBackspace(LCUI_TextLayer layer, int n_char);
|
||||
LCUI_API void TextLayer_SetAutoWrap(LCUI_TextLayer layer, LCUI_BOOL autowrap);
|
||||
|
||||
/** 设置单词内断行模式 */
|
||||
LCUI_API void TextLayer_SetWordBreak(LCUI_TextLayer layer, LCUI_WordBreakMode mode);
|
||||
LCUI_API void TextLayer_SetWordBreak(LCUI_TextLayer layer,
|
||||
LCUI_WordBreakMode mode);
|
||||
|
||||
/** 设置是否使用样式标签 */
|
||||
LCUI_API void TextLayer_SetUsingStyleTags(LCUI_TextLayer layer, LCUI_BOOL is_true);
|
||||
LCUI_API void TextLayer_SetUsingStyleTags(LCUI_TextLayer layer,
|
||||
LCUI_BOOL is_true);
|
||||
|
||||
/** 重新载入各个文字的字体位图 */
|
||||
LCUI_API void TextLayer_ReloadCharBitmap(LCUI_TextLayer layer);
|
||||
@@ -249,7 +257,8 @@ LCUI_API int TextLayer_RenderAll(LCUI_TextLayer layer);
|
||||
LCUI_API void TextLayer_ClearInvalidRect(LCUI_TextLayer layer);
|
||||
|
||||
/** 设置全局文本样式 */
|
||||
LCUI_API void TextLayer_SetTextStyle(LCUI_TextLayer layer, LCUI_TextStyle style);
|
||||
LCUI_API void TextLayer_SetTextStyle(LCUI_TextLayer layer,
|
||||
LCUI_TextStyle style);
|
||||
|
||||
/** 设置文本行的高度 */
|
||||
LCUI_API void TextLayer_SetLineHeight(LCUI_TextLayer layer, int height);
|
||||
|
||||
@@ -148,7 +148,7 @@ LCUI_API void PixelsFormat(const uchar_t *in_pixels, int in_color_type,
|
||||
/** 改变色彩类型 */
|
||||
LCUI_API int Graph_SetColorType(LCUI_Graph *graph, int color_type);
|
||||
|
||||
LCUI_API int Graph_Create(LCUI_Graph *graph, size_t width, size_t height);
|
||||
LCUI_API int Graph_Create(LCUI_Graph *graph, unsigned width, unsigned height);
|
||||
|
||||
LCUI_API void Graph_Copy(LCUI_Graph *des, const LCUI_Graph *src);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ LCUI_BEGIN_HEADER
|
||||
|
||||
typedef struct LCUI_StyleSheetRec_ {
|
||||
LCUI_Style sheet;
|
||||
int length;
|
||||
size_t length;
|
||||
} LCUI_StyleSheetRec, *LCUI_StyleSheet;
|
||||
|
||||
/** 选择器结点结构 */
|
||||
|
||||
@@ -45,7 +45,8 @@ LCUI_API void TextEdit_SetMultiline(LCUI_Widget widget, LCUI_BOOL is_true);
|
||||
LCUI_API void TextEdit_ClearText(LCUI_Widget widget);
|
||||
|
||||
/** 获取文本内容 */
|
||||
LCUI_API int TextEdit_GetTextW(LCUI_Widget widget, int start, int max_len, wchar_t *buf);
|
||||
LCUI_API size_t TextEdit_GetTextW(LCUI_Widget w, size_t start,
|
||||
size_t max_len, wchar_t *buf);
|
||||
|
||||
/** 获取文本长度 */
|
||||
LCUI_API size_t TextEdit_GetTextLength(LCUI_Widget w);
|
||||
|
||||
@@ -175,7 +175,7 @@ typedef struct LCUI_WidgetRec_ {
|
||||
float x, y; /**< 当前坐标(由 origin 计算而来) */
|
||||
float origin_x, origin_y; /**< 当前布局下计算出的坐标 */
|
||||
float width, height; /**< 部件区域大小,包括边框和内边距占用区域 */
|
||||
uint_t index; /**< 部件索引位置 */
|
||||
size_t index; /**< 部件索引位置 */
|
||||
char *id; /**< ID */
|
||||
char *type; /**< 类型 */
|
||||
char **classes; /**< 类列表 */
|
||||
|
||||
@@ -269,8 +269,8 @@ typedef struct LCUI_GraphQuote_ {
|
||||
} LCUI_GraphQuote;
|
||||
|
||||
struct LCUI_Graph_ {
|
||||
uint32_t width; /**< 宽度 */
|
||||
uint32_t height; /**< 高度 */
|
||||
unsigned width; /**< 宽度 */
|
||||
unsigned height; /**< 高度 */
|
||||
LCUI_GraphQuote quote; /**< 引用记录 */
|
||||
/** 像素数据缓存区 */
|
||||
union {
|
||||
@@ -278,8 +278,8 @@ struct LCUI_Graph_ {
|
||||
LCUI_ARGB *argb; /**< 指针,用于一次访问一个像素的数据 */
|
||||
};
|
||||
int color_type; /**< 色彩类型 */
|
||||
uint32_t bytes_per_pixel; /**< 每个像素共占多少个字节 */
|
||||
uint32_t bytes_per_row; /**< 每行像素共占多少个字节 */
|
||||
unsigned bytes_per_pixel; /**< 每个像素共占多少个字节 */
|
||||
unsigned bytes_per_row; /**< 每行像素共占多少个字节 */
|
||||
float opacity; /**< 全局不透明度,取值范围为 0~1.0 */
|
||||
size_t mem_size; /**< 像素数据缓冲区大小 */
|
||||
uchar_t *palette; /**< 调色板 */
|
||||
|
||||
+2
-2
@@ -52,9 +52,9 @@
|
||||
#ifdef LCUI_BUILD_IN_WIN32
|
||||
#include <Windows.h>
|
||||
#define encode(CP, WSTR, STR, LEN) \
|
||||
WideCharToMultiByte(CP, 0, WSTR, -1, STR, LEN, NULL, NULL)
|
||||
WideCharToMultiByte(CP, 0, WSTR, -1, STR, (int)LEN, NULL, NULL)
|
||||
#define decode(CP, STR, WSTR, LEN) \
|
||||
MultiByteToWideChar(CP, 0, STR, -1, WSTR, LEN)
|
||||
MultiByteToWideChar(CP, 0, STR, -1, WSTR, (int)LEN)
|
||||
#endif
|
||||
|
||||
static size_t utf8_to_ucs2(const char *utf8, wchar_t *ucs2)
|
||||
|
||||
+59
-69
@@ -38,17 +38,17 @@
|
||||
#include <LCUI/graph.h>
|
||||
#include <LCUI/font.h>
|
||||
|
||||
/** 文本添加类型 */
|
||||
/** 文本添加类型 */
|
||||
enum TextAddType {
|
||||
TAT_INSERT, /**< 插入至插入点处 */
|
||||
TAT_APPEND /**< 追加至文本末尾 */
|
||||
TAT_INSERT, /**< 插入至插入点处 */
|
||||
TAT_APPEND /**< 追加至文本末尾 */
|
||||
};
|
||||
|
||||
#define TextRowList_AddNewRow(ROWLIST) \
|
||||
TextRowList_InsertNewRow(ROWLIST, (ROWLIST)->length)
|
||||
#define TextLayer_GetRow(layer, n) \
|
||||
(n >= layer->text_rows.length) ? NULL:layer->text_rows.rows[n]
|
||||
#define GetDefaultLineHeight(H) iround( H * 1.42857143 )
|
||||
(n >= layer->text_rows.length) ? NULL : layer->text_rows.rows[n]
|
||||
#define GetDefaultLineHeight(H) iround(H * 1.42857143)
|
||||
#define ISALPHA(CH) (CH >= 'a' && CH <= 'z') || (CH >= 'A' && CH <= 'Z')
|
||||
|
||||
/* 根据对齐方式,计算文本行的起始X轴位置 */
|
||||
@@ -61,10 +61,13 @@ static int TextLayer_GetRowStartX(LCUI_TextLayer layer, LCUI_TextRow txtrow)
|
||||
width = layer->width;
|
||||
}
|
||||
switch (layer->text_align) {
|
||||
case SV_CENTER: return (width - txtrow->width) / 2;
|
||||
case SV_RIGHT: return width - txtrow->width;
|
||||
case SV_CENTER:
|
||||
return (width - txtrow->width) / 2;
|
||||
case SV_RIGHT:
|
||||
return width - txtrow->width;
|
||||
case SV_LEFT:
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -140,7 +143,7 @@ static LCUI_TextRow TextRowList_InsertNewRow(LCUI_TextRowList rowlist,
|
||||
i_row = rowlist->length;
|
||||
}
|
||||
++rowlist->length;
|
||||
size = sizeof(LCUI_TextRow)*(rowlist->length + 1);
|
||||
size = sizeof(LCUI_TextRow) * (rowlist->length + 1);
|
||||
txtrows = realloc(rowlist->rows, size);
|
||||
if (!txtrows) {
|
||||
--rowlist->length;
|
||||
@@ -178,8 +181,7 @@ static int TextRowList_RemoveRow(LCUI_TextRowList rowlist, int i_row)
|
||||
}
|
||||
|
||||
/** 更新文本行的尺寸 */
|
||||
static void TextLayer_UpdateRowSize(LCUI_TextLayer layer,
|
||||
LCUI_TextRow txtrow)
|
||||
static void TextLayer_UpdateRowSize(LCUI_TextLayer layer, LCUI_TextRow txtrow)
|
||||
{
|
||||
int i;
|
||||
LCUI_TextChar txtchar;
|
||||
@@ -209,7 +211,7 @@ static int TextRow_SetLength(LCUI_TextRow txtrow, int len)
|
||||
if (len < 0) {
|
||||
len = 0;
|
||||
}
|
||||
txtstr = realloc(txtrow->string, sizeof(LCUI_TextChar)*(len + 1));
|
||||
txtstr = realloc(txtrow->string, sizeof(LCUI_TextChar) * (len + 1));
|
||||
if (!txtstr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -265,8 +267,8 @@ static void TextChar_UpdateBitmap(LCUI_TextChar ch, LCUI_TextStyle style)
|
||||
}
|
||||
}
|
||||
while (font_ids && font_ids[i] > 0) {
|
||||
int ret = LCUIFont_GetBitmap(ch->code, font_ids[i],
|
||||
size, &ch->bitmap);
|
||||
int ret = LCUIFont_GetBitmap(ch->code, font_ids[i], size,
|
||||
&ch->bitmap);
|
||||
if (ret == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -343,7 +345,6 @@ static void TextLayer_DestroyStyleCache(LCUI_TextLayer layer)
|
||||
/** 销毁TextLayer */
|
||||
void TextLayer_Destroy(LCUI_TextLayer layer)
|
||||
{
|
||||
|
||||
RectList_Clear(&layer->dirty_rects);
|
||||
TextStyle_Destroy(&layer->text_default_style);
|
||||
TextRowList_Destroy(&layer->text_rows);
|
||||
@@ -353,8 +354,8 @@ void TextLayer_Destroy(LCUI_TextLayer layer)
|
||||
}
|
||||
|
||||
/** 获取指定文本行中的文本段的矩形区域 */
|
||||
static int TextLayer_GetRowRect(LCUI_TextLayer layer, int i_row,
|
||||
int start_col, int end_col, LCUI_Rect *rect)
|
||||
static int TextLayer_GetRowRect(LCUI_TextLayer layer, int i_row, int start_col,
|
||||
int end_col, LCUI_Rect *rect)
|
||||
{
|
||||
int i;
|
||||
LCUI_TextRow txtrow;
|
||||
@@ -383,8 +384,7 @@ static int TextLayer_GetRowRect(LCUI_TextLayer layer, int i_row,
|
||||
rect->x += txtrow->string[i]->bitmap->advance.x;
|
||||
}
|
||||
rect->width = 0;
|
||||
for (i = start_col; i <= end_col &&
|
||||
i < txtrow->length; ++i) {
|
||||
for (i = start_col; i <= end_col && i < txtrow->length; ++i) {
|
||||
if (!txtrow->string[i]->bitmap) {
|
||||
continue;
|
||||
}
|
||||
@@ -408,8 +408,8 @@ static void TextLayer_InvalidateRowRect(LCUI_TextLayer layer, int row,
|
||||
}
|
||||
|
||||
/** 标记指定范围内容的文本行的矩形为无效 */
|
||||
void TextLayer_InvalidateRowsRect(LCUI_TextLayer layer,
|
||||
int start_row, int end_row)
|
||||
void TextLayer_InvalidateRowsRect(LCUI_TextLayer layer, int start_row,
|
||||
int end_row)
|
||||
{
|
||||
int i, y;
|
||||
LCUI_Rect rect;
|
||||
@@ -505,8 +505,8 @@ int TextLayer_SetCaretPosByPixelPos(LCUI_TextLayer layer, int x, int y)
|
||||
}
|
||||
|
||||
/** 获取指定行列的文字的像素坐标 */
|
||||
int TextLayer_GetCharPixelPos(LCUI_TextLayer layer, int row,
|
||||
int col, LCUI_Pos *pixel_pos)
|
||||
int TextLayer_GetCharPixelPos(LCUI_TextLayer layer, int row, int col,
|
||||
LCUI_Pos *pixel_pos)
|
||||
{
|
||||
LCUI_TextRow txtrow;
|
||||
int i, pixel_x = 0, pixel_y = 0;
|
||||
@@ -558,8 +558,8 @@ void TextLayer_ClearText(LCUI_TextLayer layer)
|
||||
}
|
||||
|
||||
/** 对文本行进行断行 */
|
||||
static void TextLayer_BreakTextRow(LCUI_TextLayer layer, int row,
|
||||
int col, LCUI_EOLChar eol)
|
||||
static void TextLayer_BreakTextRow(LCUI_TextLayer layer, int row, int col,
|
||||
LCUI_EOLChar eol)
|
||||
{
|
||||
int n;
|
||||
LCUI_TextRow txtrow, next;
|
||||
@@ -618,7 +618,7 @@ static void TextLayer_TextRowTypeset(LCUI_TextLayer layer, int row)
|
||||
max_width = layer->max_width;
|
||||
}
|
||||
if (max_width <= 0 || !layer->enable_autowrap ||
|
||||
(layer->enable_autowrap && !layer->enable_mulitiline)) {
|
||||
(layer->enable_autowrap && !layer->enable_mulitiline)) {
|
||||
not_autowrap = TRUE;
|
||||
} else {
|
||||
not_autowrap = FALSE;
|
||||
@@ -755,8 +755,7 @@ static int TextLayer_ProcessText(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
for (p = wstr; *p; ++p) {
|
||||
if (layer->enable_style_tags) {
|
||||
const wchar_t *pp;
|
||||
pp = TextLayer_ProcessStyleTag(layer, p,
|
||||
tags, &style);
|
||||
pp = TextLayer_ProcessStyleTag(layer, p, tags, &style);
|
||||
if (pp) {
|
||||
p = pp - 1;
|
||||
continue;
|
||||
@@ -775,8 +774,7 @@ static int TextLayer_ProcessText(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
}
|
||||
/* 如果没有记录过文本行的矩形区域 */
|
||||
if (!rect_has_added) {
|
||||
TextLayer_InvalidateRowsRect(layer,
|
||||
ins_y, -1);
|
||||
TextLayer_InvalidateRowsRect(layer, ins_y, -1);
|
||||
rect_has_added = TRUE;
|
||||
start_row = ins_y;
|
||||
}
|
||||
@@ -823,8 +821,7 @@ static int TextLayer_ProcessText(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
int TextLayer_InsertTextW(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
LinkedList *tag_stack)
|
||||
{
|
||||
return TextLayer_ProcessText(layer, wstr, TAT_INSERT,
|
||||
tag_stack);
|
||||
return TextLayer_ProcessText(layer, wstr, TAT_INSERT, tag_stack);
|
||||
}
|
||||
|
||||
/** 插入文本内容 */
|
||||
@@ -843,8 +840,7 @@ int TextLayer_InsertText(LCUI_TextLayer layer, const char *utf8_str)
|
||||
int TextLayer_AppendTextW(LCUI_TextLayer layer, const wchar_t *wstr,
|
||||
LinkedList *tag_stack)
|
||||
{
|
||||
return TextLayer_ProcessText(layer, wstr, TAT_APPEND,
|
||||
tag_stack);
|
||||
return TextLayer_ProcessText(layer, wstr, TAT_APPEND, tag_stack);
|
||||
}
|
||||
|
||||
/** 追加文本内容 */
|
||||
@@ -880,16 +876,13 @@ int TextLayer_SetText(LCUI_TextLayer layer, const char *utf8_text)
|
||||
}
|
||||
|
||||
/** 获取文本图层中的文本(宽字符版) */
|
||||
int TextLayer_GetTextW(LCUI_TextLayer layer, int start_pos,
|
||||
int max_len, wchar_t *wstr_buff)
|
||||
size_t TextLayer_GetTextW(LCUI_TextLayer layer, size_t start_pos,
|
||||
size_t max_len, wchar_t *wstr_buff)
|
||||
{
|
||||
int row, col = 0, i;
|
||||
size_t row, col = 0, i;
|
||||
LCUI_TextRow row_ptr;
|
||||
|
||||
if (start_pos < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (max_len <= 0) {
|
||||
if (max_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
/* 先根据一维坐标计算行列坐标 */
|
||||
@@ -910,7 +903,7 @@ int TextLayer_GetTextW(LCUI_TextLayer layer, int start_pos,
|
||||
return i;
|
||||
}
|
||||
|
||||
LCUI_Graph* TextLayer_GetGraphBuffer(LCUI_TextLayer layer)
|
||||
LCUI_Graph *TextLayer_GetGraphBuffer(LCUI_TextLayer layer)
|
||||
{
|
||||
if (layer->enable_canvas) {
|
||||
return &layer->canvas;
|
||||
@@ -923,8 +916,7 @@ int TextLayer_GetWidth(LCUI_TextLayer layer)
|
||||
int i, row, w, max_w;
|
||||
LCUI_TextRow txtrow;
|
||||
|
||||
DEBUG_MSG("rows: %d, font-size: %d\n",
|
||||
layer->text_rows.length,
|
||||
DEBUG_MSG("rows: %d, font-size: %d\n", layer->text_rows.length,
|
||||
layer->text_default_style.pixel_size);
|
||||
for (row = 0, max_w = 0; row < layer->text_rows.length; ++row) {
|
||||
txtrow = layer->text_rows.rows[row];
|
||||
@@ -934,12 +926,10 @@ int TextLayer_GetWidth(LCUI_TextLayer layer)
|
||||
continue;
|
||||
}
|
||||
w += txtrow->string[i]->bitmap->advance.x;
|
||||
DEBUG_MSG("[%d/%d] %d %c, width: %d/%d\n",
|
||||
i, txtrow->length,
|
||||
DEBUG_MSG("[%d/%d] %d %c, width: %d/%d\n", i,
|
||||
txtrow->length, txtrow->string[i]->code,
|
||||
txtrow->string[i]->code,
|
||||
txtrow->string[i]->code,
|
||||
txtrow->string[i]->bitmap->advance.x,
|
||||
w);
|
||||
txtrow->string[i]->bitmap->advance.x, w);
|
||||
}
|
||||
if (w > max_w) {
|
||||
max_w = w;
|
||||
@@ -990,16 +980,16 @@ int TextLayer_SetMaxSize(LCUI_TextLayer layer, int width, int height)
|
||||
/** 设置是否启用多行文本模式 */
|
||||
void TextLayer_SetMultiline(LCUI_TextLayer layer, int is_true)
|
||||
{
|
||||
if ((layer->enable_mulitiline && !is_true)
|
||||
|| (!layer->enable_mulitiline && is_true)) {
|
||||
if ((layer->enable_mulitiline && !is_true) ||
|
||||
(!layer->enable_mulitiline && is_true)) {
|
||||
layer->enable_mulitiline = is_true;
|
||||
TextLayer_AddUpdateTypeset(layer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除指定行列的文字及其右边的文本 */
|
||||
static int TextLayer_TextDeleteEx(LCUI_TextLayer layer, int char_y,
|
||||
int char_x, int n_char)
|
||||
static int TextLayer_TextDeleteEx(LCUI_TextLayer layer, int char_y, int char_x,
|
||||
int n_char)
|
||||
{
|
||||
int end_x, end_y, i, j, len;
|
||||
LCUI_TextRow txtrow, end_txtrow, prev_txtrow;
|
||||
@@ -1117,8 +1107,7 @@ static int TextLayer_TextDeleteEx(LCUI_TextLayer layer, int char_y,
|
||||
TextRowList_RemoveRow(&layer->text_rows, end_y);
|
||||
/* 如果起始行无内容,并且上一行没有结束符(换行符),则
|
||||
* 说明需要删除起始行 */
|
||||
if (len <= 0 && char_y > 0 &&
|
||||
prev_txtrow->eol != LCUI_EOL_NONE) {
|
||||
if (len <= 0 && char_y > 0 && prev_txtrow->eol != LCUI_EOL_NONE) {
|
||||
TextLayer_InvalidateRowRect(layer, char_y, 0, -1);
|
||||
TextRowList_RemoveRow(&layer->text_rows, char_y);
|
||||
}
|
||||
@@ -1129,8 +1118,8 @@ static int TextLayer_TextDeleteEx(LCUI_TextLayer layer, int char_y,
|
||||
/** 删除文本光标的当前坐标右边的文本 */
|
||||
int TextLayer_TextDelete(LCUI_TextLayer layer, int n_char)
|
||||
{
|
||||
return TextLayer_TextDeleteEx(layer, layer->insert_y,
|
||||
layer->insert_x, n_char);
|
||||
return TextLayer_TextDeleteEx(layer, layer->insert_y, layer->insert_x,
|
||||
n_char);
|
||||
}
|
||||
|
||||
/** 退格删除文本,即删除文本光标的当前坐标左边的文本 */
|
||||
@@ -1170,8 +1159,8 @@ int TextLayer_TextBackspace(LCUI_TextLayer layer, int n_char)
|
||||
/* 开始删除文本 */
|
||||
TextLayer_TextDeleteEx(layer, char_y, char_x, n_char);
|
||||
/* 若最后一行被完全移除,则移动输入点至上一行的行尾处 */
|
||||
if (char_x == 0 && layer->text_rows.length > 0
|
||||
&& char_y >= layer->text_rows.length) {
|
||||
if (char_x == 0 && layer->text_rows.length > 0 &&
|
||||
char_y >= layer->text_rows.length) {
|
||||
char_y = layer->text_rows.length - 1;
|
||||
char_x = layer->text_rows.rows[char_y]->length;
|
||||
}
|
||||
@@ -1223,7 +1212,8 @@ void TextLayer_ReloadCharBitmap(LCUI_TextLayer layer)
|
||||
LCUI_TextRow txtrow = layer->text_rows.rows[row];
|
||||
for (col = 0; col < txtrow->length; ++col) {
|
||||
LCUI_TextChar txtchar = txtrow->string[col];
|
||||
TextChar_UpdateBitmap(txtchar, &layer->text_default_style);
|
||||
TextChar_UpdateBitmap(txtchar,
|
||||
&layer->text_default_style);
|
||||
}
|
||||
TextLayer_UpdateRowSize(layer, txtrow);
|
||||
}
|
||||
@@ -1245,8 +1235,8 @@ void TextLayer_Update(LCUI_TextLayer layer, LinkedList *rects)
|
||||
}
|
||||
layer->width = TextLayer_GetWidth(layer);
|
||||
/* 如果坐标偏移量有变化,记录各个文本行区域 */
|
||||
if (layer->new_offset_x != layer->offset_x
|
||||
|| layer->new_offset_y != layer->offset_y) {
|
||||
if (layer->new_offset_x != layer->offset_x ||
|
||||
layer->new_offset_y != layer->offset_y) {
|
||||
TextLayer_InvalidateRowsRect(layer, 0, -1);
|
||||
layer->offset_x = layer->new_offset_x;
|
||||
layer->offset_y = layer->new_offset_y;
|
||||
@@ -1325,14 +1315,14 @@ static void TextLayer_DrawTextRow(LCUI_TextLayer layer, LCUI_Rect *area,
|
||||
/* 计算字体位图的绘制坐标 */
|
||||
ch_pos.x = layer_pos.x + x;
|
||||
ch_pos.y = layer_pos.y + y;
|
||||
if (txtchar->style && txtchar->style->has_back_color) {
|
||||
if (txtchar->style && txtchar->style->has_back_color) {
|
||||
LCUI_Rect rect;
|
||||
rect.x = ch_pos.x;
|
||||
rect.y = ch_pos.y;
|
||||
rect.height = txtrow->height;
|
||||
rect.width = txtchar->bitmap->advance.x;
|
||||
Graph_FillRect(graph, txtchar->style->back_color,
|
||||
&rect, TRUE);
|
||||
Graph_FillRect(graph, txtchar->style->back_color, &rect,
|
||||
TRUE);
|
||||
}
|
||||
ch_pos.x += txtchar->bitmap->left;
|
||||
ch_pos.y += baseline;
|
||||
@@ -1347,8 +1337,8 @@ static void TextLayer_DrawTextRow(LCUI_TextLayer layer, LCUI_Rect *area,
|
||||
}
|
||||
}
|
||||
|
||||
int TextLayer_RenderTo(LCUI_TextLayer layer, LCUI_Rect area,
|
||||
LCUI_Pos layer_pos, LCUI_Graph *canvas)
|
||||
int TextLayer_RenderTo(LCUI_TextLayer layer, LCUI_Rect area, LCUI_Pos layer_pos,
|
||||
LCUI_Graph *canvas)
|
||||
{
|
||||
int y, row;
|
||||
LCUI_TextRow txtrow;
|
||||
@@ -1370,8 +1360,8 @@ int TextLayer_RenderTo(LCUI_TextLayer layer, LCUI_Rect area,
|
||||
}
|
||||
for (; row < layer->text_rows.length; ++row) {
|
||||
txtrow = TextLayer_GetRow(layer, row);
|
||||
TextLayer_DrawTextRow(layer, &area, canvas,
|
||||
layer_pos, txtrow, y);
|
||||
TextLayer_DrawTextRow(layer, &area, canvas, layer_pos, txtrow,
|
||||
y);
|
||||
y += txtrow->height;
|
||||
/* 超出绘制区域范围就不绘制了 */
|
||||
if (y > area.y + area.height) {
|
||||
|
||||
+3
-3
@@ -91,7 +91,7 @@ LCUI_Color ARGB(uchar_t a, uchar_t r, uchar_t g, uchar_t b)
|
||||
return color;
|
||||
}
|
||||
|
||||
static size_t get_pixel_size(int color_type)
|
||||
static unsigned get_pixel_size(int color_type)
|
||||
{
|
||||
switch (color_type) {
|
||||
case LCUI_COLOR_TYPE_INDEX8:
|
||||
@@ -734,7 +734,7 @@ int Graph_SetColorType(LCUI_Graph *graph, int color_type)
|
||||
return -2;
|
||||
}
|
||||
|
||||
int Graph_Create(LCUI_Graph *graph, size_t width, size_t height)
|
||||
int Graph_Create(LCUI_Graph *graph, unsigned width, unsigned height)
|
||||
{
|
||||
size_t size;
|
||||
if (width > 10000 || height > 10000) {
|
||||
@@ -1214,7 +1214,7 @@ int Graph_Tile(LCUI_Graph *buff, const LCUI_Graph *graph, LCUI_BOOL replace,
|
||||
LCUI_BOOL with_alpha)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t x, y;
|
||||
unsigned x, y;
|
||||
|
||||
if (!Graph_IsValid(graph) || !Graph_IsValid(buff)) {
|
||||
return -1;
|
||||
|
||||
+98
-88
@@ -28,7 +28,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -40,8 +39,8 @@
|
||||
#include <LCUI/gui/css_library.h>
|
||||
#include <LCUI/gui/css_parser.h>
|
||||
|
||||
#define MAX_NAME_LEN 256
|
||||
#define LEN(A) sizeof( A ) / sizeof( *A )
|
||||
#define MAX_NAME_LEN 256
|
||||
#define LEN(A) sizeof(A) / sizeof(*A)
|
||||
|
||||
enum SelectorRank {
|
||||
GENERAL_RANK = 0,
|
||||
@@ -64,47 +63,47 @@ enum SelectorFinderLevel {
|
||||
|
||||
/* 样式表查找器的上下文数据结构 */
|
||||
typedef struct NamesFinderRec_ {
|
||||
int level; /**< 当前选择器层级 */
|
||||
int class_i; /**< 当前处理到第几个类名 */
|
||||
int status_i; /**< 当前处理到第几个状态名(伪类名) */
|
||||
int name_i; /**< 选择器名称从第几个字符开始 */
|
||||
char name[MAX_NAME_LEN]; /**< 选择器名称缓存 */
|
||||
LCUI_SelectorNode node; /**< 针对的选择器结点 */
|
||||
int level; /**< 当前选择器层级 */
|
||||
int class_i; /**< 当前处理到第几个类名 */
|
||||
int status_i; /**< 当前处理到第几个状态名(伪类名) */
|
||||
int name_i; /**< 选择器名称从第几个字符开始 */
|
||||
char name[MAX_NAME_LEN]; /**< 选择器名称缓存 */
|
||||
LCUI_SelectorNode node; /**< 针对的选择器结点 */
|
||||
} NamesFinderRec, *NamesFinder;
|
||||
|
||||
/** 样式链接记录组 */
|
||||
typedef struct StyleLinkGroupRec_ {
|
||||
Dict *links; /**< 样式链接表 */
|
||||
char *name; /**< 选择器名称 */
|
||||
LCUI_SelectorNode snode; /**< 选择器结点 */
|
||||
Dict *links; /**< 样式链接表 */
|
||||
char *name; /**< 选择器名称 */
|
||||
LCUI_SelectorNode snode; /**< 选择器结点 */
|
||||
} StyleLinkGroupRec, *StyleLinkGroup;
|
||||
|
||||
/** 样式结点记录 */
|
||||
typedef struct StyleNodeRec_ {
|
||||
int rank; /**< 权值,决定优先级 */
|
||||
int batch_num; /**< 批次号 */
|
||||
char *space; /**< 所属的空间 */
|
||||
char *selector; /**< 选择器 */
|
||||
LCUI_StyleSheet sheet; /**< 样式表 */
|
||||
int rank; /**< 权值,决定优先级 */
|
||||
int batch_num; /**< 批次号 */
|
||||
char *space; /**< 所属的空间 */
|
||||
char *selector; /**< 选择器 */
|
||||
LCUI_StyleSheet sheet; /**< 样式表 */
|
||||
} StyleNodeRec, *StyleNode;
|
||||
|
||||
/** 样式链接记录 */
|
||||
typedef struct StyleLinkRec_ {
|
||||
char *selector; /**< 选择器 */
|
||||
StyleLinkGroup group; /**< 所属组 */
|
||||
LinkedList styles; /**< 作用于当前选择器的样式 */
|
||||
Dict *parents; /**< 父级节点 */
|
||||
char *selector; /**< 选择器 */
|
||||
StyleLinkGroup group; /**< 所属组 */
|
||||
LinkedList styles; /**< 作用于当前选择器的样式 */
|
||||
Dict *parents; /**< 父级节点 */
|
||||
} StyleLinkRec, *StyleLink;
|
||||
|
||||
static struct {
|
||||
LCUI_BOOL active;
|
||||
LCUI_Mutex mutex; /**< 互斥锁 */
|
||||
LinkedList groups; /**< 样式组列表 */
|
||||
Dict *cache; /**< 样式表缓存,以选择器的 hash 值索引 */
|
||||
Dict *names; /**< 样式属性名称表,以值的名称索引 */
|
||||
Dict *value_keys; /**< 样式属性值表,以值的名称索引 */
|
||||
Dict *value_names; /**< 样式属性值名称表,以值索引 */
|
||||
size_t count; /**< 当前记录的属性数量 */
|
||||
LCUI_Mutex mutex; /**< 互斥锁 */
|
||||
LinkedList groups; /**< 样式组列表 */
|
||||
Dict *cache; /**< 样式表缓存,以选择器的 hash 值索引 */
|
||||
Dict *names; /**< 样式属性名称表,以值的名称索引 */
|
||||
Dict *value_keys; /**< 样式属性值表,以值的名称索引 */
|
||||
Dict *value_names; /**< 样式属性值名称表,以值索引 */
|
||||
int count; /**< 当前记录的属性数量 */
|
||||
} library;
|
||||
|
||||
/** 样式字符串值与标识码 */
|
||||
@@ -310,8 +309,7 @@ int LCUI_GetStyleTotal(void)
|
||||
return library.count;
|
||||
}
|
||||
|
||||
LCUI_BOOL SelectorNode_Match(LCUI_SelectorNode sn1,
|
||||
LCUI_SelectorNode sn2)
|
||||
LCUI_BOOL SelectorNode_Match(LCUI_SelectorNode sn1, LCUI_SelectorNode sn2)
|
||||
{
|
||||
int i, j;
|
||||
if (sn2->id) {
|
||||
@@ -330,8 +328,8 @@ LCUI_BOOL SelectorNode_Match(LCUI_SelectorNode sn1,
|
||||
}
|
||||
for (i = 0; sn2->classes[i]; ++i) {
|
||||
for (j = 0; sn1->classes[j]; ++j) {
|
||||
if (strcmp(sn2->classes[i],
|
||||
sn1->classes[i]) == 0) {
|
||||
if (strcmp(sn2->classes[i], sn1->classes[i]) ==
|
||||
0) {
|
||||
j = -1;
|
||||
break;
|
||||
}
|
||||
@@ -347,8 +345,8 @@ LCUI_BOOL SelectorNode_Match(LCUI_SelectorNode sn1,
|
||||
}
|
||||
for (i = 0; sn2->status[i]; ++i) {
|
||||
for (j = 0; sn1->status[j]; ++j) {
|
||||
if (strcmp(sn2->status[i],
|
||||
sn1->status[i]) == 0) {
|
||||
if (strcmp(sn2->status[i], sn1->status[i]) ==
|
||||
0) {
|
||||
j = -1;
|
||||
break;
|
||||
}
|
||||
@@ -446,7 +444,8 @@ void StyleSheet_Clear(LCUI_StyleSheet ss)
|
||||
free(s->string);
|
||||
}
|
||||
s->string = NULL;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
s->is_valid = FALSE;
|
||||
}
|
||||
@@ -462,9 +461,10 @@ void StyleSheet_Delete(LCUI_StyleSheet ss)
|
||||
int StyleSheet_Merge(LCUI_StyleSheet dest, LCUI_StyleSheet src)
|
||||
{
|
||||
LCUI_Style s;
|
||||
int i, count, size;
|
||||
size_t i, count, size;
|
||||
|
||||
if (src->length > dest->length) {
|
||||
size = sizeof(LCUI_StyleRec)*src->length;
|
||||
size = sizeof(LCUI_StyleRec) * src->length;
|
||||
s = realloc(dest->sheet, size);
|
||||
if (!s) {
|
||||
return -1;
|
||||
@@ -503,9 +503,10 @@ int StyleSheet_Merge(LCUI_StyleSheet dest, LCUI_StyleSheet src)
|
||||
int StyleSheet_Replace(LCUI_StyleSheet dest, LCUI_StyleSheet src)
|
||||
{
|
||||
LCUI_Style s;
|
||||
int i, count, size;
|
||||
size_t i, count, size;
|
||||
|
||||
if (src->length > dest->length) {
|
||||
size = sizeof(LCUI_StyleRec)*src->length;
|
||||
size = sizeof(LCUI_StyleRec) * src->length;
|
||||
s = realloc(dest->sheet, size);
|
||||
if (!s) {
|
||||
return -1;
|
||||
@@ -544,7 +545,7 @@ int StyleSheet_Replace(LCUI_StyleSheet dest, LCUI_StyleSheet src)
|
||||
s->type = src->sheet[i].type;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
/** 初始化样式表查找器 */
|
||||
@@ -572,8 +573,10 @@ static void NamesFinder_Destroy(NamesFinder sfinder)
|
||||
/* 生成选择器全名列表 */
|
||||
static int NamesFinder_Find(NamesFinder sfinder, LinkedList *list)
|
||||
{
|
||||
int i, len, old_len, old_level, count = 0;
|
||||
size_t len, old_len;
|
||||
int i, old_level, count = 0;
|
||||
char *fullname = sfinder->name + sfinder->name_i;
|
||||
|
||||
old_len = len = strlen(fullname);
|
||||
old_level = sfinder->level;
|
||||
switch (sfinder->level) {
|
||||
@@ -704,7 +707,8 @@ static int NamesFinder_Find(NamesFinder sfinder, LinkedList *list)
|
||||
}
|
||||
fullname[old_len] = 0;
|
||||
return count;
|
||||
default:break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (i = sfinder->level + 1; i < LEVEL_TOTAL_NUM; ++i) {
|
||||
if (i == LEVEL_STATUS_2 || i == LEVEL_CLASS_2) {
|
||||
@@ -718,8 +722,8 @@ static int NamesFinder_Find(NamesFinder sfinder, LinkedList *list)
|
||||
return count;
|
||||
}
|
||||
|
||||
static int SelectorNode_Save(LCUI_SelectorNode node,
|
||||
const char *name, int len, char type)
|
||||
static int SelectorNode_Save(LCUI_SelectorNode node, const char *name, int len,
|
||||
char type)
|
||||
{
|
||||
char *str;
|
||||
if (len < 1) {
|
||||
@@ -754,7 +758,8 @@ static int SelectorNode_Save(LCUI_SelectorNode node,
|
||||
strncpy(str, name, len);
|
||||
node->id = str;
|
||||
return ID_RANK;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -771,7 +776,7 @@ int SelectorNode_GetNames(LCUI_SelectorNode sn, LinkedList *names)
|
||||
|
||||
int SelectorNode_Update(LCUI_SelectorNode node)
|
||||
{
|
||||
int i, len = 0;
|
||||
size_t i, len = 0;
|
||||
char *fullname;
|
||||
|
||||
node->rank = 0;
|
||||
@@ -829,7 +834,7 @@ int SelectorNode_Update(LCUI_SelectorNode node)
|
||||
free(node->fullname);
|
||||
}
|
||||
node->fullname = fullname;
|
||||
return len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Selector_Update(LCUI_Selector s)
|
||||
@@ -838,7 +843,7 @@ void Selector_Update(LCUI_Selector s)
|
||||
const unsigned char *p;
|
||||
unsigned int hash = 5381;
|
||||
for (i = 0; i < s->length; ++i) {
|
||||
p = (unsigned char*)s->nodes[i]->fullname;
|
||||
p = (unsigned char *)s->nodes[i]->fullname;
|
||||
while (*p) {
|
||||
hash = ((hash << 5) + hash) + (*p++);
|
||||
}
|
||||
@@ -867,8 +872,9 @@ LCUI_Selector Selector(const char *selector)
|
||||
if (!node && is_saving) {
|
||||
node = NEW(LCUI_SelectorNodeRec, 1);
|
||||
if (si >= MAX_SELECTOR_DEPTH) {
|
||||
_DEBUG_MSG("%s: selector node list is too long.\n",
|
||||
selector);
|
||||
_DEBUG_MSG(
|
||||
"%s: selector node list is too long.\n",
|
||||
selector);
|
||||
return NULL;
|
||||
}
|
||||
s->nodes[si] = node;
|
||||
@@ -922,11 +928,12 @@ LCUI_Selector Selector(const char *selector)
|
||||
node = NULL;
|
||||
ni = 0;
|
||||
continue;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (*p == '-' || *p == '_' || *p == '*'
|
||||
|| (*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')
|
||||
|| (*p >= '0' && *p <= '9')) {
|
||||
if (*p == '-' || *p == '_' || *p == '*' ||
|
||||
(*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') ||
|
||||
(*p >= '0' && *p <= '9')) {
|
||||
if (!is_saving) {
|
||||
type = 0;
|
||||
is_saving = TRUE;
|
||||
@@ -935,16 +942,17 @@ LCUI_Selector Selector(const char *selector)
|
||||
name[ni] = 0;
|
||||
continue;
|
||||
}
|
||||
_DEBUG_MSG("%s: unknown char 0x%02x at %ld.\n",
|
||||
selector, *p, p - selector);
|
||||
_DEBUG_MSG("%s: unknown char 0x%02x at %ld.\n", selector, *p,
|
||||
p - selector);
|
||||
return NULL;
|
||||
}
|
||||
if (is_saving) {
|
||||
if (!node) {
|
||||
node = NEW(LCUI_SelectorNodeRec, 1);
|
||||
if (si >= MAX_SELECTOR_DEPTH) {
|
||||
_DEBUG_MSG("%s: selector node list is too long.\n",
|
||||
selector);
|
||||
_DEBUG_MSG(
|
||||
"%s: selector node list is too long.\n",
|
||||
selector);
|
||||
return NULL;
|
||||
}
|
||||
s->nodes[si] = node;
|
||||
@@ -1122,8 +1130,8 @@ static LCUI_StyleSheet LCUI_SelectStyleSheet(LCUI_Selector selector,
|
||||
return snode->sheet;
|
||||
}
|
||||
|
||||
int LCUI_PutStyleSheet(LCUI_Selector selector,
|
||||
LCUI_StyleSheet in_ss, const char *space)
|
||||
int LCUI_PutStyleSheet(LCUI_Selector selector, LCUI_StyleSheet in_ss,
|
||||
const char *space)
|
||||
{
|
||||
LCUI_StyleSheet ss;
|
||||
LCUIMutex_Lock(&library.mutex);
|
||||
@@ -1136,8 +1144,10 @@ int LCUI_PutStyleSheet(LCUI_Selector selector,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int StyleLink_GetStyleSheets(StyleLink link, LinkedList *outlist)
|
||||
static size_t StyleLink_GetStyleSheets(StyleLink link, LinkedList *outlist)
|
||||
{
|
||||
size_t i;
|
||||
LCUI_BOOL found;
|
||||
StyleNode snode, out_snode;
|
||||
LinkedListNode *node, *out_node;
|
||||
|
||||
@@ -1145,12 +1155,13 @@ static int StyleLink_GetStyleSheets(StyleLink link, LinkedList *outlist)
|
||||
return link->styles.length;
|
||||
}
|
||||
for (LinkedList_Each(node, &link->styles)) {
|
||||
int pos = -1, i = 0;
|
||||
i = 0;
|
||||
found = FALSE;
|
||||
snode = node->data;
|
||||
for (LinkedList_Each(out_node, outlist)) {
|
||||
out_snode = out_node->data;
|
||||
if (snode->rank > out_snode->rank) {
|
||||
pos = i;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
if (snode->rank != out_snode->rank) {
|
||||
@@ -1158,13 +1169,13 @@ static int StyleLink_GetStyleSheets(StyleLink link, LinkedList *outlist)
|
||||
continue;
|
||||
}
|
||||
if (snode->batch_num > out_snode->batch_num) {
|
||||
pos = i;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (pos >= 0) {
|
||||
LinkedList_Insert(outlist, pos, snode);
|
||||
if (found) {
|
||||
LinkedList_Insert(outlist, i, snode);
|
||||
} else {
|
||||
LinkedList_Append(outlist, snode);
|
||||
}
|
||||
@@ -1172,10 +1183,10 @@ static int StyleLink_GetStyleSheets(StyleLink link, LinkedList *outlist)
|
||||
return link->styles.length;
|
||||
}
|
||||
|
||||
static int LCUI_FindStyleSheetFromLink(StyleLink link, LCUI_Selector s,
|
||||
int i, LinkedList *list)
|
||||
static size_t LCUI_FindStyleSheetFromLink(StyleLink link, LCUI_Selector s,
|
||||
int i, LinkedList *list)
|
||||
{
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
StyleLink parent;
|
||||
LinkedList names;
|
||||
LinkedListNode *node;
|
||||
@@ -1191,18 +1202,19 @@ static int LCUI_FindStyleSheetFromLink(StyleLink link, LCUI_Selector s,
|
||||
if (!parent) {
|
||||
continue;
|
||||
}
|
||||
count += LCUI_FindStyleSheetFromLink(parent, s,
|
||||
i, list);
|
||||
count +=
|
||||
LCUI_FindStyleSheetFromLink(parent, s, i, list);
|
||||
}
|
||||
LinkedList_Clear(&names, free);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int LCUI_FindStyleSheetFromGroup(int group, const char *name,
|
||||
LCUI_Selector s, LinkedList *list)
|
||||
int LCUI_FindStyleSheetFromGroup(int group, const char *name, LCUI_Selector s,
|
||||
LinkedList *list)
|
||||
{
|
||||
int i, count;
|
||||
int i;
|
||||
size_t count;
|
||||
Dict *groups;
|
||||
StyleLinkGroup slg;
|
||||
LinkedListNode *node;
|
||||
@@ -1232,13 +1244,12 @@ int LCUI_FindStyleSheetFromGroup(int group, const char *name,
|
||||
iter = Dict_GetIterator(slg->links);
|
||||
while ((entry = Dict_Next(iter))) {
|
||||
StyleLink link = DictEntry_GetVal(entry);
|
||||
count += LCUI_FindStyleSheetFromLink(link, s,
|
||||
i, list);
|
||||
count += LCUI_FindStyleSheetFromLink(link, s, i, list);
|
||||
}
|
||||
Dict_ReleaseIterator(iter);
|
||||
}
|
||||
LinkedList_Clear(&names, free);
|
||||
return count;
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
void LCUI_PrintStyleSheet(LCUI_StyleSheet ss)
|
||||
@@ -1264,12 +1275,11 @@ void LCUI_PrintStyleSheet(LCUI_StyleSheet ss)
|
||||
case LCUI_STYPE_BOOL:
|
||||
LOG("%s", s->val_bool ? "true" : "false");
|
||||
break;
|
||||
case LCUI_STYPE_COLOR:
|
||||
{
|
||||
case LCUI_STYPE_COLOR: {
|
||||
LCUI_Color *clr = &s->val_color;
|
||||
if (clr->alpha < 255) {
|
||||
LOG("rgba(%d,%d,%d,%g)", clr->r,
|
||||
clr->g, clr->b, clr->a / 255.0);
|
||||
LOG("rgba(%d,%d,%d,%g)", clr->r, clr->g, clr->b,
|
||||
clr->a / 255.0);
|
||||
} else {
|
||||
LOG("#%02x%02x%02x", clr->r, clr->g, clr->b);
|
||||
}
|
||||
@@ -1317,8 +1327,8 @@ void LCUI_PrintSelector(LCUI_Selector selector)
|
||||
strcat(path, (*sn)->fullname);
|
||||
strcat(path, " ");
|
||||
}
|
||||
LOG("path: %s (rank = %d, batch_num = %d)\n", path,
|
||||
selector->rank, selector->batch_num);
|
||||
LOG("path: %s (rank = %d, batch_num = %d)\n", path, selector->rank,
|
||||
selector->batch_num);
|
||||
}
|
||||
|
||||
static void LCUI_PrintStyleLink(StyleLink link, const char *selector)
|
||||
@@ -1442,13 +1452,13 @@ static void StyleNameDestructor(void *privdata, void *val)
|
||||
|
||||
static unsigned int IntKeyDict_HashFunction(const void *key)
|
||||
{
|
||||
return Dict_IdentityHashFunction(*(unsigned int*)key);
|
||||
return Dict_IdentityHashFunction(*(unsigned int *)key);
|
||||
}
|
||||
|
||||
static int IntKeyDict_KeyCompare(void *privdata,
|
||||
const void *key1, const void *key2)
|
||||
static int IntKeyDict_KeyCompare(void *privdata, const void *key1,
|
||||
const void *key2)
|
||||
{
|
||||
return *(unsigned int*)key1 == *(unsigned int*)key2;
|
||||
return *(unsigned int *)key1 == *(unsigned int *)key2;
|
||||
}
|
||||
|
||||
static void IntKeyDict_KeyDestructor(void *privdata, void *key)
|
||||
@@ -1459,7 +1469,7 @@ static void IntKeyDict_KeyDestructor(void *privdata, void *key)
|
||||
static void *IntKeyDict_KeyDup(void *privdata, const void *key)
|
||||
{
|
||||
unsigned int *newkey = malloc(sizeof(unsigned int));
|
||||
*newkey = *(unsigned int*)key;
|
||||
*newkey = *(unsigned int *)key;
|
||||
return newkey;
|
||||
}
|
||||
|
||||
|
||||
@@ -940,7 +940,7 @@ static size_t LCUI_LoadCSSBlock(LCUI_CSSParserContext ctx, const char *str)
|
||||
|
||||
int LCUI_LoadCSSFile(const char *filepath)
|
||||
{
|
||||
int n;
|
||||
size_t n;
|
||||
FILE *fp;
|
||||
char buff[512];
|
||||
LCUI_CSSParserContext ctx;
|
||||
|
||||
@@ -391,10 +391,11 @@ static void TextEdit_UpdateTextLayer(LCUI_Widget w)
|
||||
|
||||
static void TextEdit_OnTask(LCUI_Widget widget)
|
||||
{
|
||||
size_t i, len;
|
||||
wchar_t text[256];
|
||||
LCUI_TextEdit edit = Widget_GetData(widget, self.prototype);
|
||||
|
||||
while (edit->tasks[TASK_UPDATE_MASK]) {
|
||||
int i, len;
|
||||
wchar_t text[256];
|
||||
edit->tasks[TASK_UPDATE] = TRUE;
|
||||
edit->tasks[TASK_UPDATE_MASK] = FALSE;
|
||||
TextLayer_ClearText(edit->layer_mask);
|
||||
@@ -511,7 +512,8 @@ void TextEdit_ClearText(LCUI_Widget widget)
|
||||
Widget_InvalidateArea(widget, NULL, SV_PADDING_BOX);
|
||||
}
|
||||
|
||||
int TextEdit_GetTextW(LCUI_Widget w, int start, int max_len, wchar_t *buf)
|
||||
size_t TextEdit_GetTextW(LCUI_Widget w, size_t start, size_t max_len,
|
||||
wchar_t *buf)
|
||||
{
|
||||
LCUI_TextEdit edit = GetData(w);
|
||||
return TextLayer_GetTextW(edit->layer_source, start, max_len, buf);
|
||||
@@ -660,10 +662,12 @@ static void TextEdit_OnKeyDown(LCUI_Widget widget,
|
||||
{
|
||||
int cols, rows, cur_col, cur_row;
|
||||
LCUI_TextEdit edit = Widget_GetData(widget, self.prototype);
|
||||
|
||||
cur_row = edit->layer->insert_y;
|
||||
cur_col = edit->layer->insert_x;
|
||||
rows = TextLayer_GetRowTotal(edit->layer);
|
||||
cols = TextLayer_GetRowTextLength(edit->layer, cur_row);
|
||||
e->cancel_bubble = TRUE;
|
||||
switch (e->key.code) {
|
||||
case LCUI_KEY_HOME: // home键移动光标至行首
|
||||
cur_col = 0;
|
||||
|
||||
@@ -255,7 +255,7 @@ int Widget_Top(LCUI_Widget w)
|
||||
|
||||
void Widget_SetTitleW(LCUI_Widget w, const wchar_t *title)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
wchar_t *new_title, *old_title;
|
||||
|
||||
len = wcslen(title) + 1;
|
||||
|
||||
@@ -129,8 +129,10 @@ int Widget_HandleChildrenStyleChange(LCUI_Widget w, int type, const char *name)
|
||||
LCUI_Selector s;
|
||||
LinkedList snames;
|
||||
LinkedListNode *node;
|
||||
int i, n, count = 0;
|
||||
char ch, **names = NULL;
|
||||
|
||||
size_t i, n, len;
|
||||
int count = 0;
|
||||
char ch, *str, **names = NULL;
|
||||
|
||||
/* 选择相应的前缀 */
|
||||
switch (type) {
|
||||
@@ -148,8 +150,8 @@ int Widget_HandleChildrenStyleChange(LCUI_Widget w, int type, const char *name)
|
||||
n = strsplit(name, " ", &names);
|
||||
/* 为分割出来的字符串加上前缀 */
|
||||
for (i = 0; i < n; ++i) {
|
||||
int len = strlen(names[i]) + 2;
|
||||
char *str = malloc(len * sizeof(char));
|
||||
len = strlen(names[i]) + 2;
|
||||
str = malloc(len * sizeof(char));
|
||||
strncpy(str + 1, names[i], len - 1);
|
||||
str[0] = ch;
|
||||
free(names[i]);
|
||||
|
||||
@@ -245,7 +245,7 @@ void Widget_DestroyChildren(LCUI_Widget w)
|
||||
|
||||
static void _LCUIWidget_PrintTree(LCUI_Widget w, int depth, const char *prefix)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
LCUI_Widget child;
|
||||
LinkedListNode *node;
|
||||
LCUI_SelectorNode snode;
|
||||
|
||||
+5
-3
@@ -126,10 +126,12 @@ int LCUI_ReadBMPHeader(LCUI_ImageReader reader)
|
||||
|
||||
int LCUI_ReadBMP(LCUI_ImageReader reader, LCUI_Graph *graph)
|
||||
{
|
||||
size_t n, row, bytes_per_row;
|
||||
long offset;
|
||||
unsigned char *buffer, *dest;
|
||||
size_t n, row, bytes_per_row;
|
||||
LCUI_BMPReader bmp_reader = reader->data;
|
||||
INFOHEADER *info = &bmp_reader->info;
|
||||
|
||||
if (reader->type != LCUI_BMP_READER) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -139,8 +141,8 @@ int LCUI_ReadBMP(LCUI_ImageReader reader, LCUI_Graph *graph)
|
||||
}
|
||||
}
|
||||
/* 信息头中的偏移位置是相对于起始处,需要减去当前已经偏移的位置 */
|
||||
n = bmp_reader->header.offset - bmp_reader->info.size - 14;
|
||||
reader->fn_skip(reader->stream_data, n);
|
||||
offset = bmp_reader->header.offset - bmp_reader->info.size - 14;
|
||||
reader->fn_skip(reader->stream_data, offset);
|
||||
if (0 != Graph_Create(graph, info->width, info->height)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
+1
-1
@@ -241,7 +241,7 @@ int LCUI_ReadJPEG(LCUI_ImageReader reader, LCUI_Graph *graph)
|
||||
JSAMPARRAY buffer;
|
||||
j_decompress_ptr cinfo;
|
||||
int k, row_stride;
|
||||
size_t x;
|
||||
unsigned x;
|
||||
|
||||
if (reader->type != LCUI_JPEG_READER) {
|
||||
return -EINVAL;
|
||||
|
||||
+2
-2
@@ -233,7 +233,7 @@ int LCUI_WritePNGFile(const char *file_name, const LCUI_Graph *graph)
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_bytep *row_pointers;
|
||||
int x, y, row_size;
|
||||
size_t x, y, row_size;
|
||||
|
||||
if (!Graph_IsValid(graph)) {
|
||||
_DEBUG_MSG("graph is not valid\n");
|
||||
@@ -322,7 +322,7 @@ int LCUI_WritePNGFile(const char *file_name, const LCUI_Graph *graph)
|
||||
}
|
||||
png_write_image(png_ptr, row_pointers);
|
||||
/* cleanup heap allocation */
|
||||
for (y = 0; y < rect.height; ++y) {
|
||||
for (y = 0; y < (size_t)rect.height; ++y) {
|
||||
free(row_pointers[y]);
|
||||
}
|
||||
free(row_pointers);
|
||||
|
||||
@@ -171,8 +171,8 @@ static void OnCreateSurface(void *arg1, void *arg2)
|
||||
instance = LCUI_GetAppData();
|
||||
/* 为 Surface 创建窗口 */
|
||||
surface->hwnd = CreateWindow(
|
||||
TEXT("LCUI"), TEXT("LCUI Surface"), WIN32_WINDOW_STYLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, instance, NULL);
|
||||
TEXT("LCUI"), TEXT("LCUI Surface"), WIN32_WINDOW_STYLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, instance, NULL);
|
||||
#ifdef ENABLE_TOUCH_SUPPORT
|
||||
RegisterTouchWindow(surface->hwnd, 0);
|
||||
#endif
|
||||
@@ -368,7 +368,8 @@ static void WinSurface_Present(LCUI_Surface surface)
|
||||
RECT client_rect;
|
||||
|
||||
DEBUG_MSG("surface: %p, hwnd: %p\n", surface, surface->hwnd);
|
||||
SetBitmapBits(surface->fb_bmp, surface->fb.mem_size, surface->fb.bytes);
|
||||
SetBitmapBits(surface->fb_bmp, (DWORD)surface->fb.mem_size,
|
||||
surface->fb.bytes);
|
||||
switch (surface->mode) {
|
||||
case RENDER_MODE_STRETCH_BLT:
|
||||
GetClientRect(surface->hwnd, &client_rect);
|
||||
@@ -486,9 +487,9 @@ static void OnWMGetMinMaxInfo(LCUI_Event e, void *arg)
|
||||
if (info->min_width == info->max_width &&
|
||||
info->min_height == info->max_height) {
|
||||
style &= ~(WS_SIZEBOX | WS_MAXIMIZEBOX);
|
||||
} else if (info->min_width == info->max_width ||
|
||||
} else if (info->min_width == info->max_width ||
|
||||
info->min_height == info->max_height) {
|
||||
style &= ~WS_MAXIMIZEBOX;
|
||||
style &= ~WS_MAXIMIZEBOX;
|
||||
}
|
||||
SetWindowLong(msg->hwnd, GWL_STYLE, style);
|
||||
}
|
||||
@@ -516,7 +517,7 @@ static void OnWMSize(LCUI_Event e, void *arg)
|
||||
}
|
||||
|
||||
static int WinDisplay_BindEvent(int event_id, LCUI_EventFunc func, void *data,
|
||||
void(*destroy_data)(void *))
|
||||
void (*destroy_data)(void *))
|
||||
{
|
||||
return EventTrigger_Bind(win.trigger, event_id, func, data,
|
||||
destroy_data);
|
||||
|
||||
+3
-83
@@ -218,12 +218,12 @@ void LinkedList_Concat(LinkedList *list1, LinkedList *list2)
|
||||
|
||||
|
||||
typedef struct SortRange_ {
|
||||
int start, end;
|
||||
size_t start, end;
|
||||
LinkedListNode *snode, *enode;
|
||||
} SortRange;
|
||||
|
||||
static SortRange NewSortRange(int s, LinkedListNode *snode,
|
||||
int e, LinkedListNode *enode)
|
||||
static SortRange NewSortRange(size_t s, LinkedListNode *snode,
|
||||
size_t e, LinkedListNode *enode)
|
||||
{
|
||||
SortRange r;
|
||||
r.end = e;
|
||||
@@ -276,83 +276,3 @@ void LinkedList_SwapNode(LinkedList *list, LinkedListNode *a, LinkedListNode *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LinkedList_QuickSort(LinkedList *list, int(*cmp)(void*, void*))
|
||||
{
|
||||
int p = 0;
|
||||
SortRange *r;
|
||||
if (list->length <= 0) {
|
||||
return;
|
||||
}
|
||||
r = malloc(list->length * sizeof(SortRange));
|
||||
r[p++] = NewSortRange(0, list->head.next,
|
||||
list->length - 1, list->tail.prev);
|
||||
while (p) {
|
||||
int left, right;
|
||||
SortRange range = r[--p];
|
||||
LinkedListNode *mnode, *lnode, *rnode, *node;
|
||||
if (range.start >= range.end) {
|
||||
continue;
|
||||
}
|
||||
mnode = range.enode;
|
||||
left = range.start, right = range.end - 1;
|
||||
lnode = range.snode, rnode = range.enode->prev;
|
||||
while (left < right) {
|
||||
while (left < right &&
|
||||
cmp(lnode->data, mnode->data) < 0) {
|
||||
left++, lnode = lnode->next;
|
||||
}
|
||||
while (left < right &&
|
||||
cmp(rnode->data, mnode->data) >= 0) {
|
||||
right--, rnode = rnode->prev;
|
||||
}
|
||||
LinkedList_SwapNode(list, lnode, rnode);
|
||||
if (lnode == range.snode) {
|
||||
range.snode = rnode;
|
||||
}
|
||||
node = lnode;
|
||||
lnode = rnode;
|
||||
rnode = node;
|
||||
}
|
||||
if (cmp(lnode->data, range.enode->data) >= 0) {
|
||||
LinkedList_SwapNode(list, lnode, range.enode);
|
||||
if (mnode == range.enode) {
|
||||
mnode = lnode;
|
||||
}
|
||||
node = lnode;
|
||||
lnode = range.enode;
|
||||
range.enode = node;
|
||||
} else {
|
||||
left++, lnode = lnode->next;
|
||||
}
|
||||
r[p++] = NewSortRange(range.start, range.snode,
|
||||
left - 1, lnode->prev);
|
||||
r[p++] = NewSortRange(left + 1, lnode->next,
|
||||
range.end, range.enode);
|
||||
}
|
||||
free(r);
|
||||
}
|
||||
|
||||
void LinkedList_BubbleSort(LinkedList *list, int(*cmp)(void*, void*))
|
||||
{
|
||||
size_t i, j;
|
||||
LinkedListNode *node, *cur, *next;
|
||||
for (i = 0; i < list->length - 1; ++i) {
|
||||
int no_swap = 1;
|
||||
cur = list->head.next;
|
||||
for (j = 0; j < list->length - 1 - i; ++j) {
|
||||
next = cur->next;
|
||||
if (cmp(cur->data, next->data) >= 0) {
|
||||
LinkedList_SwapNode(list, cur, next);
|
||||
node = cur;
|
||||
cur = next;
|
||||
next = node;
|
||||
no_swap = 0;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
if (no_swap) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -432,9 +432,9 @@ int strsdel(char ***strlist, const char *str)
|
||||
|
||||
int sortedstrsadd(char ***strlist, const char *str)
|
||||
{
|
||||
int i, pos;
|
||||
size_t len, n;
|
||||
int i, pos, n;
|
||||
char **newlist, *newstr;
|
||||
size_t len;
|
||||
|
||||
if (*strlist) {
|
||||
for (i = 0; (*strlist)[i]; ++i)
|
||||
|
||||
Reference in New Issue
Block a user