Okay, I've adjusted it so that it draws within the box, but I still get nothing. Am I missing something here? I have attached the source to this e-mail.
V/r, Bryan > -----Original Message----- > From: Denis Oliver Kropp [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 26, 2008 1:41 AM > To: Bryan Bui-Tuong > Cc: directfb-users@directfb.org > Subject: Re: [directfb-users] LiTE: Creating a new widget > > Bryan Bui-Tuong wrote: > > How do I specify the x/y relative to the parent? And starting with > 0,0 > > You already did that by setting x/y in the box.rect. > > > relative to myself will be done in the Draw_line function? > > Yes, you should draw from 0,0 to box.rect.w-1, box.rect.h-1. > > -- > Best regards, > Denis Oliver Kropp > > .------------------------------------------. > | DirectFB - Hardware accelerated graphics | > | http://www.directfb.org/ | > "------------------------------------------"
#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; 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->x2 - reg->x1; rect.h = reg->y2 - reg->y1; 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->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); printf("drawing line...\n"); s->SetColor(s, color->r, color->g, color->b, color->a); s->DrawLine(s, 0, 0, box->rect.w-1, box->rect.h-1); 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 directfb-users@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users