more work on widgets and objects.
This commit is contained in:
@@ -70,19 +70,27 @@
|
|||||||
|
|
||||||
<headers dist="true" install="$(pkgincludedir)">
|
<headers dist="true" install="$(pkgincludedir)">
|
||||||
context_cairo.h
|
context_cairo.h
|
||||||
o_drawable.h
|
w_drawable.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<headers dist="true" >
|
<headers dist="true" >
|
||||||
context_cairo_p.h
|
context_cairo_p.h
|
||||||
o_drawable_p.h
|
w_drawable_p.h
|
||||||
|
w_hlayout.h
|
||||||
|
w_vlayout.h
|
||||||
|
w_mlayout.h
|
||||||
|
w_label.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
|
|
||||||
<sources>
|
<sources>
|
||||||
$(local/typefiles)
|
$(local/typefiles)
|
||||||
context_cairo.c
|
context_cairo.c
|
||||||
o_drawable.c
|
w_drawable.c
|
||||||
|
w_hlayout.c
|
||||||
|
w_vlayout.c
|
||||||
|
w_mlayout.c
|
||||||
|
w_label.c
|
||||||
</sources>
|
</sources>
|
||||||
|
|
||||||
<extradist>
|
<extradist>
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* This file is part of the project AqDiagram.
|
|
||||||
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
|
||||||
*
|
|
||||||
* The license for this file can be found in the file COPYING which you
|
|
||||||
* should have received along with this file.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef AQDG_DRAW_O_DRAWABLE_H
|
|
||||||
#define AQDG_DRAW_O_DRAWABLE_H
|
|
||||||
|
|
||||||
#include <aqdiagram/aqdg_api.h>
|
|
||||||
|
|
||||||
#include <aqdiagram/placement/object.h>
|
|
||||||
#include <aqdiagram/draw/context.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef int (*AQDG_OBJECT_DRAWABLE_DRAW_FN)(AQDG_OBJECT *object);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_API AQDG_OBJECT *AQDG_DrawableObject_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext);
|
|
||||||
|
|
||||||
AQDG_API AQDG_DRAW_CONTEXT *AQDG_DrawableObject_GetDrawContext(const AQDG_OBJECT *object);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_GetFontId(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetFontId(AQDG_OBJECT *object, int i);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_GetForegroundPenId(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetForegroundPenId(AQDG_OBJECT *object, int i);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_GetBackgroundPenId(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetBackgroundPenId(AQDG_OBJECT *object, int i);
|
|
||||||
|
|
||||||
AQDG_API const char *AQDG_DrawableObject_GetText(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetText(AQDG_OBJECT *object, const char *s);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_GetContentWidth(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetContentWidth(AQDG_OBJECT *object, int i);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_GetContentHeight(const AQDG_OBJECT *object);
|
|
||||||
AQDG_API void AQDG_DrawableObject_SetContentHeight(AQDG_OBJECT *object, int i);
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_API AQDG_OBJECT_DRAWABLE_DRAW_FN AQDG_DrawableObject_SetDrawFn(AQDG_OBJECT *object, AQDG_OBJECT_DRAWABLE_DRAW_FN fn);
|
|
||||||
|
|
||||||
AQDG_API int AQDG_DrawableObject_Draw(AQDG_OBJECT *object);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "o_drawable_p.h"
|
#include "w_drawable_p.h"
|
||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
@@ -24,9 +24,6 @@
|
|||||||
static GWENHYWFAR_CB void _freeData(void *bp, void *p);
|
static GWENHYWFAR_CB void _freeData(void *bp, void *p);
|
||||||
|
|
||||||
static int _drawFallback(AQDG_OBJECT *object);
|
static int _drawFallback(AQDG_OBJECT *object);
|
||||||
static int _getDefaultWidth(AQDG_OBJECT *object);
|
|
||||||
static int _getDefaultHeight(AQDG_OBJECT *object);
|
|
||||||
static void _updateContentSize(AQDG_OBJECT *object);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -39,31 +36,39 @@ GWEN_INHERIT(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_OBJECT *AQDG_DrawableObject_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext)
|
AQDG_OBJECT *AQDG_DrawableWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
{
|
{
|
||||||
AQDG_OBJECT *object;
|
AQDG_OBJECT *object;
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
object=AQDG_Object_new();
|
object=AQDG_Object_new();
|
||||||
|
if (parent)
|
||||||
|
AQDG_Object_Tree2_AddChild(parent, object);
|
||||||
|
|
||||||
|
AQDG_DrawableWidget_Extend(object, drawContext);
|
||||||
|
AQDG_Object_SetOptions(object, options);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQDG_DrawableWidget_Extend(AQDG_OBJECT *object, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
AQDG_OBJECT *parent;
|
||||||
|
|
||||||
GWEN_NEW_OBJECT(AQDG_OBJECT_DRAWABLE, xo);
|
GWEN_NEW_OBJECT(AQDG_OBJECT_DRAWABLE, xo);
|
||||||
GWEN_INHERIT_SETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object, xo, _freeData);
|
GWEN_INHERIT_SETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object, xo, _freeData);
|
||||||
|
|
||||||
AQDG_Object_SetOptions(object, options);
|
|
||||||
xo->drawContext=drawContext;
|
xo->drawContext=drawContext;
|
||||||
xo->drawFn=_drawFallback;
|
xo->drawFn=_drawFallback;
|
||||||
|
|
||||||
AQDG_Object_SetGetDefaultWidthFn(object, _getDefaultWidth);
|
parent=AQDG_Object_Tree2_GetParent(object);
|
||||||
AQDG_Object_SetGetDefaultHeightFn(object, _getDefaultHeight);
|
|
||||||
|
|
||||||
if (parent && GWEN_INHERIT_ISOFTYPE(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, parent)) {
|
if (parent && GWEN_INHERIT_ISOFTYPE(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, parent)) {
|
||||||
xo->fontId=AQDG_DrawableObject_GetFontId(parent);
|
xo->fontId=AQDG_DrawableWidget_GetFontId(parent);
|
||||||
xo->foregroundPenId=AQDG_DrawableObject_GetForegroundPenId(parent);
|
xo->foregroundPenId=AQDG_DrawableWidget_GetForegroundPenId(parent);
|
||||||
xo->backgroundPenId=AQDG_DrawableObject_GetBackgroundPenId(parent);
|
xo->backgroundPenId=AQDG_DrawableWidget_GetBackgroundPenId(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent)
|
|
||||||
AQDG_Object_Tree2_AddChild(parent, object);
|
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,7 +84,7 @@ GWENHYWFAR_CB void _freeData(void *bp, void *p)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_DRAW_CONTEXT *AQDG_DrawableObject_GetDrawContext(const AQDG_OBJECT *object)
|
AQDG_DRAW_CONTEXT *AQDG_DrawableWidget_GetDrawContext(const AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -92,7 +97,7 @@ AQDG_DRAW_CONTEXT *AQDG_DrawableObject_GetDrawContext(const AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_GetFontId(const AQDG_OBJECT *object)
|
int AQDG_DrawableWidget_GetFontId(const AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -105,7 +110,7 @@ int AQDG_DrawableObject_GetFontId(const AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetFontId(AQDG_OBJECT *object, int i)
|
void AQDG_DrawableWidget_SetFontId(AQDG_OBJECT *object, int i)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -114,10 +119,8 @@ void AQDG_DrawableObject_SetFontId(AQDG_OBJECT *object, int i)
|
|||||||
if (xo) {
|
if (xo) {
|
||||||
if (xo->fontId!=i) {
|
if (xo->fontId!=i) {
|
||||||
xo->fontId=i;
|
xo->fontId=i;
|
||||||
_updateContentSize(object);
|
AQDG_Object_AddFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
||||||
AQDG_Object_ModifyBranchFlagsUp(object,
|
AQDG_Object_ModifyBranchFlagsUp(object, AQDG_OBJECT_FLAGS_RECALC, AQDG_OBJECT_FLAGS_RECALC);
|
||||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW,
|
|
||||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +128,7 @@ void AQDG_DrawableObject_SetFontId(AQDG_OBJECT *object, int i)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_GetForegroundPenId(const AQDG_OBJECT *object)
|
int AQDG_DrawableWidget_GetForegroundPenId(const AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -138,20 +141,24 @@ int AQDG_DrawableObject_GetForegroundPenId(const AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetForegroundPenId(AQDG_OBJECT *object, int i)
|
void AQDG_DrawableWidget_SetForegroundPenId(AQDG_OBJECT *object, int i)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
if (xo)
|
if (xo) {
|
||||||
xo->foregroundPenId=i;
|
if (xo->foregroundPenId!=i) {
|
||||||
|
xo->foregroundPenId=i;
|
||||||
|
AQDG_Object_AddFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_GetBackgroundPenId(const AQDG_OBJECT *object)
|
int AQDG_DrawableWidget_GetBackgroundPenId(const AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -164,20 +171,24 @@ int AQDG_DrawableObject_GetBackgroundPenId(const AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetBackgroundPenId(AQDG_OBJECT *object, int i)
|
void AQDG_DrawableWidget_SetBackgroundPenId(AQDG_OBJECT *object, int i)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
if (xo)
|
if (xo) {
|
||||||
xo->backgroundPenId=i;
|
if (xo->backgroundPenId!=i) {
|
||||||
|
xo->backgroundPenId=i;
|
||||||
|
AQDG_Object_AddFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char *AQDG_DrawableObject_GetText(const AQDG_OBJECT *object)
|
const char *AQDG_DrawableWidget_GetText(const AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -190,7 +201,7 @@ const char *AQDG_DrawableObject_GetText(const AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetText(AQDG_OBJECT *object, const char *s)
|
void AQDG_DrawableWidget_SetText(AQDG_OBJECT *object, const char *s)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -200,81 +211,22 @@ void AQDG_DrawableObject_SetText(AQDG_OBJECT *object, const char *s)
|
|||||||
free(xo->text);
|
free(xo->text);
|
||||||
xo->text=s?strdup(s):NULL;
|
xo->text=s?strdup(s):NULL;
|
||||||
|
|
||||||
_updateContentSize(object);
|
AQDG_Object_AddFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
||||||
AQDG_Object_ModifyBranchFlagsUp(object,
|
AQDG_Object_ModifyBranchFlagsUp(object, AQDG_OBJECT_FLAGS_RECALC, AQDG_OBJECT_FLAGS_RECALC);
|
||||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW,
|
|
||||||
AQDG_OBJECT_FLAGS_LAYOUT | AQDG_OBJECT_FLAGS_DRAW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_GetContentWidth(const AQDG_OBJECT *object)
|
AQDG_WIDGET_DRAWABLE_DRAW_FN AQDG_DrawableWidget_SetDrawFn(AQDG_OBJECT *object, AQDG_WIDGET_DRAWABLE_DRAW_FN fn)
|
||||||
{
|
|
||||||
if (object) {
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
return xo?xo->contentWidth:0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetContentWidth(AQDG_OBJECT *object, int i)
|
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
xo->contentWidth=i;
|
AQDG_WIDGET_DRAWABLE_DRAW_FN oldFn;
|
||||||
AQDG_Object_ModifyBranchFlagsUp(object, AQDG_OBJECT_FLAGS_LAYOUT, AQDG_OBJECT_FLAGS_LAYOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_GetContentHeight(const AQDG_OBJECT *object)
|
|
||||||
{
|
|
||||||
if (object) {
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
return xo?xo->contentHeight:0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQDG_DrawableObject_SetContentHeight(AQDG_OBJECT *object, int i)
|
|
||||||
{
|
|
||||||
if (object) {
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
if (xo) {
|
|
||||||
xo->contentHeight=i;
|
|
||||||
AQDG_Object_ModifyBranchFlagsUp(object, AQDG_OBJECT_FLAGS_LAYOUT, AQDG_OBJECT_FLAGS_LAYOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_OBJECT_DRAWABLE_DRAW_FN AQDG_DrawableObject_SetDrawFn(AQDG_OBJECT *object, AQDG_OBJECT_DRAWABLE_DRAW_FN fn)
|
|
||||||
{
|
|
||||||
if (object) {
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
if (xo) {
|
|
||||||
AQDG_OBJECT_DRAWABLE_DRAW_FN oldFn;
|
|
||||||
|
|
||||||
oldFn=xo->drawFn;
|
oldFn=xo->drawFn;
|
||||||
xo->drawFn=fn;
|
xo->drawFn=fn;
|
||||||
@@ -287,7 +239,7 @@ AQDG_OBJECT_DRAWABLE_DRAW_FN AQDG_DrawableObject_SetDrawFn(AQDG_OBJECT *object,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQDG_DrawableObject_Draw(AQDG_OBJECT *object)
|
int AQDG_DrawableWidget_Draw(AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
@@ -302,25 +254,75 @@ int AQDG_DrawableObject_Draw(AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQDG_DrawableWidget_DrawBackground(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
|
if (xo) {
|
||||||
|
AQDG_Draw_Context_DrawFilledRect(xo->drawContext,
|
||||||
|
xo->backgroundPenId,
|
||||||
|
AQDG_Object_GetAbsoluteX(object),
|
||||||
|
AQDG_Object_GetAbsoluteY(object),
|
||||||
|
AQDG_Object_GetWidth(object),
|
||||||
|
AQDG_Object_GetHeight(object));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQDG_DrawableWidget_DrawText(AQDG_OBJECT *object, int x, int y, const char *text)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
|
if (xo) {
|
||||||
|
x+=AQDG_Object_GetAbsoluteX(object);
|
||||||
|
y+=AQDG_Object_GetAbsoluteY(object);
|
||||||
|
AQDG_Draw_Context_DrawText(xo->drawContext, xo->foregroundPenId, xo->fontId, AQDG_Direction_Horizontal, x, y, text?text:"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQDG_DrawableWidget_DrawChildren(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
|
if (xo) {
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
if (child) {
|
||||||
|
while (child) {
|
||||||
|
AQDG_DrawableWidget_Draw(child);
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _drawFallback(AQDG_OBJECT *object)
|
int _drawFallback(AQDG_OBJECT *object)
|
||||||
{
|
{
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
AQDG_OBJECT *child;
|
AQDG_DrawableWidget_DrawBackground(object);
|
||||||
|
AQDG_DrawableWidget_DrawChildren(object);
|
||||||
AQDG_Draw_Context_DrawFilledRect(xo->drawContext,
|
|
||||||
xo->backgroundPenId,
|
|
||||||
AQDG_Object_GetAbsoluteX(object),
|
|
||||||
AQDG_Object_GetAbsoluteY(object),
|
|
||||||
AQDG_Object_GetWidth(object),
|
|
||||||
AQDG_Object_GetHeight(object));
|
|
||||||
child=AQDG_Object_Tree2_GetFirstChild(object);
|
|
||||||
while(child) {
|
|
||||||
AQDG_DrawableObject_Draw(child);
|
|
||||||
child=AQDG_Object_Tree2_GetNext(child);
|
|
||||||
}
|
|
||||||
AQDG_Object_SubFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
AQDG_Object_SubFlags(object, AQDG_OBJECT_FLAGS_DRAW);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -329,57 +331,24 @@ int _drawFallback(AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _getDefaultWidth(AQDG_OBJECT *object)
|
void AQDG_DrawableWidget_UpdateTextContentDims(AQDG_OBJECT *object)
|
||||||
{
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
if (xo) {
|
|
||||||
return xo->contentWidth;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _getDefaultHeight(AQDG_OBJECT *object)
|
|
||||||
{
|
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
|
||||||
if (xo) {
|
|
||||||
return xo->contentHeight;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _updateContentSize(AQDG_OBJECT *object)
|
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
AQDG_OBJECT_DRAWABLE *xo;
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
xo->contentWidth=0;
|
|
||||||
xo->contentHeight=0;
|
|
||||||
if (xo->text) {
|
if (xo->text) {
|
||||||
int i;
|
int w;
|
||||||
|
int h;
|
||||||
|
|
||||||
i=AQDG_Draw_Context_GetTextWidth(xo->drawContext, xo->fontId, xo->text);
|
w=AQDG_DrawableWidget_GetTextWidth(object);
|
||||||
if (i<0) {
|
w+=AQDG_Object_GetBorderLeft(object)+AQDG_Object_GetBorderRight(object);
|
||||||
DBG_INFO(NULL, "here (%d)", i);
|
h=AQDG_DrawableWidget_GetTextHeight(object);
|
||||||
}
|
h+=AQDG_Object_GetBorderTop(object)+AQDG_Object_GetBorderBottom(object);
|
||||||
else
|
|
||||||
xo->contentWidth=i;
|
|
||||||
|
|
||||||
i=AQDG_Draw_Context_GetTextHeight(xo->drawContext, xo->fontId, xo->text);
|
AQDG_Object_SetContentWidth(object, w);
|
||||||
if (i<0) {
|
AQDG_Object_SetContentHeight(object, h);
|
||||||
DBG_INFO(NULL, "here (%d)", i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
xo->contentHeight=i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,6 +356,54 @@ void _updateContentSize(AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQDG_DrawableWidget_GetTextWidth(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
|
if (xo) {
|
||||||
|
if (xo->text) {
|
||||||
|
int w;
|
||||||
|
|
||||||
|
w=AQDG_Draw_Context_GetTextWidth(xo->drawContext, xo->fontId, xo->text);
|
||||||
|
if (w<0) {
|
||||||
|
DBG_INFO(NULL, "here (%d)", w);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQDG_DrawableWidget_GetTextHeight(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
AQDG_OBJECT_DRAWABLE *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_DRAWABLE, object);
|
||||||
|
if (xo) {
|
||||||
|
if (xo->text) {
|
||||||
|
int h;
|
||||||
|
|
||||||
|
h=AQDG_Draw_Context_GetTextHeight(xo->drawContext, xo->fontId, xo->text);
|
||||||
|
if (h<0) {
|
||||||
|
DBG_INFO(NULL, "here (%d)", h);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
75
src/lib/aqdiagram/draw/w_drawable.h
Normal file
75
src/lib/aqdiagram/draw/w_drawable.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_DRAW_W_DRAWABLE_H
|
||||||
|
#define AQDG_DRAW_W_DRAWABLE_H
|
||||||
|
|
||||||
|
#include <aqdiagram/aqdg_api.h>
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/draw/context.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef int (*AQDG_WIDGET_DRAWABLE_DRAW_FN)(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
#define AQDG_DRAWABLE_OPTIONS_JUSTIFY_RIGHT 0x00000001
|
||||||
|
#define AQDG_DRAWABLE_OPTIONS_JUSTIFY_HCENTER 0x00000002
|
||||||
|
#define AQDG_DRAWABLE_OPTIONS_JUSTIFY_BOTTOM 0x00000004
|
||||||
|
#define AQDG_DRAWABLE_OPTIONS_JUSTIFY_VCENTER 0x00000008
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets virtual functions:
|
||||||
|
* - AQDG_OBJECT_DRAWABLE_DRAW_FN (just fill background and lets children draw their content)
|
||||||
|
*/
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_DrawableWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only sets draw function, does not overwrite getDefaultWidth/Height or layout functions.
|
||||||
|
*/
|
||||||
|
AQDG_API void AQDG_DrawableWidget_Extend(AQDG_OBJECT *object, AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
AQDG_API AQDG_DRAW_CONTEXT *AQDG_DrawableWidget_GetDrawContext(const AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetFontId(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetFontId(AQDG_OBJECT *object, int i);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetForegroundPenId(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetForegroundPenId(AQDG_OBJECT *object, int i);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetBackgroundPenId(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetBackgroundPenId(AQDG_OBJECT *object, int i);
|
||||||
|
|
||||||
|
AQDG_API const char *AQDG_DrawableWidget_GetText(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetText(AQDG_OBJECT *object, const char *s);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetContentWidth(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetContentWidth(AQDG_OBJECT *object, int i);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetContentHeight(const AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_SetContentHeight(AQDG_OBJECT *object, int i);
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_WIDGET_DRAWABLE_DRAW_FN AQDG_DrawableWidget_SetDrawFn(AQDG_OBJECT *object, AQDG_WIDGET_DRAWABLE_DRAW_FN fn);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_Draw(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_DrawBackground(AQDG_OBJECT *object);
|
||||||
|
AQDG_API int AQDG_DrawableWidget_DrawChildren(AQDG_OBJECT *object);
|
||||||
|
AQDG_API void AQDG_DrawableWidget_DrawText(AQDG_OBJECT *object, int x, int y, const char *text);
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API void AQDG_DrawableWidget_UpdateTextContentDims(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetTextWidth(AQDG_OBJECT *object);
|
||||||
|
AQDG_API int AQDG_DrawableWidget_GetTextHeight(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -6,10 +6,10 @@
|
|||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef AQDG_DRAW_O_DRAWABLE_P_H
|
#ifndef AQDG_DRAW_W_DRAWABLE_P_H
|
||||||
#define AQDG_DRAW_O_DRAWABLE_P_H
|
#define AQDG_DRAW_W_DRAWABLE_P_H
|
||||||
|
|
||||||
#include <aqdiagram/draw/o_drawable.h>
|
#include <aqdiagram/draw/w_drawable.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct AQDG_OBJECT_DRAWABLE AQDG_OBJECT_DRAWABLE;
|
typedef struct AQDG_OBJECT_DRAWABLE AQDG_OBJECT_DRAWABLE;
|
||||||
@@ -20,10 +20,8 @@ struct AQDG_OBJECT_DRAWABLE {
|
|||||||
int backgroundPenId;
|
int backgroundPenId;
|
||||||
|
|
||||||
char *text;
|
char *text;
|
||||||
int contentWidth;
|
|
||||||
int contentHeight;
|
|
||||||
|
|
||||||
AQDG_OBJECT_DRAWABLE_DRAW_FN drawFn;
|
AQDG_WIDGET_DRAWABLE_DRAW_FN drawFn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
33
src/lib/aqdiagram/draw/w_hlayout.c
Normal file
33
src/lib/aqdiagram/draw/w_hlayout.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./w_vlayout.h"
|
||||||
|
|
||||||
|
#include "./w_drawable.h"
|
||||||
|
#include "aqdiagram/placement/o_hlayout.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_OBJECT *AQDG_HLayoutWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *object;
|
||||||
|
|
||||||
|
object=AQDG_HLayoutObject_new(parent, options);
|
||||||
|
AQDG_DrawableWidget_Extend(object, drawContext);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
23
src/lib/aqdiagram/draw/w_hlayout.h
Normal file
23
src/lib/aqdiagram/draw/w_hlayout.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_DRAW_W_HLAYOUT_H
|
||||||
|
#define AQDG_DRAW_W_HLAYOUT_H
|
||||||
|
|
||||||
|
#include <aqdiagram/aqdg_api.h>
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/draw/context.h>
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_HLayoutWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
148
src/lib/aqdiagram/draw/w_label.c
Normal file
148
src/lib/aqdiagram/draw/w_label.c
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./w_label.h"
|
||||||
|
|
||||||
|
#include "./w_drawable.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* forward declarations
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int _draw(AQDG_OBJECT *object);
|
||||||
|
static int _calcXPos(AQDG_OBJECT *object, uint32_t opts, int tw);
|
||||||
|
static int _calcYPos(AQDG_OBJECT *object, uint32_t opts, int th);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* implementations
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_OBJECT *AQDG_LabelWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *object;
|
||||||
|
|
||||||
|
object=AQDG_DrawableWidget_new(parent, options, drawContext);
|
||||||
|
AQDG_Object_SetOptions(object, options);
|
||||||
|
AQDG_DrawableWidget_SetDrawFn(object, _draw);
|
||||||
|
if (parent)
|
||||||
|
AQDG_Object_Tree2_AddChild(parent, object);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _draw(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
if (object) {
|
||||||
|
uint32_t opts;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int tw;
|
||||||
|
int th;
|
||||||
|
|
||||||
|
AQDG_DrawableWidget_DrawBackground(object);
|
||||||
|
opts=AQDG_Object_GetOptions(object);
|
||||||
|
tw=AQDG_DrawableWidget_GetTextWidth(object);
|
||||||
|
th=AQDG_DrawableWidget_GetTextHeight(object);
|
||||||
|
|
||||||
|
x=_calcXPos(object, opts, tw);
|
||||||
|
y=_calcYPos(object, opts, th);
|
||||||
|
AQDG_DrawableWidget_DrawText(object, x, y, AQDG_DrawableWidget_GetText(object));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcXPos(AQDG_OBJECT *object, uint32_t opts, int tw)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
w=AQDG_Object_GetWidth(object)-AQDG_Object_GetBorderLeft(object)-AQDG_Object_GetBorderRight(object);
|
||||||
|
if (w<0) {
|
||||||
|
DBG_ERROR(NULL, "Width smaller than borders (%d)", w);
|
||||||
|
return AQDG_Object_GetBorderLeft(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts & AQDG_DRAWABLE_OPTIONS_JUSTIFY_RIGHT) {
|
||||||
|
/* right */
|
||||||
|
x=(w-tw)+AQDG_Object_GetBorderLeft(object);
|
||||||
|
}
|
||||||
|
else if (opts & AQDG_DRAWABLE_OPTIONS_JUSTIFY_HCENTER) {
|
||||||
|
/* hcenter */
|
||||||
|
x=((w-tw)/2)+AQDG_Object_GetBorderLeft(object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* left */
|
||||||
|
x=AQDG_Object_GetBorderLeft(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x<AQDG_Object_GetBorderLeft(object)) {
|
||||||
|
DBG_INFO(NULL, "x lower than left border pos");
|
||||||
|
x=AQDG_Object_GetBorderLeft(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcYPos(AQDG_OBJECT *object, uint32_t opts, int th)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
int h;
|
||||||
|
|
||||||
|
h=AQDG_Object_GetHeight(object)-AQDG_Object_GetBorderTop(object)-AQDG_Object_GetBorderBottom(object);
|
||||||
|
if (h<0) {
|
||||||
|
DBG_ERROR(NULL, "Height smaller than borders (%d)", h);
|
||||||
|
return AQDG_Object_GetBorderTop(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts & AQDG_DRAWABLE_OPTIONS_JUSTIFY_BOTTOM) {
|
||||||
|
/* bottom */
|
||||||
|
y=(h-th)+AQDG_Object_GetBorderTop(object);
|
||||||
|
}
|
||||||
|
else if (opts & AQDG_DRAWABLE_OPTIONS_JUSTIFY_VCENTER) {
|
||||||
|
/* vcenter */
|
||||||
|
y=((h-th)/2)+AQDG_Object_GetBorderTop(object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* top */
|
||||||
|
y=AQDG_Object_GetBorderTop(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y<AQDG_Object_GetBorderTop(object)) {
|
||||||
|
DBG_INFO(NULL, "y lower than top border pos");
|
||||||
|
y=AQDG_Object_GetBorderTop(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
23
src/lib/aqdiagram/draw/w_label.h
Normal file
23
src/lib/aqdiagram/draw/w_label.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_DRAW_W_LABEL_H
|
||||||
|
#define AQDG_DRAW_W_LABEL_H
|
||||||
|
|
||||||
|
#include <aqdiagram/aqdg_api.h>
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/draw/context.h>
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_LabelWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
46
src/lib/aqdiagram/draw/w_mlayout.c
Normal file
46
src/lib/aqdiagram/draw/w_mlayout.c
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./w_mlayout.h"
|
||||||
|
|
||||||
|
#include "./w_drawable.h"
|
||||||
|
#include "aqdiagram/placement/o_mlayout.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_OBJECT *AQDG_MatrixLayoutWidgetByRows_new(AQDG_OBJECT *parent, uint32_t options, int columns, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *object;
|
||||||
|
|
||||||
|
object=AQDG_MatrixLayoutObjectByRows_new(parent, options, columns);
|
||||||
|
AQDG_DrawableWidget_Extend(object, drawContext);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_OBJECT *AQDG_MatrixLayoutWidgetByColumns_new(AQDG_OBJECT *parent, uint32_t options, int rows, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *object;
|
||||||
|
|
||||||
|
object=AQDG_MatrixLayoutObjectByColumns_new(parent, options, rows);
|
||||||
|
AQDG_DrawableWidget_Extend(object, drawContext);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
27
src/lib/aqdiagram/draw/w_mlayout.h
Normal file
27
src/lib/aqdiagram/draw/w_mlayout.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_DRAW_W_MLAYOUT_H
|
||||||
|
#define AQDG_DRAW_W_MLAYOUT_H
|
||||||
|
|
||||||
|
#include <aqdiagram/aqdg_api.h>
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/draw/context.h>
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_MatrixLayoutWidgetByRows_new(AQDG_OBJECT *parent, uint32_t options, int columns,
|
||||||
|
AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_MatrixLayoutWidgetByColumns_new(AQDG_OBJECT *parent, uint32_t options, int rows,
|
||||||
|
AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
33
src/lib/aqdiagram/draw/w_vlayout.c
Normal file
33
src/lib/aqdiagram/draw/w_vlayout.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./w_vlayout.h"
|
||||||
|
|
||||||
|
#include "./w_drawable.h"
|
||||||
|
#include "aqdiagram/placement/o_vlayout.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_OBJECT *AQDG_VLayoutWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *object;
|
||||||
|
|
||||||
|
object=AQDG_VLayoutObject_new(parent, options);
|
||||||
|
AQDG_DrawableWidget_Extend(object, drawContext);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
23
src/lib/aqdiagram/draw/w_vlayout.h
Normal file
23
src/lib/aqdiagram/draw/w_vlayout.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2024 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_DRAW_W_VLAYOUT_H
|
||||||
|
#define AQDG_DRAW_W_VLAYOUT_H
|
||||||
|
|
||||||
|
#include <aqdiagram/aqdg_api.h>
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/draw/context.h>
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_OBJECT *AQDG_VLayoutWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_DRAW_CONTEXT *drawContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -31,8 +31,6 @@
|
|||||||
static int GWENHYWFAR_CB test1(GWEN_TEST_MODULE *mod);
|
static int GWENHYWFAR_CB test1(GWEN_TEST_MODULE *mod);
|
||||||
|
|
||||||
static AQDG_OBJECT *_createBox10x10(uint32_t opts);
|
static AQDG_OBJECT *_createBox10x10(uint32_t opts);
|
||||||
static int _boxGetDefaultWidth10(AQDG_OBJECT *object);
|
|
||||||
static int _boxGetDefaultHeight10(AQDG_OBJECT *object);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -166,29 +164,13 @@ AQDG_OBJECT *_createBox10x10(uint32_t opts)
|
|||||||
|
|
||||||
box=AQDG_Object_new();
|
box=AQDG_Object_new();
|
||||||
AQDG_Object_SetOptions(box, opts);
|
AQDG_Object_SetOptions(box, opts);
|
||||||
AQDG_Object_SetGetDefaultWidthFn(box, _boxGetDefaultWidth10);
|
AQDG_Object_SetContentWidth(box, 10);
|
||||||
AQDG_Object_SetGetDefaultHeightFn(box, _boxGetDefaultHeight10);
|
AQDG_Object_SetContentHeight(box, 10);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _boxGetDefaultWidth10(AQDG_OBJECT *object)
|
|
||||||
{
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _boxGetDefaultHeight10(AQDG_OBJECT *object)
|
|
||||||
{
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int AQDG_HLayoutObject_AddTests(GWEN_TEST_MODULE *mod)
|
int AQDG_HLayoutObject_AddTests(GWEN_TEST_MODULE *mod)
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int _layout(AQDG_OBJECT *object);
|
static int _layout(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentDims(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentWidth(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentHeight(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,6 +39,7 @@ AQDG_OBJECT *AQDG_HLayoutObject_new(AQDG_OBJECT *parent, uint32_t options)
|
|||||||
AQDG_Object_SetOptions(object, options);
|
AQDG_Object_SetOptions(object, options);
|
||||||
|
|
||||||
AQDG_Object_SetLayoutFn(object, _layout);
|
AQDG_Object_SetLayoutFn(object, _layout);
|
||||||
|
AQDG_Object_SetCalcContentDimsFn(object, _calcContentDims);
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
AQDG_Object_Tree2_AddChild(parent, object);
|
AQDG_Object_Tree2_AddChild(parent, object);
|
||||||
@@ -82,3 +86,55 @@ int _layout(AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentDims(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_Object_SetContentWidth(object, _calcContentWidth(object));
|
||||||
|
AQDG_Object_SetContentHeight(object, _calcContentHeight(object));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentWidth(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int v;
|
||||||
|
int spacing;
|
||||||
|
|
||||||
|
v=AQDG_Object_GetBorderLeft(object);
|
||||||
|
spacing=AQDG_Object_GetHSpacing(object);
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
v+=AQDG_Object_GetDefaultWidth(child);
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
if (child)
|
||||||
|
v+=spacing;
|
||||||
|
}
|
||||||
|
v+=AQDG_Object_GetBorderRight(object);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentHeight(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v=AQDG_Object_GetBorderTop(object);
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i=AQDG_Object_GetDefaultHeight(child);
|
||||||
|
v=(i>v)?i:v;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
}
|
||||||
|
v+=AQDG_Object_GetBorderBottom(object);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ static void _setChildrenFromElementsY(AQDG_OBJECT *object, const AQDG_PLACEMENT_
|
|||||||
static void _setObjectFromElementX(AQDG_OBJECT *object, const AQDG_PLACEMENT_LAYOUT_ELEMENT *eptr);
|
static void _setObjectFromElementX(AQDG_OBJECT *object, const AQDG_PLACEMENT_LAYOUT_ELEMENT *eptr);
|
||||||
static void _setObjectFromElementY(AQDG_OBJECT *object, const AQDG_PLACEMENT_LAYOUT_ELEMENT *eptr);
|
static void _setObjectFromElementY(AQDG_OBJECT *object, const AQDG_PLACEMENT_LAYOUT_ELEMENT *eptr);
|
||||||
|
|
||||||
|
static int _calcDimsByRows(AQDG_OBJECT *object);
|
||||||
|
static int _calcDimsByColumns(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
static int _calcWidthByRows(const AQDG_OBJECT *object, int columns);
|
||||||
|
static int _calcHeightByRows(const AQDG_OBJECT *object, int columns);
|
||||||
|
|
||||||
|
static int _calcWidthByColumns(const AQDG_OBJECT *object, int rows);
|
||||||
|
static int _calcHeightByColumns(const AQDG_OBJECT *object, int rows);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@@ -56,6 +65,7 @@ AQDG_OBJECT *AQDG_MatrixLayoutObjectByRows_new(AQDG_OBJECT *parent, uint32_t opt
|
|||||||
|
|
||||||
object=_matrixLayoutObject_new(parent, options, columns);
|
object=_matrixLayoutObject_new(parent, options, columns);
|
||||||
AQDG_Object_SetLayoutFn(object, _layoutByRows);
|
AQDG_Object_SetLayoutFn(object, _layoutByRows);
|
||||||
|
AQDG_Object_SetCalcContentDimsFn(object, _calcDimsByRows);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +77,7 @@ AQDG_OBJECT *AQDG_MatrixLayoutObjectByColumns_new(AQDG_OBJECT *parent, uint32_t
|
|||||||
|
|
||||||
object=_matrixLayoutObject_new(parent, options, rows);
|
object=_matrixLayoutObject_new(parent, options, rows);
|
||||||
AQDG_Object_SetLayoutFn(object, _layoutByColumns);
|
AQDG_Object_SetLayoutFn(object, _layoutByColumns);
|
||||||
|
AQDG_Object_SetCalcContentDimsFn(object, _calcDimsByColumns);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,3 +356,177 @@ void _setObjectFromElementY(AQDG_OBJECT *object, const AQDG_PLACEMENT_LAYOUT_ELE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcDimsByRows(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT_MLAYOUT *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_MLAYOUT, object);
|
||||||
|
if (xo) {
|
||||||
|
AQDG_Object_SetContentWidth(object, _calcWidthByRows(object, xo->numRowsOrColumns));
|
||||||
|
AQDG_Object_SetContentHeight(object, _calcHeightByRows(object, xo->numRowsOrColumns));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcDimsByColumns(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT_MLAYOUT *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQDG_OBJECT, AQDG_OBJECT_MLAYOUT, object);
|
||||||
|
if (xo) {
|
||||||
|
AQDG_Object_SetContentWidth(object, _calcWidthByColumns(object, xo->numRowsOrColumns));
|
||||||
|
AQDG_Object_SetContentHeight(object, _calcHeightByColumns(object, xo->numRowsOrColumns));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcWidthByRows(const AQDG_OBJECT *object, int columns)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int i=0;
|
||||||
|
int cw=0;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
w=AQDG_Object_GetBorderLeft(object);
|
||||||
|
i=0;
|
||||||
|
cw=0;
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child && i<columns) {
|
||||||
|
AQDG_OBJECT *n;
|
||||||
|
|
||||||
|
/* get highest width of column */
|
||||||
|
n=child;
|
||||||
|
while(n) {
|
||||||
|
int k;
|
||||||
|
int j=0;
|
||||||
|
|
||||||
|
k=AQDG_Object_GetDefaultWidth(n);
|
||||||
|
cw=(k>cw)?k:cw;
|
||||||
|
while(n && j<columns) { /* skip columns */
|
||||||
|
j++;
|
||||||
|
n=AQDG_Object_Tree2_GetNext(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w+=cw;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
if (child)
|
||||||
|
w+=AQDG_Object_GetHSpacing(object);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
w+=AQDG_Object_GetBorderRight(object);
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcHeightByRows(const AQDG_OBJECT *object, int columns)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int i=0;
|
||||||
|
int ch=0;
|
||||||
|
int h;
|
||||||
|
|
||||||
|
h=AQDG_Object_GetBorderTop(object);
|
||||||
|
i=0;
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
int k;
|
||||||
|
|
||||||
|
k=AQDG_Object_GetDefaultHeight(child);
|
||||||
|
ch=(k>ch)?k:ch;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
i++;
|
||||||
|
if (i>=columns) {
|
||||||
|
h+=ch;
|
||||||
|
i=0;
|
||||||
|
ch=0;
|
||||||
|
if (child)
|
||||||
|
h+=AQDG_Object_GetVSpacing(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h+=AQDG_Object_GetBorderBottom(object);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcWidthByColumns(const AQDG_OBJECT *object, int rows)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int i=0;
|
||||||
|
int cw=0;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
w=AQDG_Object_GetBorderLeft(object);
|
||||||
|
i=0;
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
int k;
|
||||||
|
|
||||||
|
k=AQDG_Object_GetDefaultWidth(child);
|
||||||
|
cw=(k>cw)?k:cw;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
i++;
|
||||||
|
if (i>=rows) {
|
||||||
|
w+=cw;
|
||||||
|
i=0;
|
||||||
|
cw=0;
|
||||||
|
if (child)
|
||||||
|
w+=AQDG_Object_GetHSpacing(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w+=AQDG_Object_GetBorderRight(object);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcHeightByColumns(const AQDG_OBJECT *object, int rows)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int i=0;
|
||||||
|
int ch=0;
|
||||||
|
int h;
|
||||||
|
|
||||||
|
h=AQDG_Object_GetBorderTop(object);
|
||||||
|
i=0;
|
||||||
|
ch=0;
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child && i<rows) {
|
||||||
|
AQDG_OBJECT *n;
|
||||||
|
|
||||||
|
/* get highest height of row */
|
||||||
|
n=child;
|
||||||
|
while(n) {
|
||||||
|
int k;
|
||||||
|
int j=0;
|
||||||
|
|
||||||
|
k=AQDG_Object_GetDefaultHeight(n);
|
||||||
|
ch=(k>ch)?k:ch;
|
||||||
|
while(n && j<rows) { /* skip rows */
|
||||||
|
j++;
|
||||||
|
n=AQDG_Object_Tree2_GetNext(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h+=ch;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
if (child)
|
||||||
|
h+=AQDG_Object_GetVSpacing(object);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
h+=AQDG_Object_GetBorderBottom(object);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int _layout(AQDG_OBJECT *object);
|
static int _layout(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentDims(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentWidth(AQDG_OBJECT *object);
|
||||||
|
static int _calcContentHeight(AQDG_OBJECT *object);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,6 +39,7 @@ AQDG_OBJECT *AQDG_VLayoutObject_new(AQDG_OBJECT *parent, uint32_t options)
|
|||||||
AQDG_Object_SetOptions(object, options);
|
AQDG_Object_SetOptions(object, options);
|
||||||
|
|
||||||
AQDG_Object_SetLayoutFn(object, _layout);
|
AQDG_Object_SetLayoutFn(object, _layout);
|
||||||
|
AQDG_Object_SetCalcContentDimsFn(object, _calcContentDims);
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
AQDG_Object_Tree2_AddChild(parent, object);
|
AQDG_Object_Tree2_AddChild(parent, object);
|
||||||
@@ -82,3 +86,55 @@ int _layout(AQDG_OBJECT *object)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentDims(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_Object_SetContentWidth(object, _calcContentWidth(object));
|
||||||
|
AQDG_Object_SetContentHeight(object, _calcContentHeight(object));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentWidth(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v=AQDG_Object_GetBorderLeft(object);
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i=AQDG_Object_GetDefaultWidth(child);
|
||||||
|
v=(i>v)?i:v;
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
}
|
||||||
|
v+=AQDG_Object_GetBorderRight(object);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _calcContentHeight(AQDG_OBJECT *object)
|
||||||
|
{
|
||||||
|
AQDG_OBJECT *child;
|
||||||
|
int v;
|
||||||
|
int spacing;
|
||||||
|
|
||||||
|
v=AQDG_Object_GetBorderTop(object);
|
||||||
|
spacing=AQDG_Object_GetVSpacing(object);
|
||||||
|
child=AQDG_Object_Tree2_GetFirstChild(object);
|
||||||
|
while(child) {
|
||||||
|
v+=AQDG_Object_GetDefaultHeight(child);
|
||||||
|
child=AQDG_Object_Tree2_GetNext(child);
|
||||||
|
if (child)
|
||||||
|
v+=spacing;
|
||||||
|
}
|
||||||
|
v+=AQDG_Object_GetBorderBottom(object);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,52 @@
|
|||||||
} \n
|
} \n
|
||||||
</content>
|
</content>
|
||||||
</inline>
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) int $(struct_prefix)_GetDefaultWidth($(struct_type) *object);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
int $(struct_prefix)_GetDefaultWidth($(struct_type) *object) \n
|
||||||
|
{ \n
|
||||||
|
if (object) { \n
|
||||||
|
if (object->flags & AQDG_OBJECT_FLAGS_RECALC) { \n
|
||||||
|
$(struct_prefix)_CalcContentDims(object); \n
|
||||||
|
object->flags &=~AQDG_OBJECT_FLAGS_RECALC; \n
|
||||||
|
} \n
|
||||||
|
return object->contentWidth; \n
|
||||||
|
} \n
|
||||||
|
return 1; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) int $(struct_prefix)_GetDefaultHeight($(struct_type) *object);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
int $(struct_prefix)_GetDefaultHeight($(struct_type) *object)\n
|
||||||
|
{ \n
|
||||||
|
if (object) { \n
|
||||||
|
if (object->flags & AQDG_OBJECT_FLAGS_RECALC) { \n
|
||||||
|
$(struct_prefix)_CalcContentDims(object); \n
|
||||||
|
object->flags &=~AQDG_OBJECT_FLAGS_RECALC; \n
|
||||||
|
} \n
|
||||||
|
return object->contentHeight; \n
|
||||||
|
} \n
|
||||||
|
return 1; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
</inlines>
|
</inlines>
|
||||||
@@ -81,6 +127,7 @@
|
|||||||
<item name="HIDDEN" value="0x00000001" />
|
<item name="HIDDEN" value="0x00000001" />
|
||||||
<item name="LAYOUT" value="0x00000002" />
|
<item name="LAYOUT" value="0x00000002" />
|
||||||
<item name="DRAW" value="0x00000004" />
|
<item name="DRAW" value="0x00000004" />
|
||||||
|
<item name="RECALC" value="0x00000008" />
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define id="AQDG_OBJECT_OPTIONS" prefix="AQDG_OBJECT_OPTIONS_">
|
<define id="AQDG_OBJECT_OPTIONS" prefix="AQDG_OBJECT_OPTIONS_">
|
||||||
@@ -188,6 +235,20 @@
|
|||||||
</member>
|
</member>
|
||||||
|
|
||||||
|
|
||||||
|
<member name="contentWidth" type="int" maxlen="8" >
|
||||||
|
<default>0</default>
|
||||||
|
<preset>0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
|
||||||
|
<member name="contentHeight" type="int" maxlen="8" >
|
||||||
|
<default>0</default>
|
||||||
|
<preset>0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
|
||||||
<member name="flags" type="uint32_t" maxlen="8">
|
<member name="flags" type="uint32_t" maxlen="8">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<preset>0</preset>
|
<preset>0</preset>
|
||||||
@@ -208,19 +269,11 @@
|
|||||||
|
|
||||||
<virtualFns>
|
<virtualFns>
|
||||||
|
|
||||||
<fn name="getDefaultWidth" location="post" >
|
<fn name="calcContentDims" location="post" >
|
||||||
<descr></descr>
|
<descr></descr>
|
||||||
|
|
||||||
<access>public</access>
|
<access>public</access>
|
||||||
<defaultReturnValue>1</defaultReturnValue>
|
<defaultReturnValue>0</defaultReturnValue>
|
||||||
<returnType>int</returnType>
|
|
||||||
</fn>
|
|
||||||
|
|
||||||
<fn name="getDefaultHeight" location="post" >
|
|
||||||
<descr></descr>
|
|
||||||
|
|
||||||
<access>public</access>
|
|
||||||
<defaultReturnValue>1</defaultReturnValue>
|
|
||||||
<returnType>int</returnType>
|
<returnType>int</returnType>
|
||||||
</fn>
|
</fn>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user