Пример #1
0
/* Respond to the mouse moving off a form */
void formHiLiteLost(W_FORM *psWidget, W_CONTEXT *psContext)
{
	/* If one of the widgets were hilited that has to loose it as well */
	if (psWidget->psLastHiLite != NULL)
	{
		widgHiLiteLost(psWidget->psLastHiLite, psContext);
	}
	if (psWidget->style & WFORM_TABBED)
	{
		((W_TABFORM *)psWidget)->tabHiLite = (UWORD)(-1);
	}
	if (psWidget->style & WFORM_CLICKABLE)
	{
		((W_CLICKFORM *)psWidget)->state &= ~(WCLICK_DOWN | WCLICK_HILITE);
	}
	/* Clear the tool tip if there is one */
	tipStop((WIDGET *)psWidget);
}
Пример #2
0
/* Delete a widget from a form */
static bool widgDeleteFromForm(W_FORM *psForm, UDWORD id, W_CONTEXT *psContext)
{
	WIDGET		*psPrev = NULL, *psCurr, *psNext;
	W_TABFORM	*psTabForm;
	UDWORD		minor,major;
	W_MAJORTAB	*psMajor;
	W_MINORTAB	*psMinor;
	W_CONTEXT	sNewContext;

	/* Clear the last hilite if necessary */
	if ((psForm->psLastHiLite != NULL) && (psForm->psLastHiLite->id == id))
	{
		widgHiLiteLost(psForm->psLastHiLite, psContext);
		psForm->psLastHiLite = NULL;
	}

	if (psForm->style & WFORM_TABBED)
	{
		psTabForm = (W_TABFORM *)psForm;
		ASSERT( psTabForm != NULL,
			"widgDeleteFromForm: Invalid form pointer" );

		/* loop through all the tabs */
		psMajor = psTabForm->asMajor;
		for(major=0; major < psTabForm->numMajor; major++)
		{
			psMinor = psMajor->asMinor;
			for(minor=0; minor < psMajor->numMinor; minor++)
			{
				if (psMinor->psWidgets && psMinor->psWidgets->id == id)
				{
					/* The widget is the first on this tab */
					psNext = psMinor->psWidgets->psNext;
					widgRelease(psMinor->psWidgets);
					psMinor->psWidgets = psNext;

					return true;
				}
				else
				{
					for(psCurr = psMinor->psWidgets; psCurr; psCurr = psCurr->psNext)
					{
						if (psCurr->id == id)
						{
							psPrev->psNext = psCurr->psNext;
							widgRelease(psCurr);

							return true;
						}
						if (psCurr->type == WIDG_FORM)
						{
							/* Recurse down to other form */
							sNewContext.psScreen = psContext->psScreen;
							sNewContext.psForm = (W_FORM *)psCurr;
							sNewContext.xOffset = psContext->xOffset - psCurr->x;
							sNewContext.yOffset = psContext->yOffset - psCurr->y;
							sNewContext.mx = psContext->mx - psCurr->x;
							sNewContext.my = psContext->my - psCurr->y;
							if (widgDeleteFromForm((W_FORM *)psCurr, id, &sNewContext))
							{
								return true;
							}
						}
						psPrev = psCurr;
					}
				}
				psMinor++;
			}
			psMajor++;
		}
	}
	else
	{
		ASSERT( psForm != NULL,
			"widgDeleteFromForm: Invalid form pointer" );

		/* Delete from a normal form */
		if (psForm->psWidgets && psForm->psWidgets->id == id)
		{
			/* The widget is the first in the list */
			psNext = psForm->psWidgets->psNext;
			widgRelease(psForm->psWidgets);
			psForm->psWidgets = psNext;

			return true;
		}
		else
		{
			/* Search the rest of the list */
			for(psCurr = psForm->psWidgets; psCurr; psCurr = psCurr->psNext)
			{
				if (psCurr->id == id)
				{
					psPrev->psNext = psCurr->psNext;
					widgRelease(psCurr);

					return true;
				}
				if (psCurr->type == WIDG_FORM)
				{
					/* Recurse down to other form */
					sNewContext.psScreen = psContext->psScreen;
					sNewContext.psForm = (W_FORM *)psCurr;
					sNewContext.xOffset = psContext->xOffset - psCurr->x;
					sNewContext.yOffset = psContext->yOffset - psCurr->y;
					sNewContext.mx = psContext->mx - psCurr->x;
					sNewContext.my = psContext->my - psCurr->y;
					if (widgDeleteFromForm((W_FORM *)psCurr, id, &sNewContext))
					{
						return true;
					}
				}
				psPrev = psCurr;
			}
		}
	}

	return false;
}
Пример #3
0
/* Process all the widgets on a form.
 * mx and my are the coords of the mouse relative to the form origin.
 */
static void widgProcessForm(W_CONTEXT *psContext)
{
	WIDGET		*psCurr, *psOver;
	SDWORD		mx,my, omx,omy, xOffset,yOffset, xOrigin,yOrigin;
	W_FORM		*psForm;
	W_CONTEXT	sFormContext, sWidgContext;

	/* Note current form */
	psForm = psContext->psForm;

//	if(psForm->disableChildren == true) {
//		return;
//	}

	/* Note the current mouse position */
	mx = psContext->mx;
	my = psContext->my;

	/* Note the current offset */
	xOffset = psContext->xOffset;
	yOffset = psContext->yOffset;

	/* Initialise the form context */
	sFormContext.psScreen = psContext->psScreen;

	/* Initialise widget context */
	formGetOrigin(psForm, &xOrigin, &yOrigin);
	sWidgContext.psScreen = psContext->psScreen;
	sWidgContext.psForm = psForm;
	sWidgContext.mx = mx - xOrigin;
	sWidgContext.my = my - yOrigin;
	sWidgContext.xOffset = xOffset + xOrigin;
	sWidgContext.yOffset = yOffset + yOrigin;

	/* Process the form's widgets */
	psOver = NULL;
	for(psCurr = formGetWidgets(psForm); psCurr; psCurr = psCurr->psNext)
	{
		/* Skip any hidden widgets */
		if (psCurr->style & WIDG_HIDDEN)
		{
			continue;
		}

		if (psCurr->type == WIDG_FORM)
		{
			/* Found a sub form, so set up the context */
			sFormContext.psForm = (W_FORM *)psCurr;
			sFormContext.mx = mx - psCurr->x - xOrigin;
			sFormContext.my = my - psCurr->y - yOrigin;
			sFormContext.xOffset = xOffset + psCurr->x + xOrigin;
			sFormContext.yOffset = yOffset + psCurr->y + yOrigin;

			/* Process it */
			widgProcessForm(&sFormContext);
		}
		else
		{
			/* Run the widget */
			widgRun(psCurr, &sWidgContext);
		}
	}

	/* Now check for mouse clicks */
	omx = mx - xOrigin;
	omy = my - yOrigin;
	if (mx >= 0 && mx <= psForm->width &&
		my >= 0 && my <= psForm->height)
	{
   		/* Update for the origin */

   		/* Mouse is over the form - is it over any of the widgets */
   		for(psCurr = formGetWidgets(psForm); psCurr; psCurr = psCurr->psNext)
   		{
   			/* Skip any hidden widgets */
   			if (psCurr->style & WIDG_HIDDEN)
   			{
   				continue;
   			}

   			if (omx >= psCurr->x &&
   				omy >= psCurr->y &&
   				omx <= psCurr->x + psCurr->width &&
   				omy <= psCurr->y + psCurr->height)
   			{
   				/* Note the widget the mouse is over */
   				if (!psMouseOverWidget)
   				{
   					psMouseOverWidget = (WIDGET *)psCurr;
   				}
   				psOver = psCurr;

   				/* Don't check the widgets if it is a clickable form */
   				if (!(psForm->style & WFORM_CLICKABLE))
   				{
   					if (pressed != WKEY_NONE && psCurr->type != WIDG_FORM)
   					{
   						/* Tell the widget it has been clicked */
						psCurr->clicked(&sWidgContext, pressed);
   					}
   					if (released != WKEY_NONE && psCurr->type != WIDG_FORM)
   					{
   						/* Tell the widget the mouse button has gone up */
   						widgReleased(psCurr, released, &sWidgContext);
   					}
   				}
   			}
   		}
   		/* Note that the mouse is over this form */
   		if (!psMouseOverWidget)
   		{
   			psMouseOverWidget = (WIDGET *)psForm;
   		}

		/* Only send the Clicked or Released messages if a widget didn't get the message */
		if (pressed != WKEY_NONE &&
			(psOver == NULL || (psForm->style & WFORM_CLICKABLE)))
		{
			/* Tell the form it has been clicked */
			psForm->clicked(psContext, pressed);
		}
		if (released != WKEY_NONE &&
			(psOver == NULL || (psForm->style & WFORM_CLICKABLE)))
		{
			/* Tell the form the mouse button has gone up */
			widgReleased((WIDGET *)psForm, released, psContext);
		}
	}

	/* See if the mouse has moved onto or off a widget */
	if (psForm->psLastHiLite != psOver)
	{
		if (psOver != NULL)
		{
			widgHiLite(psOver, &sWidgContext);
		}
		if (psForm->psLastHiLite != NULL)
		{
			widgHiLiteLost(psForm->psLastHiLite, &sWidgContext);
		}
		psForm->psLastHiLite = psOver;
	}

	/* Run this form */
	widgRun((WIDGET *)psForm, psContext);
}