Exemple #1
0
/*
 * This function requests a minimal geometry for displaying the widget.
 * It is expected to return the width and height in pixels into r.
 *
 * Note: Some widgets will provide FooSizeHint() functions to allow the
 * programmer to request an initial size in pixels or some other metric
 * FooSizeHint() typically sets some structure variable, which are then
 * used here.
 */
static void
SizeRequest(void *p, AG_SizeReq *r)
{
	formaText *my = (formaText*)p;

	if (my->mySurface == -1) {
		/*
		 * We can use AG_TextSize() to return the dimensions of rendered
		 * text, without rendering it.
		 */
		AG_TextFont(AG_FetchFont(NULL, 24, 0));
		AG_TextSize("Custom widget!", &r->w, &r->h);

	} else {
		/*
		 * We can use the geometry of the rendered surface. The
		 * AGWIDGET_SURFACE() macro returns the AG_Surface given a
		 * Widget surface handle.
		 */
		r->w = AGWIDGET_SURFACE(my,my->mySurface)->w;
		r->h = AGWIDGET_SURFACE(my,my->mySurface)->h;
		//r->w=(min(r->w,600));
	}
}
Exemple #2
0
void OnMouseMotionSDL(AG_Event *event)
{
    XM7_SDLView *my = (XM7_SDLView *)AG_SELF();
    int x = AG_INT(1);
    int y = AG_INT(2);
    int w;
    int h;
    AG_Surface *su;
   
    if(my == NULL) return;
    if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
    su = AGWIDGET_SURFACE(my, my->mySurface);
    w = su->w;
    h = su->h;
    CalcMouseMove(w, h, x, y);
}
Exemple #3
0
void OnMouseButtonDownSDL(AG_Event *event)
{
   XM7_SDLView *my = (XM7_SDLView *)AG_SELF();
   int button = AG_INT(1);
   int x = AG_INT(2);
   int y = AG_INT(3);
   int w;
   int h;
   AG_Surface *su;
   if(my == NULL) return;
   if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
   su = AGWIDGET_SURFACE(my, my->mySurface);
   w = su->w;
   h = su->h;
   CalcMouseMove(w, h, x, y);
   if(button == AG_MOUSE_LEFT) {
	nMouseButton &= ~0x10;
   }
   if(button == AG_MOUSE_RIGHT) {
	nMouseButton &= ~0x20;
   }

}