WMTreeNode *WMFindInTreeWithDepthLimit(WMTreeNode * aTree, WMMatchDataProc * match, void *cdata, int limit) { wassertrv(aTree != NULL, NULL); wassertrv(limit >= 0, NULL); return findNodeInTree(aTree, match, cdata, limit); }
static WMPropList *retainPropListByCount(WMPropList * plist, int count) { WMPropList *key, *value; WMHashEnumerator e; int i; plist->retainCount += count; switch (plist->type) { case WPLString: case WPLData: break; case WPLArray: for (i = 0; i < WMGetArrayItemCount(plist->d.array); i++) { retainPropListByCount(WMGetFromArray(plist->d.array, i), count); } break; case WPLDictionary: e = WMEnumerateHashTable(plist->d.dict); while (WMNextHashEnumeratorItemAndKey(&e, (void **)&value, (void **)&key)) { retainPropListByCount(key, count); retainPropListByCount(value, count); } break; default: wwarning(_("Used proplist functions on non-WMPropLists objects")); wassertrv(False, NULL); break; } return plist; }
char* WMGetFontName(WMFont *font) { wassertrv(font!=NULL, NULL); return font->name; }
unsigned int WMFontHeight(WMFont *font) { wassertrv(font!=NULL, 0); return font->height; }
int wGetRectPlacementInfo(WScreen * scr, WMRect rect, int *flags) { int best; unsigned long area, totalArea; int i; int rx = rect.pos.x; int ry = rect.pos.y; int rw = rect.size.width; int rh = rect.size.height; wassertrv(flags != NULL, 0); best = -1; area = 0; totalArea = 0; *flags = XFLAG_NONE; if (scr->xine_info.count <= 1) { unsigned long a; a = calcIntersectionArea(rx, ry, rw, rh, 0, 0, scr->scr_width, scr->scr_height); if (a == 0) { *flags |= XFLAG_DEAD; } else if (a != rw * rh) { *flags |= XFLAG_PARTIAL; } return scr->xine_info.primary_head; } for (i = 0; i < wXineramaHeads(scr); i++) { unsigned long a; a = calcIntersectionArea(rx, ry, rw, rh, scr->xine_info.screens[i].pos.x, scr->xine_info.screens[i].pos.y, scr->xine_info.screens[i].size.width, scr->xine_info.screens[i].size.height); totalArea += a; if (a > area) { if (best != -1) *flags |= XFLAG_MULTIPLE; area = a; best = i; } } if (best == -1) { *flags |= XFLAG_DEAD; best = wGetHeadForPointerLocation(scr); } else if (totalArea != rw * rh) *flags |= XFLAG_PARTIAL; return best; }
WMTreeNode *WMInsertNodeInTree(WMTreeNode * parent, int index, WMTreeNode * aNode) { wassertrv(parent != NULL, NULL); wassertrv(aNode != NULL, NULL); aNode->parent = parent; updateNodeDepth(aNode, parent->depth + 1); if (!parent->leaves) { parent->leaves = WMCreateArrayWithDestructor(1, destroyNode); } if (index < 0) { WMAddToArray(parent->leaves, aNode); } else { WMInsertInArray(parent->leaves, index, aNode); } return aNode; }
WMFont* WMRetainFont(WMFont *font) { wassertrv(font!=NULL, NULL); font->refCount++; return font; }
void *WMReplaceDataForTreeNode(WMTreeNode * aNode, void *newData) { void *old; wassertrv(aNode != NULL, NULL); old = aNode->data; aNode->data = newData; return old; }
WMSize WMGetPixmapSize(WMPixmap * pixmap) { WMSize size = { 0, 0 }; wassertrv(pixmap != NULL, size); size.width = pixmap->width; size.height = pixmap->height; return size; }
int WMWidthOfString(WMFont *font, char *text, int length) { XGlyphInfo extents; wassertrv(font!=NULL, 0); wassertrv(text!=NULL, 0); if (font->screen->useWideChar) { wchar_t *wtext; const char *mtext; int len; wtext = (wchar_t *)wmalloc(sizeof(wchar_t)*(length+1)); mtext = text; len = wmbsnrtowcs(wtext, &mtext, length, length); if (len>0) { wtext[len] = L'\0'; /* not really necessary here */ XftTextExtents32(font->screen->display, font->font, (XftChar32 *)wtext, len, &extents); } else { if (len==-1) { wwarning(_("Conversion to widechar failed (possible " "invalid multibyte sequence): '%s':(pos %d)\n"), text, mtext-text+1); } extents.xOff = 0; } wfree(wtext); } else if (font->screen->useMultiByte) { XftTextExtentsUtf8(font->screen->display, font->font, (XftChar8 *)text, length, &extents); } else { XftTextExtents8(font->screen->display, font->font, (XftChar8 *)text, length, &extents); } return extents.xOff; /* don't ask :P */ }
WMBrowser *WMCreateBrowser(WMWidget * parent) { WMBrowser *bPtr; int i; wassertrv(parent, NULL); bPtr = wmalloc(sizeof(WMBrowser)); bPtr->widgetClass = WC_Browser; bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { wfree(bPtr); return NULL; } bPtr->view->self = bPtr; bPtr->view->delegate = &_BrowserViewDelegate; WMCreateEventHandler(bPtr->view, ExposureMask | StructureNotifyMask | ClientMessageMask, handleEvents, bPtr); /* default configuration */ bPtr->flags.hasScroller = DEFAULT_HAS_SCROLLER; bPtr->titleHeight = DEFAULT_TITLE_HEIGHT; bPtr->flags.isTitled = DEFAULT_IS_TITLED; bPtr->maxVisibleColumns = DEFAULT_MAX_VISIBLE_COLUMNS; WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); bPtr->pathSeparator = wstrdup(DEFAULT_SEPARATOR); if (bPtr->flags.hasScroller) setupScroller(bPtr); for (i = 0; i < bPtr->maxVisibleColumns; i++) { WMAddBrowserColumn(bPtr); } bPtr->usedColumnCount = 0; bPtr->selectedColumn = -1; return bPtr; }
WMTreeNode *WMInsertItemInTree(WMTreeNode * parent, int index, void *item) { WMTreeNode *aNode; wassertrv(parent != NULL, NULL); aNode = WMCreateTreeNodeWithDestructor(item, parent->destructor); aNode->parent = parent; aNode->depth = parent->depth + 1; if (!parent->leaves) { parent->leaves = WMCreateArrayWithDestructor(1, destroyNode); } if (index < 0) { WMAddToArray(parent->leaves, aNode); } else { WMInsertInArray(parent->leaves, index, aNode); } return aNode; }
static unsigned hashPropList(const void *param) { WMPropList *plist= (WMPropList *) param; unsigned ret = 0; unsigned ctr = 0; const char *key; int i, len; switch (plist->type) { case WPLString: key = plist->d.string; len = WMIN(strlen(key), MaxHashLength); for (i = 0; i < len; i++) { ret ^= tolower(key[i]) << ctr; ctr = (ctr + 1) % sizeof(char *); } /*while (*key) { ret ^= tolower(*key++) << ctr; ctr = (ctr + 1) % sizeof (char *); } */ break; case WPLData: key = WMDataBytes(plist->d.data); len = WMIN(WMGetDataLength(plist->d.data), MaxHashLength); for (i = 0; i < len; i++) { ret ^= key[i] << ctr; ctr = (ctr + 1) % sizeof(char *); } break; default: wwarning(_("Only string or data is supported for a proplist dictionary key")); wassertrv(False, 0); break; } return ret; }
WMTreeNode *WMFindInTree(WMTreeNode * aTree, WMMatchDataProc * match, void *cdata) { wassertrv(aTree != NULL, NULL); return findNodeInTree(aTree, match, cdata, -1); }
Pixmap WMGetPixmapMaskXID(WMPixmap * pixmap) { wassertrv(pixmap != NULL, None); return pixmap->mask; }
Pixmap WMGetPixmapXID(WMPixmap * pixmap) { wassertrv(pixmap != NULL, None); return pixmap->pixmap; }