예제 #1
0
void
WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
{
    wassertr(W_TabViewItemView(item) != NULL);

    if (tPtr->maxItems == tPtr->itemCount) {
        WMTabViewItem **items;

        items = wrealloc(tPtr->items,
                         sizeof(WMTabViewItem*) * (tPtr->maxItems + 10));
        memset(&items[tPtr->maxItems], 0, sizeof(WMTabViewItem*) * 10);
        tPtr->items = items;
        tPtr->maxItems += 10;
    }

    if (index > tPtr->itemCount)
        index = tPtr->itemCount;

    if (index == 0 && tPtr->items[0]) {
        W_UnmapTabViewItem(tPtr->items[0]);
    }

    if (index < tPtr->itemCount) {
        memmove(tPtr->items + index + 1, tPtr->items + index,
                (tPtr->itemCount - index) * sizeof(WMTabViewItem*));
    }

    tPtr->items[index] = item;

    tPtr->itemCount++;

    recalcTabWidth(tPtr);

    W_SetTabViewItemParent(item, tPtr);

    W_UnmapTabViewItem(item);

    if (tPtr->flags.bordered) {
        W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
                       tPtr->tabHeight + 1);

        W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3,
                     tPtr->view->size.height - tPtr->tabHeight - 3);
    } else {
        W_ReparentView(W_TabViewItemView(item), tPtr->view, 0,
                       tPtr->tabHeight);

        W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width,
                     tPtr->view->size.height - tPtr->tabHeight);
    }

    if (index == 0) {
        W_MapTabViewItem(item);
    }
    if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems)
        (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr);

    if (W_VIEW_REALIZED(tPtr->view))
        paintTabView(tPtr);
}
예제 #2
0
파일: wtabview.c 프로젝트: crmafra/wmaker
void WMSetTabViewFont(WMTabView * tPtr, WMFont * font)
{
	if (tPtr->font)
		WMReleaseFont(tPtr->font);

	tPtr->font = WMRetainFont(font);
	tPtr->tabHeight = WMFontHeight(tPtr->font) + 3;
	recalcTabWidth(tPtr);
}
예제 #3
0
파일: wtabview.c 프로젝트: crmafra/wmaker
void WMSetTabViewItemLabel(WMTabViewItem * item, const char *label)
{
	if (item->label)
		wfree(item->label);

	if (label)
		item->label = wstrdup(label);
	else
		item->label = NULL;

	if (item->tabView)
		recalcTabWidth(item->tabView);
}
예제 #4
0
파일: wtabview.c 프로젝트: crmafra/wmaker
static void rearrange(TabView * tPtr)
{
	int i;
	int width, height;
	int bordered = tPtr->flags.bordered;

	recalcTabWidth(tPtr);

	width = tPtr->view->size.width - (bordered ? 3 : 0);
	height = tPtr->view->size.height - tPtr->tabHeight - (bordered ? 3 : 0);

	for (i = 0; i < tPtr->itemCount; i++) {
		W_MoveView(W_TabViewItemView(tPtr->items[i]), 1 * bordered, tPtr->tabHeight + 1 * bordered);
		W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height);
	}
	if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view))
		paintTabView(tPtr);
}