#include <ctrllist.h>
Inheritance diagram for ControlList:
Public Member Functions | |
ControlList () | |
Constructor. | |
virtual | ~ControlList () |
Destructor. | |
BOOL | NewControl (wxControl *pControl) |
Adds a control to the list managed by us. | |
BOOL | DeleteControl (wxControl *pControl) |
Removes a control from the list managed by us. | |
BOOL | AssociateControl (wxControl *pControl, DialogOp *pDialogOp=NULL) |
Associates a control with a dialog and an OpDescriptor (divined automagically). | |
BOOL | ReflectAllStates (BOOL IgnoreChangedFlag=FALSE) |
Refreshes all controls on the list. | |
void | Changed () |
void | Invoke (wxControl *pControl, OpParam *pOpParam=NULL, BOOL fWithUndo=TRUE) |
Invokes the Op attached to the OpDescriptor, with the parameters pOpParam & fwithUndo. | |
OpDescriptor * | Find (wxControl *pControl) |
Searches for the OpDescriptor attached to a control. | |
BOOL | BuildGadgetList (List *pOutputList, OpDescriptor *pOpDesc) |
Builds a list of GadgetListItems, each item holding a DialogBarOp* and a CGadgetID for a control associated with this OpDescriptor. This allows the caller to manipulate the controls even if there isn't a message from them needing processing. NB. the caller is responsible for allocating and deallocating this list! | |
BOOL | SendMessageToAllControls (DialogOp *pDialogOp, DialogMsg *DlgMsg, CWindowID pWindow=NULL) |
void | RegisterWindowAndChildren (wxWindow *pwxWindow, DialogOp *pDialogOp) |
void | RemoveWindowAndChildren (wxWindow *pwxWindow) |
Static Public Member Functions | |
static ControlList * | Get () |
static BOOL | Init () |
static initalizer | |
static void | DeInit () |
static initalizer | |
static void | Idle () |
Private Member Functions | |
BOOL | ReflectState (wxControl *pControl, ControlList::ListEntry *pListEntry, BOOL ForceUpdate=FALSE) |
Removes a control from the list managed by us. | |
Private Attributes | |
ControlPtrToListEntry * | m_pHash |
BOOL | m_ChangedFlag |
Static Private Attributes | |
static ControlList * | m_pControlList = NULL |
Classes | |
class | ListEntry |
Definition at line 127 of file ctrllist.h.
|
Constructor.
Definition at line 130 of file ctrllist.cpp. 00131 { 00132 m_pHash = new ControlPtrToListEntry; 00133 m_ChangedFlag = FALSE; 00134 }
|
|
Destructor.
Definition at line 151 of file ctrllist.cpp.
|
|
Associates a control with a dialog and an OpDescriptor (divined automagically).
Definition at line 281 of file ctrllist.cpp. 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 }
|
|
Builds a list of GadgetListItems, each item holding a DialogBarOp* and a CGadgetID for a control associated with this OpDescriptor. This allows the caller to manipulate the controls even if there isn't a message from them needing processing. NB. the caller is responsible for allocating and deallocating this list!
Definition at line 529 of file ctrllist.cpp. 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 }
|
|
Definition at line 155 of file ctrllist.h. 00155 {m_ChangedFlag = TRUE;}
|
|
static initalizer
Definition at line 201 of file ctrllist.cpp. 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 }
|
|
Removes a control from the list managed by us.
Definition at line 254 of file ctrllist.cpp. 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 }
|
|
Searches for the OpDescriptor attached to a control.
Definition at line 498 of file ctrllist.cpp. 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 }
|
|
Definition at line 145 of file ctrllist.h. 00145 {return m_pControlList;}
|
|
Definition at line 161 of file ctrllist.h. 00161 {if (m_pControlList) m_pControlList->ReflectAllStates();}
|
|
static initalizer
Reimplemented from SimpleCCObject. Definition at line 175 of file ctrllist.cpp. 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 }
|
|
Invokes the Op attached to the OpDescriptor, with the parameters pOpParam & fwithUndo.
Definition at line 466 of file ctrllist.cpp. 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 }
|
|
Adds a control to the list managed by us.
Definition at line 227 of file ctrllist.cpp. 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 }
|
|
Refreshes all controls on the list.
Definition at line 430 of file ctrllist.cpp. 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 }
|
|
Removes a control from the list managed by us.
Definition at line 356 of file ctrllist.cpp. 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 }
|
|
Definition at line 632 of file ctrllist.cpp. 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 }
|
|
Definition at line 673 of file ctrllist.cpp. 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 }
|
|
Definition at line 581 of file ctrllist.cpp. 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 }
|
|
Definition at line 172 of file ctrllist.h. |
|
Definition at line 169 of file ctrllist.h. |
|
Definition at line 171 of file ctrllist.h. |