forked from pyrite-dev/milsko
refactor font api
This commit is contained in:
parent
9fc659b652
commit
0de09207a4
31 changed files with 12209 additions and 6149 deletions
|
|
@ -264,8 +264,8 @@ void vulkan_setup(MwWidget handle) {
|
||||||
swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh},
|
swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh},
|
||||||
swapchainCreateInfo.imageArrayLayers = 1,
|
swapchainCreateInfo.imageArrayLayers = 1,
|
||||||
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||||
VK_IMAGE_USAGE_SAMPLED_BIT;
|
VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
// th is how we specify no transformation.
|
// th is how we specify no transformation.
|
||||||
swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||||
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
|
|
|
||||||
|
|
@ -176,29 +176,31 @@ MWDECL void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int in
|
||||||
/*!
|
/*!
|
||||||
* @brief Draws a text
|
* @brief Draws a text
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
|
* @param ttf TTF, NULLable
|
||||||
* @param point Center point of the text
|
* @param point Center point of the text
|
||||||
* @param text Text
|
* @param text Text
|
||||||
* @param bold Bold
|
|
||||||
* @param align Align
|
* @param align Align
|
||||||
* @param color Color
|
* @param color Color
|
||||||
*/
|
*/
|
||||||
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
MWDECL void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates a text width
|
* @brief Calculates a text width
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
* @param text Text
|
* @param text Text
|
||||||
|
* @param font Font, NULLable
|
||||||
* @return Text width
|
* @return Text width
|
||||||
*/
|
*/
|
||||||
MWDECL int MwTextWidth(MwWidget handle, const char* text);
|
MWDECL int MwTextWidth(MwWidget handle, MwFLFont font, const char* text);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates a text height
|
* @brief Calculates a text height
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
* @param text Text
|
* @param text Text
|
||||||
|
* @param font Font, NULLable
|
||||||
* @return Text height
|
* @return Text height
|
||||||
*/
|
*/
|
||||||
MWDECL int MwTextHeight(MwWidget handle, const char* text);
|
MWDECL int MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
|
||||||
|
|
||||||
/* color.c */
|
/* color.c */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,10 @@ struct _MwLLTextDispatchTable {
|
||||||
void (*fontFree)(void* handle);
|
void (*fontFree)(void* handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MwFLFlagMonospace (1 << 0)
|
||||||
|
#define MwFLFlagBold (1 << 1)
|
||||||
|
#define MwFLBuildFont(x) ((MwFLFont)(void*)(size_t)(x))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -246,9 +250,9 @@ MWDECL int MWFL_FT2Setup(void);
|
||||||
MWDECL int MwFL_STBTTSetup(void);
|
MWDECL int MwFL_STBTTSetup(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MWDECL int (*MwFLDrawText)(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color);
|
||||||
MWDECL int (*MwFLTextWidth)(MwWidget handle, const char* text);
|
MWDECL int (*MwFLTextWidth)(MwFLFont ttf, const char* text);
|
||||||
MWDECL int (*MwFLTextHeight)(MwWidget handle, int count);
|
MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
|
||||||
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size);
|
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size);
|
||||||
MWDECL void (*MwFLFontFree)(void* handle);
|
MWDECL void (*MwFLFontFree)(void* handle);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,26 @@ MWDECL unsigned char MwBoldTTFData[];
|
||||||
*/
|
*/
|
||||||
MWDECL unsigned int MwBoldTTFDataSize;
|
MWDECL unsigned int MwBoldTTFDataSize;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default monospace TTF font data
|
||||||
|
*/
|
||||||
|
MWDECL unsigned char MwMonospaceTTFData[];
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default monospace TTF font size
|
||||||
|
*/
|
||||||
|
MWDECL unsigned int MwMonospaceTTFDataSize;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default bold monospace TTF font data
|
||||||
|
*/
|
||||||
|
MWDECL unsigned char MwBoldMonospaceTTFData[];
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default bold monospace TTF font size
|
||||||
|
*/
|
||||||
|
MWDECL unsigned int MwBoldMonospaceTTFDataSize;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
#define MwNroundness "Iroundness"
|
#define MwNroundness "Iroundness"
|
||||||
#define MwNisRounded "IisRounded"
|
#define MwNisRounded "IisRounded"
|
||||||
#define MwNdarkTheme "IdarkTheme"
|
#define MwNdarkTheme "IdarkTheme"
|
||||||
|
#define MwNuseMonospace "IuseMonospace"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|
@ -56,6 +57,8 @@
|
||||||
#define MwNfont "Vfont"
|
#define MwNfont "Vfont"
|
||||||
#define MwNboldFont "VboldFont"
|
#define MwNboldFont "VboldFont"
|
||||||
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
||||||
|
#define MwNmonospaceFont "VmonospaceFont"
|
||||||
|
#define MwNboldMonospaceFont "VboldMonospaceFont"
|
||||||
|
|
||||||
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
||||||
#define MwNresizeHandler "Cresize" /* NULL */
|
#define MwNresizeHandler "Cresize" /* NULL */
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ struct _MwWidget {
|
||||||
|
|
||||||
void* root_font;
|
void* root_font;
|
||||||
void* root_boldfont;
|
void* root_boldfont;
|
||||||
|
void* root_monofont;
|
||||||
|
void* root_boldmonofont;
|
||||||
|
|
||||||
int berserk;
|
int berserk;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,9 @@
|
||||||
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
||||||
<pointer name="font" />
|
<pointer name="font" />
|
||||||
<pointer name="boldFont" />
|
<pointer name="boldFont" />
|
||||||
|
<pixmap name="backgroundPixmap" />
|
||||||
|
<pointer name="monospaceFont" />
|
||||||
|
<pointer name="boldMonospaceFont" />
|
||||||
|
|
||||||
<handler name="activate" />
|
<handler name="activate" />
|
||||||
<handler name="resize" />
|
<handler name="resize" />
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
my @enabled_backends=();
|
my @enabled_backends = ();
|
||||||
|
|
||||||
if (param_get("wayland")) {
|
if (param_get("wayland")) {
|
||||||
push(@enabled_backends,"wayland");
|
push(@enabled_backends, "wayland");
|
||||||
}
|
}
|
||||||
if (param_get("x11")) {
|
if (param_get("x11")) {
|
||||||
push(@enabled_backends,"x11");
|
push(@enabled_backends, "x11");
|
||||||
}
|
}
|
||||||
|
|
||||||
use_backend(@enabled_backends);
|
use_backend(@enabled_backends);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ new_object("src/*.c");
|
||||||
my $gl_libs = "";
|
my $gl_libs = "";
|
||||||
if (param_get("tiny")) {
|
if (param_get("tiny")) {
|
||||||
add_cflags("-Oz");
|
add_cflags("-Oz");
|
||||||
if(defined($ENV{CC}) && grep(/^clang$/, $ENV{CC})) {
|
if (defined($ENV{CC}) && grep(/^clang$/, $ENV{CC})) {
|
||||||
add_libs("-flto=thin");
|
add_libs("-flto=thin");
|
||||||
add_cflags("-flto=thin");
|
add_cflags("-flto=thin");
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ if (grep(/^cocoa$/, @backends)) {
|
||||||
|
|
||||||
if (param_get("stb-image")) {
|
if (param_get("stb-image")) {
|
||||||
add_cflags("-DUSE_STB_IMAGE");
|
add_cflags("-DUSE_STB_IMAGE");
|
||||||
if(param_get("tiny")) {
|
if (param_get("tiny")) {
|
||||||
add_cflags("-DSTB_IMAGE_STATIC");
|
add_cflags("-DSTB_IMAGE_STATIC");
|
||||||
add_cflags("-DSTB_IMAGE_IMPLEMENTATION");
|
add_cflags("-DSTB_IMAGE_IMPLEMENTATION");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
resource/font/OpenSans-Bold.ttf
Normal file
BIN
resource/font/OpenSans-Bold.ttf
Normal file
Binary file not shown.
BIN
resource/font/OpenSans-Regular.ttf
Normal file
BIN
resource/font/OpenSans-Regular.ttf
Normal file
Binary file not shown.
|
|
@ -18,9 +18,9 @@ void* MwDirectoryOpen(const char* path) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char* p = malloc(strlen(path) + 2 + 1);
|
char* p = malloc(strlen(path) + 2 + 1);
|
||||||
strcpy(p, path);
|
strcpy(p, path);
|
||||||
if(strchr(path, '/') != NULL){
|
if(strchr(path, '/') != NULL) {
|
||||||
strcat(p, "/");
|
strcat(p, "/");
|
||||||
}else{
|
} else {
|
||||||
strcat(p, "\\");
|
strcat(p, "\\");
|
||||||
}
|
}
|
||||||
strcat(p, "*");
|
strcat(p, "*");
|
||||||
|
|
@ -78,7 +78,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
||||||
l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime;
|
l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime;
|
||||||
|
|
||||||
entry->mtime = l->QuadPart / 10000000 - 11644473600;
|
entry->mtime = l->QuadPart / 10000000 - 11644473600;
|
||||||
|
|
||||||
dir->next = FindNextFile(dir->hFind, &dir->ffd);
|
dir->next = FindNextFile(dir->hFind, &dir->ffd);
|
||||||
#else
|
#else
|
||||||
struct dirent* d;
|
struct dirent* d;
|
||||||
|
|
|
||||||
15
src/core.c
15
src/core.c
|
|
@ -216,8 +216,10 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
if(IsFirstVisible(h)) {
|
if(IsFirstVisible(h)) {
|
||||||
h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize);
|
h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize);
|
||||||
h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
||||||
|
h->root_monofont = MwFontLoad(MwMonospaceTTFData, MwMonospaceTTFDataSize);
|
||||||
|
h->root_boldmonofont = MwFontLoad(MwBoldMonospaceTTFData, MwBoldMonospaceTTFDataSize);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -530,6 +532,7 @@ int MwGetInteger(MwWidget handle, const char* key) {
|
||||||
#endif
|
#endif
|
||||||
if(strcmp(key, MwNisRounded) == 0) return inherit_integer(handle, key, 1);
|
if(strcmp(key, MwNisRounded) == 0) return inherit_integer(handle, key, 1);
|
||||||
if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0);
|
if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0);
|
||||||
|
if(strcmp(key, MwNuseMonospace) == 0) return inherit_integer(handle, key, 0);
|
||||||
}
|
}
|
||||||
return shget(handle->integer, key);
|
return shget(handle->integer, key);
|
||||||
}
|
}
|
||||||
|
|
@ -579,7 +582,7 @@ void* MwGetVoid(MwWidget handle, const char* key) {
|
||||||
if(v != NULL) return v;
|
if(v != NULL) return v;
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
if(strcmp(key, MwNfont) == 0 || strcmp(key, MwNboldFont) == 0) {
|
if(strcmp(key, MwNfont) == 0 || strcmp(key, MwNboldFont) == 0 || strcmp(key, MwNmonospaceFont) == 0 || strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||||
v = inherit_void(handle, key);
|
v = inherit_void(handle, key);
|
||||||
|
|
||||||
if(v == NULL) {
|
if(v == NULL) {
|
||||||
|
|
@ -588,8 +591,12 @@ void* MwGetVoid(MwWidget handle, const char* key) {
|
||||||
while(w != NULL && v == NULL) {
|
while(w != NULL && v == NULL) {
|
||||||
if(strcmp(key, MwNfont) == 0) {
|
if(strcmp(key, MwNfont) == 0) {
|
||||||
v = w->root_font;
|
v = w->root_font;
|
||||||
} else {
|
} else if(strcmp(key, MwNboldFont) == 0) {
|
||||||
v = w->root_boldfont;
|
v = w->root_boldfont;
|
||||||
|
} else if(strcmp(key, MwNmonospaceFont) == 0) {
|
||||||
|
v = w->root_monofont;
|
||||||
|
} else if(strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||||
|
v = w->root_boldmonofont;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = w->parent;
|
w = w->parent;
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
||||||
left = 8 + 48 + 8;
|
left = 8 + 48 + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
th = MwTextHeight(handle, text);
|
th = MwTextHeight(handle, NULL, text);
|
||||||
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
|
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
|
||||||
MwNtext, text,
|
MwNtext, text,
|
||||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) {
|
||||||
|
|
||||||
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) {
|
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) {
|
||||||
unsigned char bytes[sizeof(MwU32)];
|
unsigned char bytes[sizeof(MwU32)];
|
||||||
int i;
|
int i;
|
||||||
memcpy(bytes, &key, sizeof(MwU32));
|
memcpy(bytes, &key, sizeof(MwU32));
|
||||||
|
|
||||||
for(i = 0; i < sizeof(MwU32); i++) {
|
for(i = 0; i < sizeof(MwU32); i++) {
|
||||||
|
|
|
||||||
3022
src/text/font/boldmonottf.c
Normal file
3022
src/text/font/boldmonottf.c
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
3022
src/text/font/monottf.c
Normal file
3022
src/text/font/monottf.c
Normal file
File diff suppressed because it is too large
Load diff
5891
src/text/font/ttf.c
5891
src/text/font/ttf.c
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,9 @@
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
static struct {
|
#define HEIGHT 14
|
||||||
|
|
||||||
|
static struct ft_table {
|
||||||
FT_Error (*FT_Init_FreeType)(FT_Library* alibrary);
|
FT_Error (*FT_Init_FreeType)(FT_Library* alibrary);
|
||||||
FT_Error (*FT_New_Memory_Face)(FT_Library library,
|
FT_Error (*FT_New_Memory_Face)(FT_Library library,
|
||||||
const FT_Byte* file_base,
|
const FT_Byte* file_base,
|
||||||
|
|
@ -27,17 +29,15 @@ struct _MwFLFont {
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
void* data;
|
void* data;
|
||||||
};
|
};
|
||||||
static int ft2_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
|
||||||
int tw, th;
|
int tw, th;
|
||||||
unsigned char* px;
|
unsigned char* px;
|
||||||
MwLLPixmap p;
|
MwLLPixmap p;
|
||||||
MwRect r;
|
MwRect r;
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
if(ttf == NULL) return 1;
|
|
||||||
|
|
||||||
tw = MwTextWidth(handle, text);
|
tw = MwTextWidth(handle, ttf, text);
|
||||||
th = MwTextHeight(handle, text);
|
th = MwTextHeight(handle, ttf, text);
|
||||||
px = malloc(tw * th * 4);
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
memset(px, 0, tw * th * 4);
|
||||||
|
|
@ -51,7 +51,7 @@ static int ft2_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int
|
||||||
|
|
||||||
if(c == '\n') {
|
if(c == '\n') {
|
||||||
x = 0;
|
x = 0;
|
||||||
y += ttf->face->height * 14 / ttf->face->units_per_EM;
|
y += ttf->face->height * HEIGHT / ttf->face->units_per_EM;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ static int ft2_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int
|
||||||
for(cy = 0; cy < bmp->rows; cy++) {
|
for(cy = 0; cy < bmp->rows; cy++) {
|
||||||
for(cx = 0; cx < bmp->width; cx++) {
|
for(cx = 0; cx < bmp->width; cx++) {
|
||||||
int ox = x + cx + ttf->face->glyph->bitmap_left;
|
int ox = x + cx + ttf->face->glyph->bitmap_left;
|
||||||
int oy = y + (ttf->face->height * 14 / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * 14 / ttf->face->units_per_EM);
|
int oy = y + (ttf->face->height * HEIGHT / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * HEIGHT / ttf->face->units_per_EM);
|
||||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||||
|
|
||||||
opx[0] = color->common.red;
|
opx[0] = color->common.red;
|
||||||
|
|
@ -80,12 +80,6 @@ static int ft2_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int
|
||||||
r.width = tw;
|
r.width = tw;
|
||||||
r.height = th;
|
r.height = th;
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
MwLLDestroyPixmap(p);
|
MwLLDestroyPixmap(p);
|
||||||
free(px);
|
free(px);
|
||||||
|
|
@ -93,10 +87,8 @@ static int ft2_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ft2_MwTextWidth(MwWidget handle, const char* text) {
|
static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, MwNfont);
|
int tw = 0, mtw = 0;
|
||||||
int tw = 0, mtw = 0;
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
while(text[0] != 0) {
|
while(text[0] != 0) {
|
||||||
int c;
|
int c;
|
||||||
|
|
@ -117,11 +109,8 @@ static int ft2_MwTextWidth(MwWidget handle, const char* text) {
|
||||||
return mtw;
|
return mtw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ft2_MwTextHeight(MwWidget handle, int count) {
|
static int ft2_MwTextHeight(MwFLFont ttf, int count) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, MwNfont);
|
return (ttf->face->height * HEIGHT / ttf->face->units_per_EM) * count;
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
return (ttf->face->height * 14 / ttf->face->units_per_EM) * count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* ft2_MwFontLoad(unsigned char* data, unsigned int size) {
|
static void* ft2_MwFontLoad(unsigned char* data, unsigned int size) {
|
||||||
|
|
@ -131,7 +120,7 @@ static void* ft2_MwFontLoad(unsigned char* data, unsigned int size) {
|
||||||
ft_table.FT_Init_FreeType(&ttf->library);
|
ft_table.FT_Init_FreeType(&ttf->library);
|
||||||
ft_table.FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
ft_table.FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
||||||
|
|
||||||
ft_table.FT_Set_Pixel_Sizes(ttf->face, 0, 14);
|
ft_table.FT_Set_Pixel_Sizes(ttf->face, 0, HEIGHT);
|
||||||
|
|
||||||
return ttf;
|
return ttf;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,16 @@ struct _MwFLFont {
|
||||||
int descent;
|
int descent;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stbtt_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
static int stbtt_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
|
||||||
unsigned char* px;
|
unsigned char* px;
|
||||||
int tw, th;
|
int tw, th;
|
||||||
MwRect r;
|
MwRect r;
|
||||||
MwLLPixmap p;
|
MwLLPixmap p;
|
||||||
int ax, lsb;
|
int ax, lsb;
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
if(ttf == NULL) return 1;
|
|
||||||
|
|
||||||
tw = MwTextWidth(handle, text);
|
tw = MwTextWidth(handle, ttf, text);
|
||||||
th = MwTextHeight(handle, text);
|
th = MwTextHeight(handle, ttf, text);
|
||||||
px = malloc(tw * th * 4);
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
memset(px, 0, tw * th * 4);
|
||||||
|
|
@ -71,12 +69,6 @@ static int stbtt_MwDrawText(MwWidget handle, MwPoint* point, const char* text, i
|
||||||
r.width = tw;
|
r.width = tw;
|
||||||
r.height = th;
|
r.height = th;
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
MwLLDestroyPixmap(p);
|
MwLLDestroyPixmap(p);
|
||||||
free(px);
|
free(px);
|
||||||
|
|
@ -84,11 +76,9 @@ static int stbtt_MwDrawText(MwWidget handle, MwPoint* point, const char* text, i
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stbtt_MwTextWidth(MwWidget handle, const char* text) {
|
static int stbtt_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, MwNfont);
|
int ax, lsb;
|
||||||
int ax, lsb;
|
int tw = 0;
|
||||||
int tw = 0;
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
while(text[0] != 0) {
|
while(text[0] != 0) {
|
||||||
int c;
|
int c;
|
||||||
|
|
@ -102,10 +92,7 @@ static int stbtt_MwTextWidth(MwWidget handle, const char* text) {
|
||||||
return tw;
|
return tw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stbtt_MwTextHeight(MwWidget handle, int count) {
|
static int stbtt_MwTextHeight(MwFLFont ttf, int count) {
|
||||||
MwFLFont ttf = MwGetVoid(handle, MwNfont);
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
return (ttf->ascent - ttf->descent) * ttf->scale * count;
|
return (ttf->ascent - ttf->descent) * ttf->scale * count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
int (*MwFLDrawText)(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) = NULL;
|
int (*MwFLDrawText)(MwWidget handle, MwFLFont font, MwPoint* point, const char* text, MwLLColor color) = NULL;
|
||||||
int (*MwFLTextWidth)(MwWidget handle, const char* text) = NULL;
|
int (*MwFLTextWidth)(MwFLFont font, const char* text) = NULL;
|
||||||
int (*MwFLTextHeight)(MwWidget handle, int count) = NULL;
|
int (*MwFLTextHeight)(MwFLFont font, int count) = NULL;
|
||||||
void* (*MwFLFontLoad)(unsigned char* data, unsigned int size) = NULL;
|
void* (*MwFLFontLoad)(unsigned char* data, unsigned int size) = NULL;
|
||||||
void (*MwFLFontFree)(void* handle) = NULL;
|
void (*MwFLFontFree)(void* handle) = NULL;
|
||||||
|
|
||||||
#if defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE)
|
#if defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE)
|
||||||
#define TTF
|
#define TTF
|
||||||
|
|
@ -13,40 +13,91 @@ void (*MwFLFontFree)(void* handle) = NULL;
|
||||||
#define FontWidth 7
|
#define FontWidth 7
|
||||||
#define FontHeight 14
|
#define FontHeight 14
|
||||||
|
|
||||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color);
|
||||||
|
|
||||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
static int is_bold(MwWidget handle, MwFLFont ttf) {
|
||||||
if(strlen(text) == 0) return;
|
size_t u = (size_t)ttf;
|
||||||
#ifdef TTF
|
int s;
|
||||||
if(MwFLDrawText)
|
|
||||||
if(MwGetInteger(handle, MwNbitmapFont) || MwFLDrawText(handle, point, text, bold, align, color))
|
if(u & MwFLFlagBold) return 1;
|
||||||
#endif
|
|
||||||
bitmap_MwDrawText(handle, point, text, bold, align, color);
|
s = MwGetInteger(handle, MwNbold);
|
||||||
|
if(s == MwDEFAULT) return 0;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MwTextWidth(MwWidget handle, const char* text) {
|
static int is_monospace(MwWidget handle, MwFLFont ttf) {
|
||||||
|
size_t u = (size_t)ttf;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if(u & MwFLFlagMonospace) return 1;
|
||||||
|
|
||||||
|
s = MwGetInteger(handle, MwNuseMonospace);
|
||||||
|
if(s == MwDEFAULT) return 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
|
||||||
|
static MwFLFont assume_ttf(MwWidget handle, MwFLFont ttf) {
|
||||||
|
if(MwGetInteger(handle, MwNbitmapFont)) return NULL;
|
||||||
|
|
||||||
|
if(is_monospace(handle, ttf)) return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldMonospaceFont) : MwGetVoid(handle, MwNmonospaceFont);
|
||||||
|
return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldFont) : MwGetVoid(handle, MwNfont);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color) {
|
||||||
|
MwPoint p = *point;
|
||||||
|
|
||||||
|
if(strlen(text) == 0) return;
|
||||||
|
#ifdef TTF
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
|
p.x -= MwTextWidth(handle, ttf, text) / 2;
|
||||||
|
} else if(align == MwALIGNMENT_END) {
|
||||||
|
p.x -= MwTextWidth(handle, ttf, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
if(MwFLDrawText)
|
||||||
|
if(MwGetInteger(handle, MwNbitmapFont) || ttf == NULL || MwFLDrawText(handle, ttf, &p, text, color))
|
||||||
|
#endif
|
||||||
|
bitmap_MwDrawText(handle, &p, text, is_bold(handle, ttf), color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MwTextWidth(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||||
/* TODO: check newline */
|
/* TODO: check newline */
|
||||||
#ifdef TTF
|
#ifdef TTF
|
||||||
int st;
|
int st;
|
||||||
|
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
|
||||||
if(MwFLTextWidth)
|
if(MwFLTextWidth)
|
||||||
if(!MwGetInteger(handle, MwNbitmapFont) && (st = MwFLTextWidth(handle, text)) != -1) return st;
|
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextWidth(ttf, text)) != -1) return st;
|
||||||
#else
|
#else
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
(void)ttf;
|
||||||
#endif
|
#endif
|
||||||
return MwUTF8Length(text) * FontWidth;
|
return MwUTF8Length(text) * FontWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MwTextHeight(MwWidget handle, const char* text) {
|
int MwTextHeight(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||||
int c = 1;
|
int c = 1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#ifdef TTF
|
#ifdef TTF
|
||||||
int st;
|
int st;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
#else
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)text;
|
(void)text;
|
||||||
|
(void)ttf;
|
||||||
|
#endif
|
||||||
|
|
||||||
while(text[i] != 0) {
|
while(text[i] != 0) {
|
||||||
int out;
|
int out;
|
||||||
|
|
@ -58,7 +109,7 @@ int MwTextHeight(MwWidget handle, const char* text) {
|
||||||
}
|
}
|
||||||
#ifdef TTF
|
#ifdef TTF
|
||||||
if(MwFLTextHeight)
|
if(MwFLTextHeight)
|
||||||
if(!MwGetInteger(handle, MwNbitmapFont) && (st = MwFLTextHeight(handle, c)) != -1) return st;
|
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextHeight(ttf, c)) != -1) return st;
|
||||||
#endif
|
#endif
|
||||||
return FontHeight * c;
|
return FontHeight * c;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +124,7 @@ void MwFontFree(void* handle) {
|
||||||
if(MwFLFontFree) MwFLFontFree(handle);
|
if(MwFLFontFree) MwFLFontFree(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color) {
|
||||||
int i = 0, x, y, sx, sy;
|
int i = 0, x, y, sx, sy;
|
||||||
int tw, th;
|
int tw, th;
|
||||||
unsigned char* px;
|
unsigned char* px;
|
||||||
|
|
@ -81,8 +132,8 @@ static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text,
|
||||||
MwLLPixmap p;
|
MwLLPixmap p;
|
||||||
|
|
||||||
if(strlen(text) == 0) text = " ";
|
if(strlen(text) == 0) text = " ";
|
||||||
tw = MwTextWidth(handle, text);
|
tw = MwTextWidth(handle, NULL, text);
|
||||||
th = MwTextHeight(handle, text);
|
th = MwTextHeight(handle, NULL, text);
|
||||||
px = malloc(tw * th * 4);
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
memset(px, 0, tw * th * 4);
|
||||||
|
|
@ -128,12 +179,6 @@ static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text,
|
||||||
r.width = tw;
|
r.width = tw;
|
||||||
r.height = th;
|
r.height = th;
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
MwLLDestroyPixmap(p);
|
MwLLDestroyPixmap(p);
|
||||||
free(px);
|
free(px);
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ static void draw(MwWidget handle) {
|
||||||
point.x = r.x + r.width / 2;
|
point.x = r.x + r.width / 2;
|
||||||
point.y = r.x + r.height / 2;
|
point.y = r.x + r.height / 2;
|
||||||
|
|
||||||
MwDrawText(handle, &point, str, 0, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, NULL, &point, str, MwALIGNMENT_CENTER, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ static void draw(MwWidget handle) {
|
||||||
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
||||||
p.y = MwGetInteger(handle, MwNheight) / 2;
|
p.y = MwGetInteger(handle, MwNheight) / 2;
|
||||||
|
|
||||||
MwDrawText(handle, &p, cb->list[MwGetInteger(handle, MwNvalue)], 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, NULL, &p, cb->list[MwGetInteger(handle, MwNvalue)], MwALIGNMENT_BEGINNING, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rc;
|
r = rc;
|
||||||
|
|
@ -115,11 +115,11 @@ static void click(MwWidget handle) {
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
|
||||||
|
|
||||||
for(i = 0; i < arrlen(cb->list); i++) {
|
for(i = 0; i < arrlen(cb->list); i++) {
|
||||||
int l = MwTextWidth(handle, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
int l = MwTextWidth(handle, NULL, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
||||||
if(l > width) width = l;
|
if(l > width) width = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4,
|
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, NULL, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M") / 4,
|
||||||
MwNsingleClickSelectable, 1,
|
MwNsingleClickSelectable, 1,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
MwFLFont font = MwFLBuildFont(MwFLFlagMonospace);
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
|
|
@ -37,8 +38,8 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(str != NULL) {
|
if(str != NULL) {
|
||||||
int w = MwTextWidth(handle, "M");
|
int w = MwTextWidth(handle, font, "M");
|
||||||
int h = MwTextHeight(handle, "M");
|
int h = MwTextHeight(handle, font, "M");
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
char* show;
|
char* show;
|
||||||
int len;
|
int len;
|
||||||
|
|
@ -53,7 +54,7 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
len = (r.width - p.x * 2) / w;
|
len = (r.width - p.x * 2) / w;
|
||||||
|
|
||||||
if(len >= 0) {
|
if(len > 0) {
|
||||||
show = malloc(len * 4 + 1);
|
show = malloc(len * 4 + 1);
|
||||||
memset(show, 0, len * 4 + 1);
|
memset(show, 0, len * 4 + 1);
|
||||||
|
|
||||||
|
|
@ -65,13 +66,13 @@ static void draw(MwWidget handle) {
|
||||||
for(i = 0; i < MwUTF8Length(str) - start; i++) show[i] = '*';
|
for(i = 0; i < MwUTF8Length(str) - start; i++) show[i] = '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, font, &p, show, MwALIGNMENT_BEGINNING, text);
|
||||||
|
|
||||||
textlen = (t->cursor - 1) % len + 1;
|
textlen = (t->cursor - 1) % len + 1;
|
||||||
for(i = 0; i < textlen; i++) show[i] = 'M';
|
for(i = 0; i < textlen; i++) show[i] = 'M';
|
||||||
show[i] = 0;
|
show[i] = 0;
|
||||||
|
|
||||||
currc.x = p.x + MwTextWidth(handle, show);
|
currc.x = p.x + MwTextWidth(handle, font, show);
|
||||||
currc.y = (r.height - h) / 2;
|
currc.y = (r.height - h) / 2;
|
||||||
currc.width = 1;
|
currc.width = 1;
|
||||||
currc.height = h;
|
currc.height = h;
|
||||||
|
|
|
||||||
|
|
@ -316,9 +316,9 @@ static void draw(MwWidget handle) {
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
p.x = r.width / 2;
|
p.x = r.width / 2;
|
||||||
} else if(align == MwALIGNMENT_BEGINNING) {
|
} else if(align == MwALIGNMENT_BEGINNING) {
|
||||||
p.x = MwTextWidth(handle, str) / 2;
|
p.x = MwTextWidth(handle, NULL, str) / 2;
|
||||||
} else if(align == MwALIGNMENT_END) {
|
} else if(align == MwALIGNMENT_END) {
|
||||||
p.x = r.width - MwTextWidth(handle, str) / 2;
|
p.x = r.width - MwTextWidth(handle, NULL, str) / 2;
|
||||||
}
|
}
|
||||||
p.y = r.height / 2;
|
p.y = r.height / 2;
|
||||||
|
|
||||||
|
|
@ -326,11 +326,11 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
p.x += 1;
|
p.x += 1;
|
||||||
p.y += 1;
|
p.y += 1;
|
||||||
MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, shadow);
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, shadow);
|
||||||
|
|
||||||
p.x -= 1;
|
p.x -= 1;
|
||||||
p.y -= 1;
|
p.y -= 1;
|
||||||
MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLFreeColor(shadow);
|
MwLLFreeColor(shadow);
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, NULL, "M") + Padding) + 2; i++) {
|
||||||
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, NULL, "M") + Padding)) {
|
||||||
unsigned long t;
|
unsigned long t;
|
||||||
int old = MwGetInteger(handle->parent, MwNvalue);
|
int old = MwGetInteger(handle->parent, MwNvalue);
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
lb->click_time = t;
|
lb->click_time = t;
|
||||||
}
|
}
|
||||||
y += MwTextHeight(handle, "M") + Padding;
|
y += MwTextHeight(handle, NULL, "M") + Padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwForceRender(lb->frame);
|
MwForceRender(lb->frame);
|
||||||
|
|
@ -175,11 +175,11 @@ static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, NULL, "M") + Padding) + 2; i++) {
|
||||||
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
if(y <= p->y && p->y <= (y + MwTextHeight(handle, NULL, "M") + Padding)) {
|
||||||
MwSetInteger(handle->parent, MwNvalue, st + i);
|
MwSetInteger(handle->parent, MwNvalue, st + i);
|
||||||
}
|
}
|
||||||
y += MwTextHeight(handle, "M") + Padding;
|
y += MwTextHeight(handle, NULL, "M") + Padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwForceRender(lb->frame);
|
MwForceRender(lb->frame);
|
||||||
|
|
@ -216,7 +216,7 @@ static void frame_draw(MwWidget handle) {
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
|
|
||||||
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
||||||
ent = area / (MwTextHeight(handle, "M") + Padding) + 2;
|
ent = area / (MwTextHeight(handle, NULL, "M") + Padding) + 2;
|
||||||
|
|
||||||
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
||||||
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
||||||
|
|
@ -227,20 +227,20 @@ static void frame_draw(MwWidget handle) {
|
||||||
r2.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
r2.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
r2.y = p.y;
|
r2.y = p.y;
|
||||||
r2.width = r.width - r2.x;
|
r2.width = r.width - r2.x;
|
||||||
r2.height = MwTextHeight(handle, "M") + Padding;
|
r2.height = MwTextHeight(handle, NULL, "M") + Padding;
|
||||||
MwDrawRect(handle, &r2, text2);
|
MwDrawRect(handle, &r2, text2);
|
||||||
handle->bgcolor = text2;
|
handle->bgcolor = text2;
|
||||||
}
|
}
|
||||||
if(lb->list[i].pixmap != NULL) {
|
if(lb->list[i].pixmap != NULL) {
|
||||||
MwRect r2;
|
MwRect r2;
|
||||||
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, "M") + Padding)) ? (MwTextHeight(handle, "M") + Padding) : lb->list[i].pixmap->common.height;
|
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, NULL, "M") + Padding)) ? (MwTextHeight(handle, NULL, "M") + Padding) : lb->list[i].pixmap->common.height;
|
||||||
r2.x = MwDefaultBorderWidth(handle);
|
r2.x = MwDefaultBorderWidth(handle);
|
||||||
r2.y = p.y + (MwTextHeight(handle, "M") + Padding - h) / 2;
|
r2.y = p.y + (MwTextHeight(handle, NULL, "M") + Padding - h) / 2;
|
||||||
r2.width = h * lb->list[i].pixmap->common.width / lb->list[i].pixmap->common.height;
|
r2.width = h * lb->list[i].pixmap->common.width / lb->list[i].pixmap->common.height;
|
||||||
r2.height = h;
|
r2.height = h;
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
||||||
}
|
}
|
||||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
p.y += (MwTextHeight(handle, NULL, "M") + Padding) / 2;
|
||||||
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
for(j = 0; j < arrlen(lb->list[i].name); j++) {
|
for(j = 0; j < arrlen(lb->list[i].name); j++) {
|
||||||
char* t = lb->list[i].name[j];
|
char* t = lb->list[i].name[j];
|
||||||
|
|
@ -250,8 +250,8 @@ static void frame_draw(MwWidget handle) {
|
||||||
if(t == NULL) t = "";
|
if(t == NULL) t = "";
|
||||||
|
|
||||||
str = MwStringDuplicate(t);
|
str = MwStringDuplicate(t);
|
||||||
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, "M")) {
|
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, NULL, "M")) {
|
||||||
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, "M");
|
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, NULL, "M");
|
||||||
str[ind] = 0;
|
str[ind] = 0;
|
||||||
if(ind > 3) memset(str + ind - 3, '.', 3);
|
if(ind > 3) memset(str + ind - 3, '.', 3);
|
||||||
}
|
}
|
||||||
|
|
@ -259,26 +259,26 @@ static void frame_draw(MwWidget handle) {
|
||||||
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
||||||
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
||||||
p.x += 4;
|
p.x += 4;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
||||||
p.x -= 4;
|
p.x -= 4;
|
||||||
p.x += get_col_width(lb, j);
|
p.x += get_col_width(lb, j);
|
||||||
|
|
||||||
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
||||||
p.x += (get_col_width(lb, j) - l) / 2;
|
p.x += (get_col_width(lb, j) - l) / 2;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
||||||
p.x += (get_col_width(lb, j) - l) / 2;
|
p.x += (get_col_width(lb, j) - l) / 2;
|
||||||
p.x += l;
|
p.x += l;
|
||||||
} else if(lb->alignment[j] == MwALIGNMENT_END) {
|
} else if(lb->alignment[j] == MwALIGNMENT_END) {
|
||||||
p.x += get_col_width(lb, j);
|
p.x += get_col_width(lb, j);
|
||||||
p.x -= 4;
|
p.x -= 4;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_END, selected ? base2 : text2);
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_END, selected ? base2 : text2);
|
||||||
p.x += 4;
|
p.x += 4;
|
||||||
}
|
}
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
|
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
}
|
}
|
||||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
p.y += (MwTextHeight(handle, NULL, "M") + Padding) / 2;
|
||||||
handle->bgcolor = NULL;
|
handle->bgcolor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ static void resize(MwWidget handle) {
|
||||||
int ih, y;
|
int ih, y;
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
|
||||||
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, NULL, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
||||||
|
|
||||||
if(lb->vscroll == NULL) {
|
if(lb->vscroll == NULL) {
|
||||||
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
|
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
|
||||||
|
|
@ -316,7 +316,7 @@ static void resize(MwWidget handle) {
|
||||||
|
|
||||||
h -= y;
|
h -= y;
|
||||||
|
|
||||||
if(ih <= (h / (MwTextHeight(handle, "M") + Padding))) {
|
if(ih <= (h / (MwTextHeight(handle, NULL, "M") + Padding))) {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 0);
|
MwLLShow(lb->vscroll->lowlevel, 0);
|
||||||
} else {
|
} else {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 1);
|
MwLLShow(lb->vscroll->lowlevel, 1);
|
||||||
|
|
@ -340,7 +340,7 @@ static void resize(MwWidget handle) {
|
||||||
h -= MwDefaultBorderWidth(handle) * 2;
|
h -= MwDefaultBorderWidth(handle) * 2;
|
||||||
|
|
||||||
MwVaApply(lb->vscroll,
|
MwVaApply(lb->vscroll,
|
||||||
MwNareaShown, h / (MwTextHeight(handle, "M") + Padding),
|
MwNareaShown, h / (MwTextHeight(handle, NULL, "M") + Padding),
|
||||||
MwNmaxValue, ih,
|
MwNmaxValue, ih,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +400,7 @@ static void draw(MwWidget handle) {
|
||||||
r.x = x;
|
r.x = x;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = get_col_width(lb, i);
|
r.width = get_col_width(lb, i);
|
||||||
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M");
|
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M");
|
||||||
MwDrawFrame(handle, &r, base, 0, 0);
|
MwDrawFrame(handle, &r, base, 0, 0);
|
||||||
|
|
||||||
x += MwDefaultBorderWidth(handle);
|
x += MwDefaultBorderWidth(handle);
|
||||||
|
|
@ -408,15 +408,15 @@ static void draw(MwWidget handle) {
|
||||||
if(arrlen(lb->alignment) <= i || lb->alignment[i] == MwALIGNMENT_BEGINNING) {
|
if(arrlen(lb->alignment) <= i || lb->alignment[i] == MwALIGNMENT_BEGINNING) {
|
||||||
p.x = 4 + x;
|
p.x = 4 + x;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_BEGINNING, text);
|
||||||
} else if(lb->alignment[i] == MwALIGNMENT_CENTER) {
|
} else if(lb->alignment[i] == MwALIGNMENT_CENTER) {
|
||||||
p.x = x + r.width / 2;
|
p.x = x + r.width / 2;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_CENTER, text);
|
||||||
} else if(lb->alignment[i] == MwALIGNMENT_END) {
|
} else if(lb->alignment[i] == MwALIGNMENT_END) {
|
||||||
p.x = x + r.width - 4;
|
p.x = x + r.width - 4;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_END, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_END, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += r.width;
|
x += r.width;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ static void set_xywh(MwWidget handle) {
|
||||||
int diff = MwDefaultBorderWidth(handle);
|
int diff = MwDefaultBorderWidth(handle);
|
||||||
diff = 0;
|
diff = 0;
|
||||||
|
|
||||||
height = MwTextHeight(handle, "M") + 10;
|
height = MwTextHeight(handle, NULL, "M") + 10;
|
||||||
|
|
||||||
MwVaApply(handle,
|
MwVaApply(handle,
|
||||||
MwNx, -diff,
|
MwNx, -diff,
|
||||||
|
|
@ -71,8 +71,8 @@ static void destroy(MwWidget handle) {
|
||||||
#define BEGIN_MENU_LOOP \
|
#define BEGIN_MENU_LOOP \
|
||||||
for(i = 0; i < arrlen(m->sub); i++) { \
|
for(i = 0; i < arrlen(m->sub); i++) { \
|
||||||
int incr = m->sub[i]->name[0] == '?' ? 1 : 0; \
|
int incr = m->sub[i]->name[0] == '?' ? 1 : 0; \
|
||||||
int tw = MwTextWidth(handle, m->sub[i]->name + incr); \
|
int tw = MwTextWidth(handle, NULL, m->sub[i]->name + incr); \
|
||||||
int th = MwTextHeight(handle, m->sub[i]->name + incr); \
|
int th = MwTextHeight(handle, NULL, m->sub[i]->name + incr); \
|
||||||
int in_area; \
|
int in_area; \
|
||||||
\
|
\
|
||||||
if(incr) { \
|
if(incr) { \
|
||||||
|
|
@ -104,7 +104,7 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, &p, m->sub[i]->name + incr, m->sub[i]->wsub != NULL || (in_area && handle->pressed) ? 1 : 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, MwFLBuildFont((m->sub[i]->wsub != NULL || (in_area && handle->pressed)) ? MwFLFlagBold : 0), &p, m->sub[i]->name + incr, MwALIGNMENT_BEGINNING, text);
|
||||||
END_MENU_LOOP;
|
END_MENU_LOOP;
|
||||||
|
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
p.y += 2 + 1;
|
p.y += 2 + 1;
|
||||||
} else {
|
} else {
|
||||||
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
int tw = MwTextWidth(handle, NULL, menu->sub[i]->name);
|
||||||
int th = MwTextHeight(handle, menu->sub[i]->name);
|
int th = MwTextHeight(handle, NULL, menu->sub[i]->name);
|
||||||
|
|
||||||
if(menu->sub[i]->wsub != NULL) {
|
if(menu->sub[i]->wsub != NULL) {
|
||||||
r.x = MwGetInteger(handle, MwNleftPadding);
|
r.x = MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
@ -77,7 +77,7 @@ static void draw(MwWidget handle) {
|
||||||
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
||||||
p.y += th / 2;
|
p.y += th / 2;
|
||||||
MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, MwFLBuildFont(menu->sub[i]->wsub != NULL ? MwFLFlagBold : 0), &p, menu->sub[i]->name, MwALIGNMENT_CENTER, text);
|
||||||
|
|
||||||
if(arrlen(menu->sub[i]->sub) > 0) {
|
if(arrlen(menu->sub[i]->sub) > 0) {
|
||||||
MwRect tr;
|
MwRect tr;
|
||||||
|
|
@ -110,13 +110,13 @@ static void click(MwWidget handle) {
|
||||||
rc.x = 5;
|
rc.x = 5;
|
||||||
rc.y = 3;
|
rc.y = 3;
|
||||||
for(i = 0; i < arrlen(menu->sub); i++) {
|
for(i = 0; i < arrlen(menu->sub); i++) {
|
||||||
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
int tw = MwTextWidth(handle, NULL, menu->sub[i]->name);
|
||||||
if(tw > ww) ww = tw;
|
if(tw > ww) ww = tw;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.width = ww + 15;
|
rc.width = ww + 15;
|
||||||
for(i = 0; i < arrlen(menu->sub); i++) {
|
for(i = 0; i < arrlen(menu->sub); i++) {
|
||||||
int th = MwTextHeight(handle, menu->sub[i]->name);
|
int th = MwTextHeight(handle, NULL, menu->sub[i]->name);
|
||||||
rc.height = th;
|
rc.height = th;
|
||||||
|
|
||||||
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
||||||
|
|
@ -209,8 +209,8 @@ static void mwSubMenuGetSizeImpl(MwWidget handle, MwMenu menu, MwRect* rect) {
|
||||||
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
||||||
rect->height += 2 + 2;
|
rect->height += 2 + 2;
|
||||||
} else {
|
} else {
|
||||||
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
int tw = MwTextWidth(handle, NULL, menu->sub[i]->name);
|
||||||
rect->height += MwTextHeight(handle, menu->sub[i]->name) + 3;
|
rect->height += MwTextHeight(handle, NULL, menu->sub[i]->name) + 3;
|
||||||
if(tw > rect->width) {
|
if(tw > rect->width) {
|
||||||
rect->width = tw;
|
rect->width = tw;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
if((*skip) > 0) {
|
if((*skip) > 0) {
|
||||||
(*skip)--;
|
(*skip)--;
|
||||||
skipped = 1;
|
skipped = 1;
|
||||||
if(p->y == MwDefaultBorderWidth(handle)) p->y -= MwTextHeight(handle, "M");
|
if(p->y == MwDefaultBorderWidth(handle)) p->y -= MwTextHeight(handle, NULL, "M");
|
||||||
} else if((*shared) < (MwGetInteger(handle, MwNheight) / MwTextHeight(handle, "M") + 2)) {
|
} else if((*shared) < (MwGetInteger(handle, MwNheight) / MwTextHeight(handle, NULL, "M") + 2)) {
|
||||||
MwRect r;
|
MwRect r;
|
||||||
p->x += shift;
|
p->x += shift;
|
||||||
p->y += MwTextHeight(handle, "M") / 2 + LinePadding;
|
p->y += MwTextHeight(handle, NULL, "M") / 2 + LinePadding;
|
||||||
|
|
||||||
if(tree->tree != NULL || shift > LineSpace) {
|
if(tree->tree != NULL || shift > LineSpace) {
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
|
|
@ -47,9 +47,9 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
l[0].x -= LineSpace / 2;
|
l[0].x -= LineSpace / 2;
|
||||||
l[1] = l[0];
|
l[1] = l[0];
|
||||||
l[0].y -= MwTextHeight(handle, "M") / 2 + LinePadding;
|
l[0].y -= MwTextHeight(handle, NULL, "M") / 2 + LinePadding;
|
||||||
if(next) {
|
if(next) {
|
||||||
l[1].y += MwTextHeight(handle, "M") / 2;
|
l[1].y += MwTextHeight(handle, NULL, "M") / 2;
|
||||||
}
|
}
|
||||||
if(draw) MwLLLine(handle->lowlevel, &l[0], text2);
|
if(draw) MwLLLine(handle->lowlevel, &l[0], text2);
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
r.width = OpenerSize;
|
r.width = OpenerSize;
|
||||||
r.height = OpenerSize;
|
r.height = OpenerSize;
|
||||||
r.x = p->x - LineSpace + (LineSpace - r.width) / 2;
|
r.x = p->x - LineSpace + (LineSpace - r.width) / 2;
|
||||||
r.y = p->y - MwTextHeight(handle, "M") / 2 + (MwTextHeight(handle, "M") - r.height) / 2;
|
r.y = p->y - MwTextHeight(handle, NULL, "M") / 2 + (MwTextHeight(handle, NULL, "M") - r.height) / 2;
|
||||||
if(draw) {
|
if(draw) {
|
||||||
MwLLColor col = tree->opened ? MwLightenColor(handle, base, -8, -8, -8) : base;
|
MwLLColor col = tree->opened ? MwLightenColor(handle, base, -8, -8, -8) : base;
|
||||||
MwRect r2 = r;
|
MwRect r2 = r;
|
||||||
|
|
@ -101,11 +101,11 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(tree->pixmap != NULL) {
|
if(tree->pixmap != NULL) {
|
||||||
r.height = MwTextHeight(handle, "M");
|
r.height = MwTextHeight(handle, NULL, "M");
|
||||||
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
||||||
|
|
||||||
r.x = p->x;
|
r.x = p->x;
|
||||||
r.y = p->y - MwTextHeight(handle, "M") / 2;
|
r.y = p->y - MwTextHeight(handle, NULL, "M") / 2;
|
||||||
|
|
||||||
if(draw) MwLLDrawPixmap(handle->lowlevel, &r, tree->pixmap);
|
if(draw) MwLLDrawPixmap(handle->lowlevel, &r, tree->pixmap);
|
||||||
}
|
}
|
||||||
|
|
@ -113,16 +113,16 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
if(draw) {
|
if(draw) {
|
||||||
if(tree->selected) {
|
if(tree->selected) {
|
||||||
r.x = p->x;
|
r.x = p->x;
|
||||||
r.y = p->y - MwTextHeight(handle, "M") / 2;
|
r.y = p->y - MwTextHeight(handle, NULL, "M") / 2;
|
||||||
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift;
|
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift;
|
||||||
r.height = MwTextHeight(handle, "M");
|
r.height = MwTextHeight(handle, NULL, "M");
|
||||||
MwDrawRect(handle, &r, text2);
|
MwDrawRect(handle, &r, text2);
|
||||||
}
|
}
|
||||||
handle->bgcolor = tree->selected ? text2 : base2;
|
handle->bgcolor = tree->selected ? text2 : base2;
|
||||||
MwDrawText(handle, p, tree->label, 0, MwALIGNMENT_BEGINNING, tree->selected ? base2 : text2);
|
MwDrawText(handle, NULL, p, tree->label, MwALIGNMENT_BEGINNING, tree->selected ? base2 : text2);
|
||||||
handle->bgcolor = NULL;
|
handle->bgcolor = NULL;
|
||||||
} else {
|
} else {
|
||||||
if(p->x <= mouse->x && mouse->x <= (p->x + MwTextWidth(handle, tree->label)) && (p->y - MwTextHeight(handle, "M") / 2) <= mouse->y && mouse->y <= (p->y + MwTextHeight(handle, "M") / 2)) {
|
if(p->x <= mouse->x && mouse->x <= (p->x + MwTextWidth(handle, NULL, tree->label)) && (p->y - MwTextHeight(handle, NULL, "M") / 2) <= mouse->y && mouse->y <= (p->y + MwTextHeight(handle, NULL, "M") / 2)) {
|
||||||
unsigned long t;
|
unsigned long t;
|
||||||
|
|
||||||
set_all(root, 0);
|
set_all(root, 0);
|
||||||
|
|
@ -136,7 +136,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
}
|
}
|
||||||
p->x -= MwGetInteger(handle->parent, MwNleftPadding);
|
p->x -= MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
|
|
||||||
p->y += MwTextHeight(handle, "M") / 2;
|
p->y += MwTextHeight(handle, NULL, "M") / 2;
|
||||||
p->x -= shift;
|
p->x -= shift;
|
||||||
|
|
||||||
(*shared)++;
|
(*shared)++;
|
||||||
|
|
@ -145,7 +145,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
for(i = 0; i < arrlen(tree->tree); i++) {
|
for(i = 0; i < arrlen(tree->tree); i++) {
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
l[0].x += shift + LineSpace / 2;
|
l[0].x += shift + LineSpace / 2;
|
||||||
l[0].y += MwTextHeight(handle, "M") - (MwTextHeight(handle, "M") - OpenerSize) / 2;
|
l[0].y += MwTextHeight(handle, NULL, "M") - (MwTextHeight(handle, NULL, "M") - OpenerSize) / 2;
|
||||||
if(tree->tree[i]->tree != NULL) {
|
if(tree->tree[i]->tree != NULL) {
|
||||||
l[0].y += OpenerSize / 2;
|
l[0].y += OpenerSize / 2;
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ static void frame_draw(MwWidget handle) {
|
||||||
r = r2;
|
r = r2;
|
||||||
|
|
||||||
for(i = 0; i < arrlen(tv->tree); i++) {
|
for(i = 0; i < arrlen(tv->tree); i++) {
|
||||||
if(shared > (r.height / MwTextHeight(handle, "M"))) break;
|
if(shared > (r.height / MwTextHeight(handle, NULL, "M"))) break;
|
||||||
recursion(handle, tv->tree[i], tv->tree, base, text, base2, text2, &p, 0, LineSpace, &skip, &shared, 1, NULL);
|
recursion(handle, tv->tree[i], tv->tree, base, text, base2, text2, &p, 0, LineSpace, &skip, &shared, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
||||||
p.x = MwDefaultBorderWidth(tv->frame);
|
p.x = MwDefaultBorderWidth(tv->frame);
|
||||||
p.y = MwDefaultBorderWidth(tv->frame);
|
p.y = MwDefaultBorderWidth(tv->frame);
|
||||||
for(i = 0; i < arrlen(tv->tree); i++) {
|
for(i = 0; i < arrlen(tv->tree); i++) {
|
||||||
if(shared > (MwGetInteger(tv->frame, MwNheight) / MwTextHeight(tv->frame, "M"))) break;
|
if(shared > (MwGetInteger(tv->frame, MwNheight) / MwTextHeight(tv->frame, NULL, "M"))) break;
|
||||||
recursion(tv->frame, tv->tree[i], tv->tree, NULL, NULL, NULL, NULL, &p, 0, LineSpace, &skip, &shared, 0, &tv->pressed);
|
recursion(tv->frame, tv->tree[i], tv->tree, NULL, NULL, NULL, NULL, &p, 0, LineSpace, &skip, &shared, 0, &tv->pressed);
|
||||||
}
|
}
|
||||||
resize(handle->parent);
|
resize(handle->parent);
|
||||||
|
|
@ -267,7 +267,7 @@ static void resize(MwWidget handle) {
|
||||||
ih = recursive_length(tv->tree);
|
ih = recursive_length(tv->tree);
|
||||||
if(ih == 0) ih = 1;
|
if(ih == 0) ih = 1;
|
||||||
|
|
||||||
if(ih <= (h / (LinePadding + MwTextHeight(handle, "M")))) {
|
if(ih <= (h / (LinePadding + MwTextHeight(handle, NULL, "M")))) {
|
||||||
MwLLShow(tv->vscroll->lowlevel, 0);
|
MwLLShow(tv->vscroll->lowlevel, 0);
|
||||||
} else {
|
} else {
|
||||||
MwLLShow(tv->vscroll->lowlevel, 1);
|
MwLLShow(tv->vscroll->lowlevel, 1);
|
||||||
|
|
@ -292,7 +292,7 @@ static void resize(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwVaApply(tv->vscroll,
|
MwVaApply(tv->vscroll,
|
||||||
MwNareaShown, h / (LinePadding + MwTextHeight(handle, "M")),
|
MwNareaShown, h / (LinePadding + MwTextHeight(handle, NULL, "M")),
|
||||||
MwNmaxValue, ih,
|
MwNmaxValue, ih,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue