added function _updateContentSize()
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
|
||||
#include "o_drawable_p.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
@@ -23,6 +26,7 @@ static GWENHYWFAR_CB void _freeData(void *bp, void *p);
|
||||
static int _drawFallback(AQDG_OBJECT *object);
|
||||
static int _getDefaultWidth(AQDG_OBJECT *object);
|
||||
static int _getDefaultHeight(AQDG_OBJECT *object);
|
||||
static void _updateContentSize(AQDG_OBJECT *object);
|
||||
|
||||
|
||||
|
||||
@@ -110,6 +114,7 @@ void AQDG_DrawableObject_SetFontId(AQDG_OBJECT *object, int i)
|
||||
if (xo) {
|
||||
if (xo->fontId!=i) {
|
||||
xo->fontId=i;
|
||||
_updateContentSize(object);
|
||||
AQDG_Object_ModifyBranchFlagsUp(object,
|
||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW,
|
||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW);
|
||||
@@ -194,6 +199,8 @@ void AQDG_DrawableObject_SetText(AQDG_OBJECT *object, const char *s)
|
||||
if (xo) {
|
||||
free(xo->text);
|
||||
xo->text=s?strdup(s):NULL;
|
||||
|
||||
_updateContentSize(object);
|
||||
AQDG_Object_ModifyBranchFlagsUp(object,
|
||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW,
|
||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW);
|
||||
@@ -348,6 +355,35 @@ int _getDefaultHeight(AQDG_OBJECT *object)
|
||||
|
||||
|
||||
|
||||
void _updateContentSize(AQDG_OBJECT *object)
|
||||
{
|
||||
if (object) {
|
||||
AQDG_OBJECT_DRAWABLE *xo;
|
||||
|
||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||
if (xo) {
|
||||
xo->contentWidth=0;
|
||||
xo->contentHeight=0;
|
||||
if (xo->text) {
|
||||
int i;
|
||||
|
||||
i=AQDG_Draw_Context_GetTextWidth(xo->drawContext, xo->fontId, xo->text);
|
||||
if (i<0) {
|
||||
DBG_INFO(NULL, "here (%d)", i);
|
||||
}
|
||||
else
|
||||
xo->contentWidth=i;
|
||||
|
||||
i=AQDG_Draw_Context_GetTextHeight(xo->drawContext, xo->fontId, xo->text);
|
||||
if (i<0) {
|
||||
DBG_INFO(NULL, "here (%d)", i);
|
||||
}
|
||||
else
|
||||
xo->contentHeight=i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user