Hi I'm just trying to create a new widget, drawing a basic line but have
been unsuccessful. I was able to get everything to compile, but when I
create the new object, nothing happens. Any ideas as to why? I have
attached the source to this e-mail.
V/R,
Bryan.
//#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <direct/mem.h>
#include "lite_internal.h"
#include <lite/util.h>
#include "line.h"
D_DEBUG_DOMAIN(LiteLineDomain, "LiTE/Line", "LiteLine");
LiteLineTheme *liteDefaultLineTheme = NULL;
struct _LiteLine {
LiteBox box;
LiteLineTheme *theme;
int x;
int y;
int x1;
int y1;
DFBColor *color;
};
static DFBResult draw_line(LiteBox *box, const DFBRegion *region,
DFBBoolean clear);
static DFBResult destroy_line(LiteBox *box);
DFBResult
lite_new_line(LiteBox *parent,
DFBRegion *reg,
DFBColor *color,
LiteLineTheme *theme,
LiteLine **ret_line)
{
LiteLine *line = NULL;
DFBResult res;
DFBRectangle rect;
rect.x = reg->x1; rect.y = reg->y1; rect.w = reg->x1 + reg->x2; rect.h
= 1;
line = D_CALLOC(1, sizeof(LiteLine));
line->box.type = LITE_TYPE_BOX_USER ;
line->box.parent = parent;
line->theme = theme;
line->box.rect = rect;
res = lite_init_box(LITE_BOX(line));
if (res != DFB_OK) {
D_FREE(line);
return res;
}
//line->box.type = LITE_TYPE_LINE;
line->box.Draw = draw_line;
line->box.Destroy = destroy_line;
line->x = reg->x1;
line->y = reg->y1;
line->x1 = reg->x2;
line->y1 = reg->y2;
line->color = color;
*ret_line = line;
D_DEBUG_AT(LiteLineDomain, "Created new line object: %p\n", line);
return DFB_OK;
}
/* internals */
static DFBResult
destroy_line(LiteBox *box)
{
LiteLine *line = LITE_LINE(box);
D_ASSERT(box != NULL);
D_DEBUG_AT(LiteLineDomain, "Destroy line: %p\n", line);
if (!line)
return DFB_FAILURE;
return lite_destroy_box(box);
}
static DFBResult
draw_line(LiteBox *box,
const DFBRegion *region,
DFBBoolean clear)
{
LiteLine *line = LITE_LINE(box);
IDirectFBSurface *s = box->surface;
DFBColor *color = line->color;
D_ASSERT(box != NULL);
s->SetClip(s, region);
s->SetColor(s, color->r, color->g, color->b, color->a);
s->DrawLine(s, line->x, line->y, line->x1, line->y1);
return DFB_OK;
}
/**
* @brief This file contains definitions for the LiTE line interface.
* @ingroup LiTE
* @file line.h
* <hr>
**/
#ifndef __LITE__LINE_H__
#define __LITE__LINE_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <lite/box.h>
#include <lite/theme.h>
/* @brief Macro to convert a generic LiteBox into a LiteLine */
#define LITE_LINE(l) ((LiteLine*)(l))
/* @brief LiteLine structure */
typedef struct _LiteLine LiteLine;
/* @brief Image theme */
typedef struct _LiteLineTheme {
LiteTheme theme; /**< base LiTE theme */
struct {
IDirectFBSurface *surface;
DFBRegion *region;
DFBColor *color;
} line;
} LiteLineTheme;
/* @brief Standard line themes */
/* @brief No line theme */
#define liteNoLineTheme NULL
/* @brief default line theme */
extern LiteLineTheme *liteDefaultLineTheme;
/* @brief Create a new LiteLine object
* This function will create a new LiteLine object.
*
* @param parent IN: Valid parent LiteBox
* @param rect IN: Rectangle coordinates for the
progressbar
* @param color IN: Color
* @param theme IN: Line Theme
* @param ret_progressbar OUT: Valid LiteLine object
*
* @return DFBResult Returns DFB_OK if successful.
*/
DFBResult lite_new_line( LiteBox *parent,
DFBRegion
*reg,
DFBColor
*color,
LiteLineTheme *theme,
LiteLine
**ret_line);
#ifdef __cplusplus
}
#endif
#endif /* __LITE__LINE_H__ */
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users