MWContext* xp_FindNamedContextInChildren(MWContext* self, char* name, MWContext* excludeChild) { int i; /* XP_TRACE(("Searching for %s: context %0x, name=%s, title=%s\n", (name ? name : ""), self, (self->name ? self->name : ""), (self->title ? self->title : ""))); */ if (self->name && XP_STRCMP(self->name, name) == 0) { /* XP_TRACE(("Found %s context %0x name=%s\n", (name ? name : ""), self, self->name)); */ return self; } if (self->grid_children) { int count = XP_ListCount(self->grid_children); for (i = 1; i <= count; i++) { MWContext* child = (MWContext*)XP_ListGetObjectNum(self->grid_children, i); if (child != excludeChild) { MWContext* found = xp_FindNamedContextInChildren(child, name, NULL); if (found) return found; } } } return NULL; }
/* * Finds a context that should be loaded with the URL, given * a type and current (refering) context. Return NULL if there is none. */ MWContext * XP_FindContextOfType (MWContext * context, MWContextType type) { int i; /* The other types aren't "real" - they don't have windows. (Actually, neither do all of these, but it's damned useful to be able to find the biff context...) */ XP_ASSERT (type == MWContextBrowser || type == MWContextMail || type == MWContextNews || type == MWContextMessageComposition || type == MWContextBookmarks || type == MWContextAddressBook || type == MWContextBiff || type == MWContextMailMsg || type == MWContextNewsMsg || type == MWContextEditor || type == MWContextPane); /* Added MWContextEditor, needed for bug 61630 */ /* If our current context has the right type, go there */ if (context && context->type == type) return context; /* otherwise, just get any other context */ for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext * compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); if (compContext->type == type) return compContext; } return NULL; }
/* * Removes the context from the context list * Notifies all its children */ void XP_RemoveContextFromList(MWContext *context) { int howMany; int i; if (context == NULL) return; cx_RemoveChildContext(context); /* Its parent does not point to it any more */ /* Now take care of the children, this should not really happen */ if (context->grid_children) { howMany = XP_ListCount(context->grid_children); for (i = 1; i <= howMany; i++) { MWContext * child; child = (MWContext *)XP_ListGetObjectNum(context->grid_children, 1); if (child) child->grid_parent = NULL; XP_ListRemoveObject(context->grid_children, child); } XP_ListDestroy(context->grid_children); context->grid_children = NULL; } XP_ListRemoveObject(xp_GlobalContextList, context); /* Remove from last active stack. * Remove any nav center info about the context. */ XP_RemoveContextFromLastActiveStack(context); XP_RemoveNavCenterInfo(context); }
/* Lock the prefetch_list and normalize the item values. */ PRIVATE int pre_LockNormalizeAndSort() { int count; double sum=0; PrefetchURLStruct* pus = NULL; XP_List* pList = prefetch_list; count = XP_ListCount(prefetch_list); if (0 == count) return 0; while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList))) sum += pus->prevalue; if (sum != 0) { XP_List* pList = prefetch_list; while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList))) pus->prevalue = pus->prevalue/sum; } else return -1; return count; }
XP_List * XFE_FrameListMenu::getShownFrames() { XP_List * frame_list = XFE_MozillaApp::theApp()->getAllFrameList(); Cardinal frame_count = XP_ListCount(frame_list); XP_List * shown_frame_list = NULL; Cardinal i; // Find the shown frames and add them to a list for (i = 0; i < frame_count; i++) { // Get the next frame XFE_Frame * frame = (XFE_Frame*) XP_ListNextObject(frame_list); // Add it to list if valid and shown if (frame && XfeIsAlive(frame->getBaseWidget()) && frame->isShown()) { // Create a new list as soon as we find the first shown item if (!shown_frame_list) { shown_frame_list = XP_ListNew(); } XP_ListAddObject(shown_frame_list,frame); } } return shown_frame_list; }
/* XP_RefreshAnchors * call it after loading a new URL to refresh all the anchors */ void XP_RefreshAnchors() { int i; for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext * compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); LO_RefreshAnchors(compContext); } }
PRIVATE void pre_ProcessList(MWContext* context) { int count = XP_ListCount(prefetch_list); if (XP_ListCount(prefetch_list)>0) { /* Normalize the prefetch-list based on the values */ if (pre_LockNormalizeAndSort() > 0) { /* Invoke NET_GetURL on the prefetch_list */ int i; for (i=0; i<count; i++) { PrefetchURLStruct* pusTop; PrefetchURLStruct* pus; XP_List* pList = prefetch_list; while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList))) { if (pusTop) { if (pusTop->prevalue < pus->prevalue) pusTop = pus; } else pusTop = pus; } if (pusTop->prevalue > USER_SETTING) { NET_GetURL (pus->URL_s, FO_CACHE_ONLY, context, pre_Finished); } XP_ListRemoveObject(prefetch_list, pusTop); } } } }
void XFE_LdapSearchView::initialize() { // LDAP Specific m_rules.scope = (MSG_ScopeAttribute)scopeLdapDirectory; m_toAddrBook = NULL; m_toCompose = NULL; m_browserFrame = NULL; m_directories = FE_GetDirServers(); int nDirs = XP_ListCount(m_directories); if ( nDirs ) m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1); else m_dir = NULL; }
void XFE_ABDirListView::setDirServers(XP_List *dirs) { m_directories = dirs; if (m_directories) { m_nDirs = XP_ListCount(m_directories); }/* if */ else { m_nDirs = 0; m_dir = 0; m_dirLine = 0; }/* else */ /* update UI */ m_outliner->change(0, m_nDirs, m_nDirs); }
void XFE_ABDirListView::propertyCB(DIR_Server *dir) { int which = XP_ListGetNumFromObject(m_directories, dir); #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::propertyCB=%d\n", which); #endif if (!which) { /* new */ const int *selected; int count; m_outliner->getSelection(&selected, &count); int pos = 0; if (m_nDirs > 0 && count && selected) { // Insert dir at position pos = selected[0]; DIR_Server *prev_dir; prev_dir = (DIR_Server*)XP_ListGetObjectNum(m_directories, pos+1); XP_ListInsertObjectAfter(m_directories, prev_dir, dir); pos = pos+1; } else { XP_ListAddObjectToEnd(m_directories, dir); pos = m_nDirs+1; } // Repaint m_nDirs = XP_ListCount(m_directories); m_outliner->change(0, m_nDirs, m_nDirs); // Set selection m_outliner->selectItemExclusive(pos); notifyInterested(XFE_ABDirListView::dirSelect, (void *) dir); }/* if */ else m_outliner->invalidateLine(which); DIR_SaveServerPreferences(m_directories); if (m_deleted_directories) { DIR_CleanUpServerPreferences(m_deleted_directories); m_deleted_directories = NULL; }/* if */ getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating); }
DIR_Server* XFE_LdapSearchView::getDirServer() { Widget btn; int folderNum; XtVaGetValues(m_rules.scopeOptW, XmNmenuHistory, &btn, 0 ); XtVaGetValues(btn, XmNuserData, &folderNum, 0); // Ldap search start ... if ( m_numsubviews <= 0 ) return 0; // This should never happen int nDirs = XP_ListCount(m_directories); DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, folderNum+1); m_dir = dir; return dir; }
/* Backend is not calling FE_PaneChanged on Ldap Directory change right now, therefore, this method is not in use. However, the backend should really call FE_PaneChanged when directory order is changed in the prefs. That notification is hooked up for address book not for ldap search. Has filed a bug to phil */ void XFE_LdapSearchView::paneChanged(XP_Bool /*asynchronous*/, MSG_PANE_CHANGED_NOTIFY_CODE /* notify_code */, int32 /*value*/) { /* Shall we free existing list ? */ m_directories = FE_GetDirServers(); int nDirs = XP_ListCount(m_directories); XP_Bool found = False; for (int i=0; i < nDirs; i++) { DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1); if (dir == m_dir || (dir && m_dir && (dir->dirType == m_dir->dirType))) { if ((dir->serverName==NULL && m_dir->serverName==NULL) || (dir->serverName && m_dir->serverName && !XP_STRCMP(dir->serverName, m_dir->serverName))) { found = True; break; }/* if */ }/* if */ }/* for i*/ if (!found) { /* m_dir got deleted */ m_dir = NULL; if ( !m_dir && nDirs ) { /* there are still some directories installed, pick the first one for best guess */ m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1 ); } } if (!m_dir) /* non-directory left.... close search dialog*/ handleClose(); }
// Override void XFE_LdapSearchView::addDefaultFolders() { int i; Widget popupW; Cardinal ac = 0; Arg av[10]; XP_List *directories = FE_GetDirServers(); int nDirs = XP_ListCount(directories); XtVaGetValues(m_rules.scopeOptW, XmNsubMenuId, &popupW, 0); /* Hopefully: Get Number of Scope Names from MSG */ for ( i = 0; i < nDirs; i++) { Widget btn; XmString xmStr; DIR_Server *dir = (DIR_Server*)XP_ListGetObjectNum(directories,i+1); if ( dir && dir->dirType == LDAPDirectory ) { xmStr = XmStringCreateLtoR(dir->description, XmSTRING_DEFAULT_CHARSET); ac = 0; XtSetArg(av[ac], XmNuserData, i); ac++; XtSetArg(av[ac], XmNlabelString, xmStr); ac++; btn = XmCreatePushButtonGadget(popupW, "ldapDirectory", av, ac); XtAddCallback(btn, XmNactivateCallback, XFE_LdapSearchView::folderOptionCallback, this); XtManageChild(btn); XmStringFree(xmStr); } } }
/* * Count the contexts of the said type. * The second parameter is a flag indicating wether or not the contexts * counted can have parent contexts (top level context switch). */ int XP_ContextCount(MWContextType cxType, XP_Bool bTopLevel) { int iRetval = 0; int iTraverse; MWContext *pContext; /* * Loop through the contexts. */ for(iTraverse = 1; iTraverse <= XP_ListCount(xp_GlobalContextList); iTraverse++) { pContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, iTraverse); if(cxType == MWContextAny || pContext->type == cxType) { /* * See if there's to be no parent. */ if(bTopLevel == FALSE || pContext->is_grid_cell == FALSE) { iRetval++; } } } return(iRetval); }
/* the following was adapted from xp_FindNamedContextInChildren, but simplified for simply matching pointers instead of names. */ Bool XP_IsChildContext(MWContext* parent, MWContext* child) { int i; if (parent == child) { return TRUE; } if (parent->grid_children) { int count = XP_ListCount(parent->grid_children); for (i = 1; i <= count; i++) { MWContext* tchild = (MWContext*)XP_ListGetObjectNum(parent->grid_children, i); if (child == tchild) { return TRUE; } else{ XP_Bool found = XP_IsChildContext(tchild, child); if (found) return found; } } } return FALSE; }
XFE_ABDirListView::XFE_ABDirListView(XFE_Component *toplevel_component, Widget parent, XFE_View *parent_view, MWContext *context, XP_List *directories): XFE_MNListView(toplevel_component, parent_view, context, (MSG_Pane *)NULL), #if !defined(USE_ABCOM) m_directories(directories) #else m_containerLine(NULL), m_activeContainer(NULL) #endif /* USE_ABCOM */ { /* initialize */ m_dir = 0; m_dirLine = 0; m_ancestorInfo = 0; m_deleted_directories = NULL; /* For outliner */ int num_columns = OUTLINER_COLUMN_LAST; static int column_widths[] = {23}; m_outliner = new XFE_Outliner("dirList", this, toplevel_component, parent, False, // constantSize True, // hasHeadings num_columns, num_columns,// num_visible column_widths, AB_DIR_OUTLINER_GEOMETRY_PREF); m_outliner->setHideColumnsAllowed(False); m_outliner->setPipeColumn(OUTLINER_COLUMN_NAME); /* BEGIN_3P: XmLGrid */ XtVaSetValues(m_outliner->getBaseWidget(), XtVaTypedArg, XmNblankBackground, XmRString, "white", 6, // XmNselectionPolicy, XmSELECT_MULTIPLE_ROW, XmNvisibleRows, 15, NULL); XtVaSetValues(m_outliner->getBaseWidget(), XmNcellDefaults, True, XtVaTypedArg, XmNcellBackground, XmRString, "white", 6, NULL); /* END_3P: XmLGrid */ #if defined(USE_ABCOM) // todo: check return val int error = AB_CreateContainerPane(&m_pane, context, fe_getMNMaster()); error = AB_SetShowPropertySheetForDirFunc(m_pane, &XFE_ABDirListView::ShowPropertySheetForDirFunc); error = AB_InitializeContainerPane(m_pane); m_nDirs = MSG_GetNumLines(m_pane); #if defined(DEBUG_tao) printf("\n MSG_GetNumLines, m_nDirs=%d\n", m_nDirs); #endif #else /* XFE_Outliner constructor does not allocate any content row * XFE_Outliner::change(int first, int length, int newnumrows) */ if (directories) { m_nDirs = XP_ListCount(directories); }/* if */ #endif /* USE_ABCOM */ m_outliner->change(0, m_nDirs, m_nDirs); m_outliner->show(); if (m_nDirs) m_outliner->selectItemExclusive(0); setBaseWidget(m_outliner->getBaseWidget()); XtVaSetValues(getBaseWidget(), XmNpaneMinimum, 1, XmNpaneMaximum, 10000, NULL); /* initialize the icons if they haven't already been */ Pixel bg_pixel; XtVaGetValues(m_outliner->getBaseWidget(), XmNbackground, &bg_pixel, 0); if (!m_openParentIcon.pixmap) fe_NewMakeIcon(getToplevel()->getBaseWidget(), /* umm. fix me */ BlackPixelOfScreen(XtScreen(m_outliner->getBaseWidget())), bg_pixel, &m_openParentIcon, NULL, oparent.width, oparent.height, oparent.mono_bits, oparent.color_bits, oparent.mask_bits, FALSE); if (!m_closedParentIcon.pixmap) fe_NewMakeIcon(getToplevel()->getBaseWidget(), /* umm. fix me */ BlackPixelOfScreen(XtScreen(m_outliner->getBaseWidget())), bg_pixel, &m_closedParentIcon, NULL, cparent.width, cparent.height, cparent.mono_bits, cparent.color_bits, cparent.mask_bits, FALSE); if (!m_pabIcon.pixmap) fe_NewMakeIcon(getToplevel()->getBaseWidget(), /* umm. fix me */ BlackPixelOfScreen(XtScreen(m_outliner->getBaseWidget())), bg_pixel, &m_pabIcon, NULL, MNC_AddressSmall.width, MNC_AddressSmall.height, MNC_AddressSmall.mono_bits, MNC_AddressSmall.color_bits, MNC_AddressSmall.mask_bits, FALSE); if (!m_ldapDirIcon.pixmap) fe_NewMakeIcon(getToplevel()->getBaseWidget(), /* umm. fix me */ BlackPixelOfScreen(XtScreen(m_outliner->getBaseWidget())), bg_pixel, &m_ldapDirIcon, NULL, MN_FolderServer.width, MN_FolderServer.height, MN_FolderServer.mono_bits, MN_FolderServer.color_bits, MN_FolderServer.mask_bits, FALSE); if (!m_mListIcon.pixmap) fe_NewMakeIcon(getToplevel()->getBaseWidget(), /* umm. fix me */ BlackPixelOfScreen(XtScreen(m_outliner->getBaseWidget())), bg_pixel, &m_mListIcon, NULL, MN_People.width, MN_People.height, MN_People.mono_bits, MN_People.color_bits, MN_People.mask_bits, FALSE); } XFE_ABDirListView::~XFE_ABDirListView() { } #if defined(USE_ABCOM) int XFE_ABDirListView::ShowPropertySheetForDirFunc(DIR_Server *server, MWContext *context, MSG_Pane *pane, XP_Bool newDirectory) { #if defined(DEBUG_tao) printf("\n XFE_ABDirListView::ShowPropertySheetForDirFunc, newDirectory=%d\n", newDirectory); #endif XFE_ABDirPropertyDlg* Dlg = new XFE_ABDirPropertyDlg(CONTEXT_WIDGET(context), "abDirProperties", True, context); Dlg->setDlgValues(server); Dlg->setPane(pane); Dlg->show(); return 1; }
/* * Write out a hotlist header entry. See comment at the top of * hot_measure_Header for the format used. Assume we start writing at * the start of the buffer passed in. Return a pointer to where the * buffer ends when we get done. */ PRIVATE char * hot_write_Header(char * buffer, HotlistStruct * item, int bLongFormat, int nIndent) { XP_List * list; int iLen; int32 lVal; int32 sVal; if(!item || !buffer) return(buffer); if(bLongFormat) { /* copy the type */ sVal = (int16) item->type; iLen = 2; XP_MEMCPY(buffer, &sVal, iLen); buffer += iLen; /* copy the name */ if(item->name) { iLen = XP_STRLEN(item->name); XP_MEMCPY(buffer, item->name, iLen); buffer += iLen; } /* put the \n terminator on */ *buffer++ = '\n'; /* addition date */ lVal = (int32) item->addition_date; iLen = 4; XP_MEMCPY(buffer, &lVal, iLen); buffer += iLen; /* number of children */ lVal = XP_ListCount(item->children); iLen = 4; XP_MEMCPY(buffer, &lVal, iLen); buffer += iLen; /* copy the description */ if(item->description) { iLen = XP_STRLEN(item->description); XP_MEMCPY(buffer, item->description, iLen); buffer += iLen; } /* put the \n terminator on */ *buffer++ = '\0'; } else { XP_MEMSET(buffer, ' ', nIndent); buffer += nIndent; if(item->name) { XP_STRCPY(buffer, item->name); buffer += XP_STRLEN(item->name); } *buffer++ = '\n'; } /* if no children just get out now */ if(!item->children) return(buffer); /* write out the children */ for(list = item->children->next; list; list = list->next) { HotlistStruct * child = (HotlistStruct *) list->object; if(!child) continue; switch(child->type) { case HOT_URLType: buffer = hot_write_URL(buffer, child, bLongFormat, nIndent + TEXT_INDENT); break; case HOT_HeaderType: buffer = hot_write_Header(buffer, child, bLongFormat, nIndent + TEXT_INDENT); break; case HOT_SeparatorType: buffer = hot_write_Separator(buffer, child, bLongFormat, nIndent + TEXT_INDENT); break; default: break; } } return(buffer); }
void XFE_FrameListMenu::cascading() { XP_List * frame_list = getShownFrames(); XFE_Frame * frame; int i; int frame_count = XP_ListCount(frame_list); Cardinal num_children; WidgetList children; int total_slots_needed; int slots_to_add; int count; XfeChildrenGet(m_submenu,&children,&num_children); XP_ASSERT( num_children > 1 ); // Total number of slots needed total_slots_needed = m_firstslot + 1 + frame_count; // Number of slots to add slots_to_add = total_slots_needed - num_children; // Add more slots if needed if (slots_to_add > 0) { for (i = 0; i < slots_to_add; i++) { Widget item = XtVaCreateWidget(xfeCmdFrameListRaiseItem, //xmToggleButtonGadgetClass, xmPushButtonGadgetClass, m_submenu, NULL); XtAddCallback(item, XmNactivateCallback, //XmNvalueChangedCallback, &XFE_FrameListMenu::item_activate_cb, (XtPointer) this); } // Update num_slots, since we added stuff XfeChildrenGet(m_submenu,&children,&num_children); } count = 1; // Configure the items for (i = (int) m_firstslot + 1; i < (int) num_children; i++) { // Get the next frame frame = (XFE_Frame*) XP_ListNextObject(frame_list); // If the frame is valid, add its title to the slot buttons if (frame) { MWContext * context = m_parentFrame->getContext(); INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context); XmFontList font_list; char name[1024]; XP_SPRINTF(name,"%d. %s",count++,frame->getTitle()); INTL_MidTruncateString(INTL_GetCSIWinCSID(c), name, name, MAX_ITEM_WIDTH); XmString label = fe_ConvertToXmString((unsigned char *) name, INTL_GetCSIWinCSID(c), NULL, XmFONT_IS_FONT, &font_list); if (label) { XtVaSetValues(children[i],XmNlabelString,label,NULL); XmStringFree(label); } XtManageChild(children[i]); } // If the frame is not valid, the unmanage the slot button else { XtUnmanageChild(children[i]); } } // Update the display so that the gadget buttons get drawn XmUpdateDisplay(m_submenu); if (frame_list) { XP_ListDestroy(frame_list); } }
LONG CHiddenFrame::OnFoundDNS(WPARAM wParam, LONG lParam) { int iError = WSAGETASYNCERROR(lParam); // Go through the DNS cache, find the correct task ID. // The find should always be successful. // Be sure to initalize values. POSITION pos = NULL; CString key; CDNSObj *obj = NULL; int i_found = 0; LONG return_value = 1; for(pos = DNSCacheMap.GetStartPosition(); pos != NULL;) { DNSCacheMap.GetNextAssoc(pos, key, (CObject *&)obj); if(!obj) return return_value; // Since the handle is not unique for the session only // compare handles that are currently in use (i.e. active entries) if(!obj->i_finished && obj->m_handle == (HANDLE)wParam) { i_found = 1; break; } // Clear out object if we didn't break. // That way we don't retain value if we leave the loop. obj = NULL; } if(!obj) return return_value; TRACE("%s error=%d h_name=%d task=%d\n", obj->m_host, iError, (obj->m_hostent->h_name != NULL) ? 1 : 0, obj->m_handle); // If by chance we couldn't find it, we have a problem. // ASSERT(i_found == 1); /* temp fix */ if(!i_found) return return_value; // Mark this as completed. // obj->i_finished = 1; // If there was an error, set it. if (iError) { TRACE("DNS Lookup failed! \n"); obj->m_iError = iError; return_value = 0; } /* call ProcessNet for each socket in the list */ /* use a for loop so that we don't reference the "obj" * after our last call to processNet. We need to do * this because the "obj" can get free'd by the call * chain after all the sockets have been removed from * sock_list */ PRFileDesc *tmp_sock; int count = XP_ListCount(obj->m_sock_list); for(; count; count--) { tmp_sock = (PRFileDesc *) XP_ListRemoveTopObject(obj->m_sock_list); // Make sure we call into the Netlib on this socket in particular, // NET_SOCKET_FD type. OnForceIOSelect((WPARAM)SocketSelect, (LPARAM)tmp_sock); } return(return_value); }
MWContext * XP_FindNamedContextInList(MWContext * context, char *name) { int i; if ((name == NULL) || (xp_GlobalContextList == NULL)) return context; /* * Check for special magic window target names */ if (name[0] == '_') { if (XP_STRNCMP(name, "_self", 5) == 0) { return context; } else if (XP_STRNCMP(name, "_parent", 7) == 0) { if ((context)&&(context->grid_parent)) { return context->grid_parent; } else { return context; } } else if (XP_STRNCMP(name, "_top", 4) == 0) { MWContext *top; top = context; while ((top)&&(top->grid_parent)) { top = top->grid_parent; } return top; } else if (XP_STRNCMP(name, "_blank", 6) == 0) { return NULL; } /* else, search for the name, below */ } { MWContext* cx = context; MWContext* found; if (context) { /* If our current context has the right name, go there */ if (cx->name && (XP_STRCMP(cx->name, name) == 0)) return cx; found = xp_FindNamedContextInChildren(cx, name, NULL); if (found) return found; while (cx->is_grid_cell) { MWContext* parent = cx->grid_parent; found = xp_FindNamedContextInChildren(parent, name, cx); if (found) return found; cx = parent; } } /* otherwise, just get any other context */ for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext* compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); /* Only search other top-level contexts that aren't the one we just came from: */ if (!compContext->is_grid_cell && compContext != cx) { found = xp_FindNamedContextInChildren(compContext, name, NULL); if (found) return found; } } } return NULL; }
void CContentView::CalcChildSizes() { // Ask each descendant window what size it would like to be. ::EnumChildWindows(GetSafeHwnd(), QuerySizeCallback, (LPARAM)this); CRect crClient; GetClientRect(crClient); int cx = crClient.Width(); int cy = crClient.Height(); // Total the sizes of all the child window vectors. // This will let us scale by percentage. XP_List *pTraverse = m_pChildSizeInfo; NAVCENTPOS *pPos = NULL; int iTotalHeight = 0; while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) { iTotalHeight += pPos->m_iYVector; } // Find the child with the lowest Y disposition. int iCurPos; int iNextY = 0; while(XP_ListCount(m_pChildSizeInfo)) { pTraverse = m_pChildSizeInfo; iCurPos = INT_MAX; // Find topmost position. while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) { if(pPos->m_iYDisposition < iCurPos) { iCurPos = pPos->m_iYDisposition; } } pTraverse = m_pChildSizeInfo; while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) { if(pPos->m_iYDisposition == iCurPos) { // Resize it. float fPercent = (float)(pPos->m_iYVector) / (float)iTotalHeight; int iNewHeight = (int)(fPercent * (float)cy); // Handle rounding errors. if(iNextY + iNewHeight > cy) { iNewHeight = cy - iNextY; } RECT rect; ::GetClientRect(pPos->m_hChild, &rect); ::SetWindowPos(pPos->m_hChild, HWND_BOTTOM, 0, iNextY, cx, iNewHeight, SWP_NOZORDER); iNextY += iNewHeight; // Remove this one from the list. XP_ListRemoveObject(m_pChildSizeInfo, pPos); XP_FREE(pPos); break; } } } if(m_pChildSizeInfo) { XP_ListDestroy(m_pChildSizeInfo); m_pChildSizeInfo = NULL; } }