00001 // $Id: ctrllist.cpp 1464 2006-07-18 12:32:26Z gerry $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 00100 #include "camtypes.h" 00101 00102 #include "cartctl.h" 00103 #include "cartprov.h" 00104 #include "dlgevt.h" 00105 #include "dlgmgr.h" 00106 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 00108 CC_IMPLEMENT_DYNCREATE(ControlList, CCObject) 00109 00110 // Declare smart memory handling in Debug builds 00111 #define new CAM_DEBUG_NEW 00112 00113 ControlList * ControlList::m_pControlList = NULL; 00114 00115 /******************************************************************************************** 00116 00117 > ControlList::ControlList() 00118 00119 Author: Alex_Bligh <alex@alex.org.uk> 00120 Created: 02/12/2005 00121 Inputs: - 00122 Outputs: - 00123 Returns: - 00124 Purpose: Constructor 00125 Errors: - 00126 SeeAlso: - 00127 00128 ********************************************************************************************/ 00129 00130 ControlList::ControlList() 00131 { 00132 m_pHash = new ControlPtrToListEntry; 00133 m_ChangedFlag = FALSE; 00134 } 00135 00136 /******************************************************************************************** 00137 00138 > ControlList::~ControlList() 00139 00140 Author: Alex_Bligh <alex@alex.org.uk> 00141 Created: 02/12/2005 00142 Inputs: - 00143 Outputs: - 00144 Returns: - 00145 Purpose: Destructor 00146 Errors: - 00147 SeeAlso: - 00148 00149 ********************************************************************************************/ 00150 00151 ControlList::~ControlList() 00152 { 00153 if (m_pHash) 00154 { 00155 delete m_pHash; 00156 m_pHash = NULL; 00157 } 00158 } 00159 00160 /******************************************************************************************** 00161 00162 > static BOOL ControlList::Init() 00163 00164 Author: Alex_Bligh <alex@alex.org.uk> 00165 Created: 02/12/2005 00166 Inputs: - 00167 Outputs: - 00168 Returns: TRUE on success 00169 Purpose: static initalizer 00170 Errors: - 00171 SeeAlso: - 00172 00173 ********************************************************************************************/ 00174 00175 BOOL ControlList::Init() 00176 { 00177 ERROR2IF(m_pControlList, FALSE, "Double init of ControlList"); 00178 m_pControlList = new ControlList; 00179 ERROR2IF(!m_pControlList, FALSE, "Cannot get a new ControlList"); 00180 00181 wxToolTip::SetDelay(750); 00182 00183 return TRUE; 00184 } 00185 00186 /******************************************************************************************** 00187 00188 > static void ControlList::DeInit() 00189 00190 Author: Alex_Bligh <alex@alex.org.uk> 00191 Created: 02/12/2005 00192 Inputs: - 00193 Outputs: - 00194 Returns: TRUE on success 00195 Purpose: static initalizer 00196 Errors: - 00197 SeeAlso: - 00198 00199 ********************************************************************************************/ 00200 00201 void ControlList::DeInit() 00202 { 00203 ERROR3IF(!m_pControlList, "ControlList not initialized before DeInit()"); 00204 if (m_pControlList) 00205 { 00206 delete m_pControlList; 00207 m_pControlList = NULL; 00208 } 00209 return; 00210 } 00211 00212 /******************************************************************************************** 00213 00214 > BOOL ControlList::NewControl(wxControl * pControl) 00215 00216 Author: Alex_Bligh <alex@alex.org.uk> 00217 Created: 02/12/2005 00218 Inputs: pControl - pointer to the control to add 00219 Outputs: - 00220 Returns: TRUE on success 00221 Purpose: Adds a control to the list managed by us 00222 Errors: - 00223 SeeAlso: - 00224 00225 ********************************************************************************************/ 00226 00227 BOOL ControlList::NewControl(wxControl * pControl) 00228 { 00229 ERROR2IF(!pControl, FALSE, "Null control pointer"); 00230 ERROR2IF(!m_pHash, FALSE, "No hash table"); 00231 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00232 ERROR2IF((i!=m_pHash->end()), FALSE, "Control already present in hash table"); 00233 ControlList::ListEntry l; 00234 (*m_pHash)[pControl]=l; 00235 m_ChangedFlag = TRUE; 00236 return TRUE; 00237 } 00238 00239 /******************************************************************************************** 00240 00241 > BOOL ControlList::DeleteControl(wxControl * pControl) 00242 00243 Author: Alex_Bligh <alex@alex.org.uk> 00244 Created: 02/12/2005 00245 Inputs: pControl - pointer to the control to delete 00246 Outputs: - 00247 Returns: TRUE on success 00248 Purpose: Removes a control from the list managed by us 00249 Errors: - 00250 SeeAlso: - 00251 00252 ********************************************************************************************/ 00253 00254 BOOL ControlList::DeleteControl(wxControl * pControl) 00255 { 00256 ERROR2IF(!pControl, FALSE, "Null control pointer"); 00257 ERROR2IF(!m_pHash, FALSE, "No hash table"); 00258 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00259 ERROR2IF((i==m_pHash->end()), FALSE, "Control not present in hash table"); 00260 m_pHash->erase(i); 00261 m_ChangedFlag = TRUE; 00262 return TRUE; 00263 } 00264 00265 /******************************************************************************************** 00266 00267 > BOOL ControlList::AssociateControl(wxControl * pControl, DialogOp * pDialogOp = NULL) 00268 00269 Author: Alex_Bligh <alex@alex.org.uk> 00270 Created: 02/12/2005 00271 Inputs: pControl - pointer to the control to associate 00272 pDialogOp - pointer to the DialogOp to associate it with 00273 Outputs: - 00274 Returns: TRUE on success 00275 Purpose: Associates a control with a dialog and an OpDescriptor (divined automagically) 00276 Errors: - 00277 SeeAlso: - 00278 00279 ********************************************************************************************/ 00280 00281 BOOL ControlList::AssociateControl(wxControl * pControl, DialogOp * pDialogOp) 00282 { 00283 ERROR2IF(!pControl, FALSE, "Null control pointer"); 00284 ERROR2IF(!m_pHash, FALSE, "No hash table"); 00285 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00286 ERROR2IF((i==m_pHash->end()), FALSE, "Control not present in hash table"); 00287 OpDescriptor * pOpDesc = NULL; 00288 wxString opDesc; 00289 00290 BOOL SpecifiedOpDesc = FALSE; 00291 00292 // wxCamArtControl class can have its OpDescriptor specified in the resources. If it's 00293 // there, use that 00294 if (pControl->IsKindOf(CLASSINFO(wxCamArtControl))) 00295 { 00296 opDesc = ((wxCamArtControl *)(pControl))->GetOpDesc(); 00297 } 00298 00299 if (!(opDesc.IsEmpty())) 00300 { 00301 pOpDesc = OpDescriptor::FindOpDescriptor((TCHAR *)(opDesc.c_str())); 00302 SpecifiedOpDesc = TRUE; 00303 #if _DEBUG 00304 if (!pOpDesc) 00305 { 00306 // ERROR3_PF(("Cannot find OpDescriptor for %s",opDesc.c_str())); // this goes off too often right now 00307 TRACE(_T("ControlList::AssociateControl - Cannot find OpDescriptor for %s"),opDesc.c_str()); 00308 } 00309 #endif 00310 } 00311 else 00312 { 00313 pOpDesc = OpDescriptor::FindOpDescriptor((ResourceID)(pControl->GetId())); 00314 } 00315 00316 (i->second).m_pOpDesc=pOpDesc; 00317 (i->second).m_SpecifiedOpDesc = SpecifiedOpDesc; 00318 (i->second).m_pDialogOp = pDialogOp; 00319 00320 if (pOpDesc) 00321 { 00322 // Set the tooltip if any 00323 ResourceID ToolTip=pOpDesc->GetBubbleId(); 00324 if (ToolTip) 00325 pControl->SetToolTip(wxString(CamResource::GetText(ToolTip))); 00326 00327 ResourceID Help=pOpDesc->GetHelpId(); 00328 if (Help) 00329 pControl->SetHelpText(wxString(CamResource::GetText(Help))); 00330 } 00331 00332 m_ChangedFlag = TRUE; 00333 00334 ReflectState(i->first, &i->second, TRUE); 00335 00336 return TRUE; 00337 } 00338 00339 /******************************************************************************************** 00340 00341 > BOOL ControlList::ReflectState(const wxControl * pControl, ControlList::ListEntry * pListEntry, BOOL ForceUpdate=FALSE); 00342 00343 Author: Alex_Bligh <alex@alex.org.uk> 00344 Created: 02/12/2005 00345 Inputs: pControl - pointer to the control to reflect state to 00346 pListEntry - pointer to list entry with data in 00347 ForceUpdate - TRUE to force an update even if old state supposedly the same (e.g. on creation) 00348 Outputs: - 00349 Returns: TRUE on success 00350 Purpose: Removes a control from the list managed by us 00351 Errors: - 00352 SeeAlso: - 00353 00354 ********************************************************************************************/ 00355 00356 BOOL ControlList::ReflectState(wxControl * pControl, ControlList::ListEntry * pListEntry, BOOL ForceUpdate) 00357 { 00358 if (Camelot.CamelotIsDying()) 00359 return FALSE; 00360 00361 if (pListEntry->m_pOpDesc) 00362 { 00363 String_256 Dummy; 00364 OpState NewState = pListEntry->m_pOpDesc->GetOpsState(&Dummy); 00365 if (ForceUpdate || (pListEntry->m_OpState.Greyed != NewState.Greyed) || (pListEntry->m_OpState.Ticked != NewState.Ticked)) 00366 { 00367 pListEntry->m_OpState = NewState; 00368 00369 wxWindow* pFocusWnd = wxWindow::FindFocus(); 00370 pControl->Enable(!(pListEntry->m_OpState.Greyed)); 00371 00372 // The disabled control had focus, so we must find a sibling control to 00373 // take the focus or face losing keypresses. 00374 if( pListEntry->m_OpState.Greyed && pFocusWnd == pControl ) 00375 { 00376 wxWindowList& lstChildren = pControl->GetParent()->GetChildren(); 00377 size_t cChild = lstChildren.GetCount(); 00378 00379 bool fFound = false; 00380 for( size_t ord = 0; ord < cChild; ++ord ) 00381 { 00382 wxWindow* pSibling = lstChildren.Item( ord )->GetData(); 00383 if( pSibling->IsEnabled() ) 00384 { 00385 pSibling->SetFocus(); 00386 fFound = true; 00387 break; 00388 } 00389 } 00390 00391 // No enabled siblings, fall-back to selecting the panel 00392 if( !fFound ) 00393 pControl->GetParent()->SetFocus(); 00394 } 00395 00396 // Send this to DialogManager so we have a generic implementation 00397 DialogManager::SetBoolGadgetSelected(pControl->GetParent(), pControl->GetId(), pListEntry->m_OpState.Ticked); 00398 } 00399 } 00400 else 00401 { 00402 // Hack to grey only the tool buttons when they have no OpDescriptor attached 00403 // if (pControl->GetStyle() & wxCACS_TOOLBACKGROUND) 00404 00405 // If there was an OpDescriptor specified in the resource file, but we couldn't find it, we grey 00406 // the control. If no OpDescriptor was specified, we don't grey the control because it might be 00407 // simply that there is not meant to be one (e.g. infobar controls) 00408 if (pListEntry->m_SpecifiedOpDesc) 00409 pControl->Enable(FALSE); 00410 } 00411 00412 return TRUE; 00413 } 00414 00415 /******************************************************************************************** 00416 00417 > BOOL ControlList::ReflectAllStates(BOOL IgnoreChangedFlag = FALSE) 00418 00419 Author: Alex_Bligh <alex@alex.org.uk> 00420 Created: 02/12/2005 00421 Inputs: - 00422 Outputs: - 00423 Returns: TRUE on success 00424 Purpose: Refreshes all controls on the list 00425 Errors: - 00426 SeeAlso: - 00427 00428 ********************************************************************************************/ 00429 00430 BOOL ControlList::ReflectAllStates(BOOL IgnoreChangedFlag) 00431 { 00432 if (Camelot.CamelotIsDying()) 00433 return FALSE; 00434 00435 if (!m_ChangedFlag && !IgnoreChangedFlag) 00436 return TRUE; 00437 00438 m_ChangedFlag = FALSE; 00439 00440 ERROR2IF(!m_pHash, FALSE, "No hash table"); 00441 ControlPtrToListEntry::iterator i; 00442 for( i = m_pHash->begin(); i != m_pHash->end(); ++i ) 00443 { 00444 ReflectState(i->first, &i->second); 00445 } 00446 return TRUE; 00447 } 00448 00449 /******************************************************************************************** 00450 00451 > void ControlList::Invoke(wxControl * pControl, OpParam* pOpParam = NULL, BOOL fWithUndo = TRUE) 00452 00453 Author: Alex_Bligh <alex@alex.org.uk> 00454 Created: 02/12/2005 00455 Inputs: pControl - pointer the control 00456 pOpParam - parameters 00457 fwithUndo - invoke with undo 00458 Outputs: - 00459 Returns: - 00460 Purpose: Invokes the Op attached to the OpDescriptor, with the parameters pOpParam & fwithUndo 00461 Errors: - 00462 SeeAlso: - 00463 00464 ********************************************************************************************/ 00465 00466 void ControlList::Invoke(wxControl * pControl, OpParam* pOpParam, BOOL fWithUndo) 00467 { 00468 if (Camelot.CamelotIsDying()) 00469 return; 00470 00471 ERROR2IF(!m_pHash, (void)0, "No hash table"); 00472 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00473 ERROR2IF((i==m_pHash->end()), (void)0, "Control not present in hash table"); 00474 ReflectState(i->first, &i->second); 00475 00476 OpDescriptor * pOpDesc = i->second.m_pOpDesc; 00477 if (pOpDesc && !i->second.m_OpState.Greyed) 00478 { 00479 pOpDesc->Invoke(pOpParam, fWithUndo); 00480 } 00481 } 00482 00483 /******************************************************************************************** 00484 00485 > OpDescriptor * ControlList::Find(wxControl * pControl) 00486 00487 Author: Alex_Bligh <alex@alex.org.uk> 00488 Created: 04/03/2006 00489 Inputs: pControl - pointer to the control to look for 00490 Outputs: - 00491 Returns: NULL if not found, else pointer to the OpDescriptor 00492 Purpose: Searches for the OpDescriptor attached to a control 00493 Errors: - 00494 SeeAlso: - 00495 00496 ********************************************************************************************/ 00497 00498 OpDescriptor * ControlList::Find(wxControl * pControl) 00499 { 00500 if (Camelot.CamelotIsDying()) 00501 return NULL; 00502 00503 ERROR2IF(!m_pHash, NULL, "No hash table"); 00504 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00505 if (i==m_pHash->end()) 00506 return NULL; 00507 00508 return i->second.m_pOpDesc; 00509 } 00510 00511 /******************************************************************************************** 00512 > BOOL ControlList::BuildGadgetList(List* pOutputList, OpDescriptor * pOpDesc) 00513 00514 Author: Alex Bligh <alex@alex.org.uk> 00515 Created: 5 Mar 2005 00516 Inputs: A pointer to a list which will hold the gadgets. 00517 Outputs: A list of gadgets. 00518 Returns: TRUE if there are some gadgets associated with this OpDescriptor, 00519 FALSE if there aren't any. 00520 Purpose: Builds a list of GadgetListItems, each item holding a DialogBarOp* and a 00521 CGadgetID for a control associated with this OpDescriptor. This allows 00522 the caller to manipulate the controls even if there isn't a message from 00523 them needing processing. NB. the caller is responsible for allocating 00524 and deallocating this list! 00525 Errors: - 00526 SeeAlso: class GadgetListItem 00527 ********************************************************************************************/ 00528 00529 BOOL ControlList::BuildGadgetList(List* pOutputList, OpDescriptor * pOpDesc) 00530 { 00531 if (Camelot.CamelotIsDying()) 00532 return FALSE; 00533 00534 ERROR2IF(!pOutputList, FALSE, "Null output list in OpDescriptor::BuildGadgetList"); 00535 00536 // Iterate through all controls 00537 ERROR2IF(!m_pHash, FALSE, "No hash table"); 00538 ControlPtrToListEntry::iterator i; 00539 for( i = m_pHash->begin(); i != m_pHash->end(); ++i ) 00540 { 00541 if (i->second.m_pOpDesc == pOpDesc) 00542 { 00543 DialogOp * pDialogOp = i->second.m_pDialogOp; 00544 if (pDialogOp) 00545 { 00546 // The control shares our OpDescriptor, and has a dialog so put it on the list 00547 GadgetListItem* pgListItem = new GadgetListItem(pDialogOp, i->first->GetId()); 00548 if (pgListItem == NULL) 00549 { 00550 pOutputList->DeleteAll(); 00551 return FALSE; 00552 } 00553 00554 pOutputList->AddHead(pgListItem); 00555 } 00556 } 00557 } 00558 00559 // Return TRUE/FALSE depending on if there are any entries on the list. 00560 return !pOutputList->IsEmpty(); 00561 } 00562 00563 00564 00565 /******************************************************************************************** 00566 00567 > BOOL ControlList::SendMessageToAllBarControls(DialogOp * pDialogOp, DialogMsg * DlgMsg, CWindowID pWindow=NULL) 00568 Author: Alex Bligh 00569 Created: 03-Mar-2005 00570 Inputs: pDialogOp - pointer to the DialogBarOp 00571 DlgMsg - Pointer to the message to send 00572 pWindow - pointer to the Window to recurse through (NULL for all external callers) 00573 Purpose: This iterates through the controls on a bar and sends them each DlgMsg, or 00574 more accurately calls SendMessageToBarControl for each control with an 00575 OpDescriptor attached 00576 Returns: TRUE to destroy the window, else FALSE 00577 SeeAlso: DialogOp::Open 00578 00579 ********************************************************************************************/ 00580 00581 BOOL ControlList::SendMessageToAllControls(DialogOp * pDialogOp, DialogMsg * DlgMsg, CWindowID pWindow) 00582 { 00583 BOOL Destroy = FALSE; 00584 00585 // If at the top of the recursion, look at the appropriate wxWindow 00586 if (!pWindow) 00587 { 00588 pWindow = pDialogOp->GetReadWriteWindowID(); 00589 } 00590 00591 // Handle this window 00592 OpDescriptor * pOpDesc = OpDescriptor::FindOpDescriptor((ResourceID)(pWindow->GetId())); 00593 if (pOpDesc) 00594 { 00595 const BarControlInfo * pBarControlInfo = pOpDesc->GetBarControlInfo(); 00596 if (pBarControlInfo) 00597 { 00598 BarControlInfo bci = *pBarControlInfo; 00599 bci.ControlID = pWindow->GetId(); 00600 bci.ResourceID = pWindow->GetId(); 00601 pOpDesc->SetBarControlInfo(bci); 00602 // Pass a flag saying whether we think this has been internally processed 00603 Destroy |= pDialogOp->SendMessageToControl(pOpDesc, DlgMsg, 00604 pWindow->IsKindOf(CLASSINFO(wxCamArtControl))); 00605 } 00606 } 00607 00608 // Now handle all children 00609 wxWindowList::Node * pNode = pWindow->GetChildren().GetFirst(); 00610 while (pNode) 00611 { 00612 Destroy |= SendMessageToAllControls(pDialogOp, DlgMsg, pNode->GetData()); 00613 pNode = pNode->GetNext(); 00614 } 00615 return Destroy; 00616 } 00617 00618 00619 /******************************************************************************************** 00620 00621 > void ControlList::RegisterWindowAndChildren(wxWindow * pWindow, DialogOp * pDialogOp = NULL) 00622 Author: Alex Bligh 00623 Created: 03-Mar-2005 00624 Inputs: pWindow - pointer to the Window to recurse through 00625 Purpose: pDialogOp - pointer to a DialogOp to associate with (or NULL for none) 00626 This iterates through a windows children, and registers it and all its children 00627 Returns: TRUE to destroy the window, else FALSE 00628 SeeAlso: DialogOp::Open 00629 00630 ********************************************************************************************/ 00631 00632 void ControlList::RegisterWindowAndChildren(wxWindow * pWindow, DialogOp * pDialogOp) 00633 { 00634 ERROR2IF(!m_pHash, (void)0, "No hash table"); 00635 if (pWindow) 00636 { 00637 if (pWindow->IsKindOf(CLASSINFO(wxControl))) 00638 { 00639 wxControl * pControl = (wxControl *)pWindow; 00640 // Remove this one 00641 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00642 if (i==m_pHash->end()) 00643 { 00644 if (NewControl(pControl)) 00645 AssociateControl(pControl, pDialogOp); 00646 } 00647 } 00648 00649 // Iterate through all children 00650 wxWindowList::Node * pNode = pWindow->GetChildren().GetFirst(); 00651 while (pNode) 00652 { 00653 RegisterWindowAndChildren(pNode->GetData(), pDialogOp); 00654 pNode = pNode->GetNext(); 00655 } 00656 } 00657 return; 00658 } 00659 00660 /******************************************************************************************** 00661 00662 > void ControlList::RemoveWindowAndChildren(wxWindow * pWindow) 00663 Author: Alex Bligh 00664 Created: 03-Mar-2005 00665 Inputs: pWindow - pointer to the Window to recurse through (NULL for all external callers) 00666 Purpose: This iterates through a windows children, and removes it and the children 00667 from the list. 00668 Returns: TRUE to destroy the window, else FALSE 00669 SeeAlso: DialogOp::Open 00670 00671 ********************************************************************************************/ 00672 00673 void ControlList::RemoveWindowAndChildren(wxWindow * pWindow) 00674 { 00675 ERROR2IF(!m_pHash, (void)0, "No hash table"); 00676 if (pWindow) 00677 { 00678 if (pWindow->IsKindOf(CLASSINFO(wxControl))) 00679 { 00680 wxControl * pControl = (wxControl *)pWindow; 00681 // Remove this one 00682 ControlPtrToListEntry::iterator i=m_pHash->find(pControl); 00683 if (i!=m_pHash->end()) 00684 DeleteControl(pControl); 00685 } 00686 00687 // Iterate through all children 00688 wxWindowList::Node * pNode = pWindow->GetChildren().GetFirst(); 00689 while (pNode) 00690 { 00691 RemoveWindowAndChildren(pNode->GetData()); 00692 pNode = pNode->GetNext(); 00693 } 00694 } 00695 return; 00696 }