Exemplo n.º 1
0
//
// Scrollpane - Resize the scrollbars based on the targets state.
//
static void EZ_scrollpane_ResizeScrollbars(ez_scrollpane_t *scrollpane)
{
	ez_control_t *scrollpane_ctrl	= (ez_control_t *)scrollpane;
	ez_control_t *v_scroll_ctrl		= (ez_control_t *)scrollpane->v_scrollbar;
	ez_control_t *h_scroll_ctrl		= (ez_control_t *)scrollpane->h_scrollbar;

//	qbool size_changed	= false;
	qbool show_v		= (scrollpane->ext_flags & always_h_scrollbar) || (scrollpane->int_flags & show_v_scrollbar);
	qbool show_h		= (scrollpane->ext_flags & always_v_scrollbar) || (scrollpane->int_flags & show_h_scrollbar);
	int rh_size_v		= (scrollpane_ctrl->ext_flags & control_resize_v ? scrollpane_ctrl->resize_handle_thickness : 0); 
	int rh_size_h		= (scrollpane_ctrl->ext_flags & control_resize_h ? scrollpane_ctrl->resize_handle_thickness : 0); 

	EZ_control_SetVisible((ez_control_t *)scrollpane->v_scrollbar, show_v);
	EZ_control_SetVisible((ez_control_t *)scrollpane->h_scrollbar, show_h);

	// Resize the scrollbars depending on if both are shown or not.
	EZ_control_SetSize(v_scroll_ctrl,
						scrollpane->scrollbar_thickness, 
						scrollpane_ctrl->height - (show_h ? scrollpane->scrollbar_thickness : 0) - (2 * rh_size_v));

	EZ_control_SetSize(h_scroll_ctrl,
						scrollpane_ctrl->width - (show_v ? scrollpane->scrollbar_thickness : 0) - (2 * rh_size_h), 
						scrollpane->scrollbar_thickness);

	// Resize the target control so that it doesn't overlap with the scrollbars.
	if (scrollpane->target)
	{
		// Since this resize operation is going to raise a new OnResize event on the target control
		// which in turn calls this function again we only change the size of the target to fit
		// within the scrollbars when the scrollbars actually changed size. Otherwise we'd get an infinite recursion.
		EZ_scrollpane_AdjustTargetSize(scrollpane);
	}
}
Exemplo n.º 2
0
//
// Scrollpane - Initializes a Scrollpane.
//
void EZ_scrollpane_Init(ez_scrollpane_t *scrollpane, ez_tree_t *tree, ez_control_t *parent,
							  char *name, char *description,
							  int x, int y, int width, int height,
							  ez_control_flags_t flags)
{
	int rh_size_h = 0;
	int rh_size_v = 0;
	ez_control_t *scrollpane_ctrl = (ez_control_t *)scrollpane;

	// Initialize the inherited class first.
	EZ_control_Init(&scrollpane->super, tree, parent, name, description, x, y, width, height, flags);

	// Initilize the button specific stuff.
	((ez_control_t *)scrollpane)->CLASS_ID	= EZ_SCROLLPANE_ID;
	((ez_control_t *)scrollpane)->ext_flags	|= (flags | control_focusable | control_contained | control_resizeable);

	// Override control events.
	CONTROL_REGISTER_EVENT(scrollpane, EZ_scrollpane_OnResize, OnResize, ez_control_t);

	// Scrollpane specific events.
	CONTROL_REGISTER_EVENT(scrollpane, EZ_scrollpane_OnTargetChanged, OnTargetChanged, ez_scrollpane_t);
	CONTROL_REGISTER_EVENT(scrollpane, EZ_scrollpane_OnScrollbarThicknessChanged, OnScrollbarThicknessChanged, ez_scrollpane_t);

	scrollpane->scrollbar_thickness = 10;

	rh_size_h = (scrollpane_ctrl->ext_flags & control_resize_h) ? scrollpane_ctrl->resize_handle_thickness : 0;
	rh_size_v = (scrollpane_ctrl->ext_flags & control_resize_v) ? scrollpane_ctrl->resize_handle_thickness : 0;

	EZ_control_SetMinVirtualSize(scrollpane_ctrl, 1, 1);

	scrollpane->int_flags |= (show_h_scrollbar | show_v_scrollbar);

	// Create vertical scrollbar.
	{
		scrollpane->v_scrollbar = EZ_scrollbar_Create(tree, scrollpane_ctrl, "Vertical scrollbar", "", 0, 0, 10, 10, control_anchor_viewport);
		EZ_control_SetVisible((ez_control_t *)scrollpane->v_scrollbar, true);
		EZ_control_SetPosition((ez_control_t *)scrollpane->v_scrollbar, -rh_size_h, rh_size_v);
		EZ_control_SetAnchor((ez_control_t *)scrollpane->v_scrollbar, (anchor_top | anchor_bottom | anchor_right));

		EZ_scrollbar_SetTargetIsParent(scrollpane->v_scrollbar, false);
 
		EZ_control_AddChild(scrollpane_ctrl, (ez_control_t *)scrollpane->v_scrollbar);
	}

	// Create horizontal scrollbar.
	{
		scrollpane->h_scrollbar = EZ_scrollbar_Create(tree, (ez_control_t *)scrollpane, "Horizontal scrollbar", "", 0, 0, 10, 10, control_anchor_viewport);
	
		EZ_control_SetVisible((ez_control_t *)scrollpane->h_scrollbar, true);
		EZ_control_SetPosition((ez_control_t *)scrollpane->h_scrollbar, rh_size_h, -rh_size_v);
		EZ_control_SetAnchor((ez_control_t *)scrollpane->h_scrollbar, (anchor_left | anchor_bottom | anchor_right));

		EZ_scrollbar_SetTargetIsParent(scrollpane->h_scrollbar, false);
		EZ_scrollbar_SetIsVertical(scrollpane->h_scrollbar, false);

		EZ_control_AddChild(scrollpane_ctrl, (ez_control_t *)scrollpane->h_scrollbar);
	}

	EZ_scrollpane_ResizeScrollbars(scrollpane);
}
Exemplo n.º 3
0
//
// Listview item - Sets if a column should be visible or not.
//
void EZ_listviewitem_SetColumnVisible(ez_listviewitem_t *self, int column, qbool visible)
{
    if (!VALID_COLUMN(column))
        return;

    self->item_visibile[column] = visible;
    EZ_control_SetVisible((ez_control_t *)self->items[column], visible);

    CONTROL_RAISE_EVENT(NULL, self, ez_listviewitem_t, OnColumnVisibilityChanged, (void *)column);
}