Exemplo n.º 1
0
bool tableSetPadding(table *self, int h, int v)
{
	const int oldColPadding = self->columnPadding;
	const int oldRowPadding = self->rowPadding;
	
	// Set the padding
	self->columnPadding = h;
	self->rowPadding = v;
	
	// If applicable re-layout the window
	if (WIDGET(self)->size.x != -1 && WIDGET(self)->size.y != -1)
	{
		// If laying out the window with the new padding fails
		if (!widgetDoLayout(widgetGetRoot(WIDGET(self))))
		{
			// Restore the old padding
			self->columnPadding = oldColPadding;
			self->rowPadding = oldRowPadding;
			
			widgetDoLayout(widgetGetRoot(WIDGET(self)));
			
			return false;
		}
	}
	
	// Either widgetDoLayout succeeded or we did not need laying out
	return true;
}
Exemplo n.º 2
0
bool widgetAddChildImpl(widget *self, widget *child)
{
	// Make sure the id of the child is unquie
	assert(widgetFindById(widgetGetRoot(self), child->id) == NULL);

	// Make sure the child does not currently have a parent
	assert(child->parent == NULL);

	// Add the widget
	vectorAdd(self->children, child);

	// So long as our size is not (-1,-1) (NULL-size), re-layout the window
	if ((self->size.x == -1.0f && self->size.y == -1.0f)
	 || widgetDoLayout(widgetGetRoot(self)))
	{
		// Set ourself as its parent
		child->parent = self;

		return true;
	}
	// Not enough space to fit the widget (widgetDoLayout returned false)
	else
	{
		// Remove child *without* calling its destructor
		vectorRemoveAt(self->children, vectorSize(self->children) - 1);

		// Restore the layout
		widgetDoLayout(widgetGetRoot(self));

		return false;
	}
}
Exemplo n.º 3
0
void widgetRemoveChildImpl(widget *self, widget *child)
{
	int i;

	for (i = 0; i < vectorSize(self->children); i++)
	{
		// If the child is the to-be-removed widget, remove it
		if (vectorAt(self->children, i) == child)
		{
			// Call the destructor for the widget
			widgetDestroy(vectorAt(self->children, i));

			// Remove it from the list of children
			vectorRemoveAt(self->children, i);

			// Re-layout the window (so long as we are part of one)
			if (self->size.x != -1.0f && self->size.y != -1.0f)
			{
				widgetDoLayout(widgetGetRoot(self));
			}
		}
		// See if it is one of its children
		else if (child->parent != self)
		{
			widgetRemoveChild(vectorAt(self->children, i), child);
		}
	}
}
Exemplo n.º 4
0
void widgetHideToolTip(widget *self)
{
	// Create the event
	eventToolTip evt;
	evt.event = widgetCreateEvent(EVT_TOOL_TIP_HIDE);
	evt.target = self;

	// Dispatch the event to the root widget
	widgetHandleEvent(widgetGetRoot(self), (event *) &evt);

	// Note that the tool-tip is now hidden
	self->toolTipVisible = false;
}
Exemplo n.º 5
0
void widgetShowToolTip(widget *self)
{
	// Create the event
	eventToolTip evt;
	evt.event = widgetCreateEvent(EVT_TOOL_TIP_SHOW);
	evt.target = self;

	// Dispatch the event to the root widget
	widgetHandleEvent(widgetGetRoot(self), (event *) &evt);

	// Note that the tool-tip is visible
	self->toolTipVisible = true;
}
Exemplo n.º 6
0
void tableRemoveChildImpl(widget *self, widget *child)
{
	// If we are not the childs parent, delegate to widgetRemoveChildImpl
	if (self != child->parent)
	{
		widgetRemoveChildImpl(self, child);
	}
	// We are the childs parent, so there is some bookkeeping to tend to
	else
	{
		int i;
		
		// Find the index of the child
		for (i = 0; i < vectorSize(self->children); i++)
		{
			if (child == vectorAt(self->children, i))
			{
				break;
			}
		}
		
		// Call the child's destructor and remove it
		widgetDestroy(vectorAt(self->children, i));
		vectorRemoveAt(self->children, i);
		
		// Remove the childs positional information
		free(vectorAt(TABLE(self)->childPositions, i));
		vectorRemoveAt(TABLE(self)->childPositions, i);
		
		// Remove any empty rows/columns
		tableRemoveEmptyRows(TABLE(self));
		tableRemoveEmptyColumns(TABLE(self));
		
		// Redo the layout of the window
		if (self->size.x != -1 && self->size.y != -1)
		{
			widgetDoLayout(widgetGetRoot(self));
		}
	}
}