Beispiel #1
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int button = AG_INT(1);
	AG_Variable *binding;
	void *pState;
	int newState;
	
	if (AG_WidgetDisabled(bu))
		return;

	if (!AG_WidgetIsFocused(bu))
		AG_WidgetFocus(bu);

	if (button != AG_MOUSE_LEFT)
		return;
	
	binding = AG_GetVariable(bu, "state", &pState);
	if (!(bu->flags & AG_BUTTON_STICKY)) {
		SetState(bu, binding, pState, 1);
	} else {
		newState = !GetState(bu, binding, pState);
		SetState(bu, binding, pState, newState);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", newState);
	}
	AG_UnlockVariable(binding);

	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 1);
		AG_AddTimer(bu, &bu->delayTo, agMouseSpinDelay,
		    ExpireDelay, "%i", agMouseSpinIval);
	}
}
Beispiel #2
0
AG_Window *
DEV_UnicodeBrowser(void)
{
	AG_Window *win;
	AG_Combo *comRange;
	AG_Treetbl *tt;
	int i, w, wMax = 0;

	if ((win = AG_WindowNewNamedS(0, "DEV_UnicodeBrowser")) == NULL) {
		return (NULL);
	}
	AG_WindowSetCaptionS(win, _("Unicode Browser"));
	AG_WindowSetCloseAction(win, AG_WINDOW_DETACH);

	comRange = AG_ComboNew(win, AG_COMBO_HFILL, _("Range: "));
	for (i = 0; i < unicodeRangeCount; i++) {
		AG_TextSize(unicodeRanges[i].name, &w, NULL);
		if (w > wMax) { wMax = w; }
		AG_TlistAddPtr(comRange->list, NULL, unicodeRanges[i].name,
		    (void *)&unicodeRanges[i]);
	}
	AG_ComboSizeHintPixels(comRange, wMax, 10);
	
	tt = AG_TreetblNew(win, AG_TREETBL_EXPAND, NULL, NULL);
	AG_TreetblSizeHint(tt, 200, 6);
	AG_TreetblAddCol(tt, 0, "<XXXXXXX>", "Char");
	AG_TreetblAddCol(tt, 1, "<XXXXXXX>", "Hex");

	AG_SetEvent(comRange, "combo-selected", SelectUnicodeRange, "%p", tt);

	AG_WidgetFocus(comRange);
	return (win);
}
Beispiel #3
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Textbox *tb = AG_SELF();
	AG_WidgetFocus(tb);
	AG_ForwardEvent(NULL, tb->ed, event);
}
Beispiel #4
0
static void
MouseButtonDown(AG_Event *event)
{
    AG_GLView *glv = AG_SELF();

    AG_WidgetFocus(glv);
}
Beispiel #5
0
static void
BeginScrollbarDrag(AG_Event *event)
{
	AG_Textbox *tb = AG_PTR(1);
	
	AG_WidgetFocus(tb->ed);
	tb->ed->flags |= AG_EDITABLE_NOSCROLL;
}
Beispiel #6
0
/* Mouse click event handler */
static void
MouseButtonDown(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int button = AG_INT(1);
	int x = AG_INT(2);
	int y = AG_INT(3);

	if (button != AG_MOUSE_LEFT) {
		return;
	}
	printf("Click at %d,%d\n", x, y);
	AG_WidgetFocus(my);
}
Beispiel #7
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_HSVPal *pal = AG_SELF();
	int btn = AG_INT(1);
	int x = AG_INT(2);
	int y = AG_INT(3);
	float r;

	if (!AG_WidgetIsFocused(pal))
		AG_WidgetFocus(pal);

	switch (btn) {
	case AG_MOUSE_LEFT:
		if (y > pal->rAlpha.y) {
			UpdateAlpha(pal, x);
			pal->state = AG_HSVPAL_SEL_A;
		} else {
			x -= pal->circle.x;
			y -= pal->circle.y;
			r = Hypot((float)x, (float)y);

			if (r > (float)pal->circle.rin) {
				UpdateHue(pal, x, y);
				pal->state = AG_HSVPAL_SEL_H;
			} else {
				UpdateSV(pal, AG_INT(2), AG_INT(3));
				pal->state = AG_HSVPAL_SEL_SV;
			}
		}
		AG_Redraw(pal);
		break;
	case AG_MOUSE_MIDDLE:
	case AG_MOUSE_RIGHT:
		OpenMenu(pal, x,y);
		break;
	}
}
Beispiel #8
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();
	int button = AG_INT(1);
	int x = ((sl->type == AG_SLIDER_HORIZ) ? AG_INT(2) : AG_INT(3));
	int pos;

	if (button != AG_MOUSE_LEFT) {
		return;
	}
	if (GetPosition(sl, &pos) == -1)
		return;

	if (!AG_WidgetIsFocused(sl)) {
		AG_WidgetFocus(sl);
	}
	if (x >= pos && x <= (pos + sl->wControl)) {
		/*
		 * Click on the slider itself. We don't do anything except
		 * saving the cursor position which we will use in future
		 * mousemotion events.
		 */
		sl->ctlPressed = 1;
		sl->xOffs = x - pos;
		AG_PostEvent(NULL, sl, "slider-drag-begin", NULL);
	} else {
		/*
		 * Click outside of control. We seek to the absolute position
		 * described by the cursor.
		 */
		sl->ctlPressed = 1;
		sl->xOffs = sl->wControl/2;
		SeekToPosition(sl, x - sl->xOffs);
		AG_PostEvent(NULL, sl, "slider-drag-begin", NULL);
	}
	AG_Redraw(sl);
}
Beispiel #9
0
void RaiseMenu(AG_Event *event)
{
    if(MenuBar != NULL) {
        AG_WidgetFocus(AGWIDGET(MenuBar));
    }
}