void WMDestroyTabViewItem(WMTabViewItem * item) { if (item->label) wfree(item->label); if (item->view) W_DestroyView(item->view); wfree(item); }
WMScrollView* WMCreateScrollView(WMWidget *parent) { ScrollView *sPtr; sPtr = wmalloc(sizeof(ScrollView)); memset(sPtr, 0, sizeof(ScrollView)); sPtr->widgetClass = WC_ScrollView; sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { wfree(sPtr); return NULL; } sPtr->viewport = W_CreateView(sPtr->view); if (!sPtr->viewport) { W_DestroyView(sPtr->view); wfree(sPtr); return NULL; } sPtr->view->self = sPtr; sPtr->viewport->self = sPtr; sPtr->view->delegate = &_ScrollViewViewDelegate; sPtr->viewport->flags.mapWhenRealized = 1; WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask, handleEvents, sPtr); WMCreateEventHandler(sPtr->viewport, SubstructureNotifyMask, handleViewportEvents, sPtr); sPtr->lineScroll = 4; sPtr->pageScroll = 0; return sPtr; }
static void destroyView(W_View * view) { W_View *ptr; if (view->flags.alreadyDead) return; view->flags.alreadyDead = 1; /* delete the balloon text for the view, if there's any */ WMSetBalloonTextForView(NULL, view); if (view->nextFocusChain) view->nextFocusChain->prevFocusChain = view->prevFocusChain; if (view->prevFocusChain) view->prevFocusChain->nextFocusChain = view->nextFocusChain; /* Do not leave focus in a inexisting control */ if (W_FocusedViewOfToplevel(W_TopLevelOfView(view)) == view) W_SetFocusOfTopLevel(W_TopLevelOfView(view), NULL); if (view->flags.topLevel) { W_FocusInfo *info = view->screen->focusInfo; /* remove focus information associated to this toplevel */ if (info) { if (info->toplevel == view) { view->screen->focusInfo = info->next; wfree(info); } else { while (info->next) { if (info->next->toplevel == view) break; info = info->next; } if (info->next) { W_FocusInfo *next = info->next->next; wfree(info->next); info->next = next; } /* else the toplevel did not have any focused subview */ } } } /* destroy children recursively */ while (view->childrenList != NULL) { ptr = view->childrenList; ptr->flags.parentDying = 1; W_DestroyView(ptr); if (ptr == view->childrenList) { view->childrenList = ptr->nextSister; ptr->parent = NULL; } } W_CallDestroyHandlers(view); if (view->flags.realized) { XDeleteContext(view->screen->display, view->window, ViewContext); /* if parent is being destroyed, it will die naturaly */ if (!view->flags.parentDying || view->flags.topLevel) XDestroyWindow(view->screen->display, view->window); } /* remove self from parent's children list */ unparentView(view); /* the array has a wfree() destructor that will be called automatically */ WMFreeArray(view->eventHandlers); view->eventHandlers = NULL; WMRemoveNotificationObserver(view); W_FreeViewXdndPart(view); if (view->backColor) WMReleaseColor(view->backColor); wfree(view); }
void WMDestroyWidget(WMWidget * widget) { W_UnmapView(W_VIEW(widget)); W_DestroyView(W_VIEW(widget)); }