/****************************************************************************
 * 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

#define AQDG_DRAWABLE_DEFAULT_BORDER   5
#define AQDG_DRAWABLE_DEFAULT_HSPACING 4
#define AQDG_DRAWABLE_DEFAULT_VSPACING 4



#ifdef __cplusplus
extern "C" {
#endif



/**
 * 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 double AQDG_DrawableWidget_GetValue(const AQDG_OBJECT *object);
AQDG_API void AQDG_DrawableWidget_SetValue(AQDG_OBJECT *object, double v);

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 void AQDG_DrawableWidget_DefaultDraw(AQDG_OBJECT *object);

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 int AQDG_DrawableWidget_GetTextDefaultWidth(AQDG_OBJECT *object);
AQDG_API int AQDG_DrawableWidget_GetTextDefaultHeight(AQDG_OBJECT *object);

AQDG_API int AQDG_DrawableWidget_GetTextWidth(AQDG_OBJECT *object);
AQDG_API int AQDG_DrawableWidget_GetTextHeight(AQDG_OBJECT *object);

AQDG_API AQDG_OBJECT *AQDG_DrawableWidget_GetFirstVisibleChild(const AQDG_OBJECT *o);
AQDG_API AQDG_OBJECT *AQDG_DrawableWidget_GetNextVisibleWidget(AQDG_OBJECT *o);
AQDG_API void AQDG_DrawableWidget_UnhideAllChildren(AQDG_OBJECT *o);



#ifdef __cplusplus
}
#endif


#endif

