#include <ngprop.h>
Inheritance diagram for NamedStretchProp:
Public Types | |
enum | { nIndex = 2 } |
Public Member Functions | |
NamedStretchProp (const StringBase &strName, BYTE nStretchType=X_EXTEND|Y_EXTEND, INT32 nState=0) | |
Outputs debugging information on this property. Constructs a NamedStretchProp object. | |
NamedStretchProp (const NamedStretchProp &other) | |
Copy constructor. | |
void | AddTrigger (const StringBase &strSet) |
Adds a new target to be stretched/extended to this property's target list. | |
void | RemoveTrigger (const StringBase &strSet) |
Removes a target to be stretched/extended from this property's target list. | |
BOOL | HasTrigger (const StringBase &strSet) |
Looks up stretch trigger sets. | |
const DocRect & | GetRefTargetBounds () const |
const DocRect & | GetRefUnionTriggerBounds () const |
void | SetRefTargetBounds (const DocRect &rRefTarget) |
Sets the reference bounding box for this set as a target of stretches and extensions. From this rectangle and the reference union of triggers, we can always calculate how this set should be changed during a stretch. | |
void | SetRefUnionTriggerBounds (const DocRect &rRefTriggers) |
Sets the reference bounding box for the union of this set's stretch/extend trigger sets. From this rectangle and the reference union of triggers, we can always calculate how this set should be changed during a stretch. | |
std::list< TriggerSet > & | GetTriggers () |
void | SetStretchType (BYTE nType) |
BYTE | GetStretchType () const |
BOOL | ValidateStretchingObjects (SGNameItem *pItem) |
Outputs debugging information on this property. | |
Protected Member Functions | |
virtual SGNameProp * | Clone () |
virtual BOOL | Write (CXaraFileRecord *pRec) |
Writes out a NamedStretchProp record. | |
virtual BOOL | Read (CXaraFileRecord *pRec) |
Reads in a NamedStretchProp record. | |
virtual BOOL | HandleMouse (SGNameItem *, SGMouseInfo *, SGMiscInfo *) |
Responds to mouse events according to the state of this NamedStretchProp. | |
virtual void | CalcUiBounds (SGNameItem *, SGFormatInfo *, SGMiscInfo *, DocRect *) |
virtual BOOL | HandleRedraw (SGNameItem *, SGRedrawInfo *, SGMiscInfo *, const DocRect &) |
Draws the UI for the state of this NamedStretchProp. | |
Protected Attributes | |
std::list< TriggerSet > | m_Triggers |
DocRect | m_drInvoker |
BYTE | m_nStretchType |
DocRect | m_rTargetBounds |
DocRect | m_rTriggerBounds |
Definition at line 342 of file ngprop.h.
|
Definition at line 350 of file ngprop.h. 00350 { nIndex = 2 };
|
|
Outputs debugging information on this property. Constructs a NamedStretchProp object.
Definition at line 1056 of file ngprop.cpp. 01057 : NamedTickboxProp(strName, NamedStretchProp::nIndex, nState), 01058 m_nStretchType(nStretchType) 01059 { 01060 // Empty. 01061 }
|
|
Copy constructor.
Definition at line 1073 of file ngprop.cpp. 01074 : NamedTickboxProp(other.GetName(), other.GetIndex(), other.GetState()), 01075 m_nStretchType(other.m_nStretchType), 01076 m_rTargetBounds(other.m_rTargetBounds), 01077 m_rTriggerBounds(other.m_rTriggerBounds) 01078 { 01079 // Duplicate the targets. 01080 m_Triggers.insert(m_Triggers.begin(), other.m_Triggers.begin(), other.m_Triggers.end()); 01081 }
|
|
Adds a new target to be stretched/extended to this property's target list.
Definition at line 1095 of file ngprop.cpp. 01096 { 01097 // Remember this trigger set's name. 01098 ERROR3IF(HasTrigger(strSet), "NamedStretchProp::AddTrigger: trigger already exists"); 01099 m_Triggers.push_back(TriggerSet(strSet)); 01100 }
|
|
Reimplemented from NamedTickboxProp. Definition at line 1245 of file ngprop.cpp. 01247 { 01248 // Target invoker is 16 pixels wide. 01249 NamedTickboxProp::CalcUiBounds(pItem, pFormatInfo, pMiscInfo, pMaxBounds); 01250 m_drInvoker = *pMaxBounds; 01251 pMaxBounds->lo.x -= pMiscInfo->PixelSize * 16; 01252 }
|
|
Implements SGNameProp. Definition at line 1150 of file ngprop.cpp. 01151 { 01152 return new NamedStretchProp(*this); 01153 }
|
|
Definition at line 1426 of file ngprop.cpp. 01427 { 01428 return m_rTargetBounds; 01429 }
|
|
Definition at line 1440 of file ngprop.cpp. 01441 { 01442 return m_rTriggerBounds; 01443 }
|
|
Definition at line 368 of file ngprop.h. 00368 { return m_nStretchType; }
|
|
Definition at line 364 of file ngprop.h. 00364 { return m_Triggers; }
|
|
Responds to mouse events according to the state of this NamedStretchProp.
Reimplemented from NamedTickboxProp. Definition at line 1298 of file ngprop.cpp. 01300 { 01301 // ticking and unticking the stretching properties 01302 // must reset the size of the reference rectangles 01303 // the same as if the triggers have changed (sjk) 01304 BOOL fUsedOnOffTick = !m_drInvoker.ContainsCoord(pMouseInfo->Position); 01305 01306 // If the source is empty then it can have no editable triggers. 01307 if (pItem->IsEmpty()) return TRUE; 01308 01309 // Count the other non-empty items in the 'Used Names' group. 01310 INT32 nSets = 0; 01311 SGUsedNames* pUsedNames = NameGallery::Instance()->GetUsedNames(); 01312 for (SGNameItem* pi = (SGNameItem*) pUsedNames->GetChild(); 01313 pi != 0; 01314 pi = (SGNameItem*) pi->GetNext()) 01315 ++nSets; 01316 01317 // If there isn't another set we can't set any triggers 01318 if (--nSets == 0) return TRUE; 01319 01320 // Create the trigger flag array for the dialog to show/edit. 01321 BYTE* pbTicks = new BYTE[nSets]; 01322 ERRORIF(pbTicks == 0, _R(IDE_NOMORE_MEMORY), FALSE); 01323 01324 // Set up the array with the existing settings. 01325 BYTE* pbTicksIter = pbTicks; 01326 for (pi = (SGNameItem*) pUsedNames->GetChild(); 01327 pi != 0; 01328 pi = (SGNameItem*) pi->GetNext()) 01329 { 01330 // Skip the source set. 01331 if (pi == pItem) continue; 01332 01333 // Lookup the current item in the target list and transfer any settings. 01334 String_256 strName; 01335 pi->GetNameText(&strName); 01336 *pbTicksIter++ = HasTrigger(strName); 01337 } 01338 01339 BYTE nNewType = m_nStretchType; 01340 01341 if (!fUsedOnOffTick) 01342 { 01343 // Run the Edit Targets dialog. 01344 BOOL fOk; 01345 OpParamExtendSetsDlg pm(pbTicks, pItem, &fOk, &nNewType); 01346 01347 OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_EXTENDSETSDLG); 01348 ERROR3IF(pDesc == 0, "NamedStretchProp::HandleMouse: can't find descriptor"); 01349 pDesc->Invoke(&pm); 01350 01351 if (!fOk) 01352 { 01353 delete[] pbTicks; 01354 return TRUE; 01355 } 01356 } 01357 01358 // If the targets have been changed then clone this object and set the new targets 01359 // in the clone. 01360 NamedStretchProp* pClone = (NamedStretchProp*) Clone(); 01361 ERRORIF(pClone == 0, _R(IDE_NOMORE_MEMORY), FALSE); 01362 pClone->m_Triggers.clear(); 01363 01364 // Apply any edits. 01365 DocRect drTrigBounds(0, 0, 0, 0); 01366 BOOL fAnyTicks = FALSE; 01367 pClone->m_nStretchType = nNewType; 01368 pbTicksIter = pbTicks; 01369 01370 if (fUsedOnOffTick) pClone->m_nState = !m_nState; 01371 01372 for (pi = (SGNameItem*) pUsedNames->GetChild(); 01373 pi != 0; 01374 pi = (SGNameItem*) pi->GetNext()) 01375 { 01376 // Skip the target set. 01377 if (pi == pItem) continue; 01378 01379 // Add the set and its stretch type if it's a trigger. 01380 if (*pbTicksIter++) 01381 { 01382 fAnyTicks = TRUE; 01383 String_256 strName; 01384 pi->GetNameText(&strName); 01385 pClone->AddTrigger(strName); 01386 01387 NamedStretchProp* pStretchProp = (NamedStretchProp*) pi->GetProperty(nIndex); 01388 ERROR3IF(pStretchProp == 0, "NamedStretchProp::HandleMouse: no stretch prop"); 01389 01390 // Include the trigger's bounds in the accumulated union. 01391 drTrigBounds = drTrigBounds.Union(pi->GetSetBounds()); 01392 } 01393 } 01394 01395 // Record the bounds of the target and union of triggers at the point of 01396 // (re)definition of the stretch. 01397 pClone->SetRefTargetBounds(pItem->GetSetBounds()); 01398 pClone->SetRefUnionTriggerBounds(drTrigBounds); 01399 01400 // Try to run an op to change the property in the tree undoably. 01401 if (fAnyTicks && !fUsedOnOffTick) pClone->m_nState = TRUE; 01402 pItem->ForceRedrawOfMyself(); 01403 01404 if (pClone->m_nState) 01405 { 01406 if (!pClone->ValidateStretchingObjects(pItem)) 01407 { 01408 InformWarning(_R(IDE_SGNODEREGULARSHAPESDETECTED)); 01409 } 01410 } 01411 01412 delete[] pbTicks; 01413 return Change(pItem, pClone); 01414 }
|
|
Draws the UI for the state of this NamedStretchProp.
Reimplemented from NamedTickboxProp. Definition at line 1270 of file ngprop.cpp. 01272 { 01273 // Only draw the trigger invoker if the source isn't empty and there is at 01274 // least one other set existing, to be a trigger. 01275 if (!pItem->IsEmpty() && (pItem->GetPrevious() != 0 || pItem->GetNext() != 0)) 01276 pRedrawInfo->Renderer->DrawBitmap(m_drInvoker.lo, 01277 m_Triggers.empty() ? _R(IDB_NAMEGAL_NO_TRIGGER) : _R(IDB_NAMEGAL_TRIGGER)); 01278 01279 // Now do the default. 01280 return NamedTickboxProp::HandleRedraw(pItem, pRedrawInfo, pMiscInfo, drBounds); 01281 }
|
|
Looks up stretch trigger sets.
Definition at line 1134 of file ngprop.cpp. 01135 { 01136 std::list<TriggerSet>::iterator p = std::find(m_Triggers.begin(), m_Triggers.end(), strSet); 01137 return p != m_Triggers.end(); 01138 }
|
|
Reads in a NamedStretchProp record.
Reimplemented from NamedTickboxProp. Definition at line 1202 of file ngprop.cpp. 01203 { 01204 // Read in the base class, stretch type and relative bounds, number of trigger sets. 01205 short n; 01206 if (!NamedTickboxProp::Read(pRec) || 01207 !pRec->ReadBYTE(&m_nStretchType) || 01208 !pRec->ReadCoord(&m_rTriggerBounds.lo) || 01209 !pRec->ReadCoord(&m_rTriggerBounds.hi) || 01210 !pRec->ReadCoord(&m_rTargetBounds.lo) || 01211 !pRec->ReadCoord(&m_rTargetBounds.hi) || 01212 !pRec->ReadINT16(&n)) 01213 return FALSE; 01214 01215 // Read in the list of trigger sets. 01216 String_256 strName; 01217 while (n--) 01218 { 01219 if (!pRec->ReadUnicode(&strName)) return FALSE; 01220 if (!HasTrigger(strName)) m_Triggers.push_back(TriggerSet(strName)); 01221 } 01222 01223 // Success. 01224 return TRUE; 01225 }
|
|
Removes a target to be stretched/extended from this property's target list.
Definition at line 1114 of file ngprop.cpp. 01115 { 01116 std::list<TriggerSet>::iterator p = std::find(m_Triggers.begin(), m_Triggers.end(), strSet); 01117 ERROR3IF(p == m_Triggers.end(), "NamedStretchProp::RemoveTrigger: can't find trigger"); 01118 m_Triggers.erase(p); 01119 }
|
|
Sets the reference bounding box for this set as a target of stretches and extensions. From this rectangle and the reference union of triggers, we can always calculate how this set should be changed during a stretch.
Definition at line 1457 of file ngprop.cpp. 01458 { 01459 m_rTargetBounds = rRefTarget; 01460 }
|
|
Sets the reference bounding box for the union of this set's stretch/extend trigger sets. From this rectangle and the reference union of triggers, we can always calculate how this set should be changed during a stretch.
Definition at line 1474 of file ngprop.cpp. 01475 { 01476 m_rTriggerBounds = rRefTriggers; 01477 }
|
|
Definition at line 367 of file ngprop.h. 00367 { m_nStretchType = nType; }
|
|
Outputs debugging information on this property. Author : Matt Priestley Created : 13 February 2001 Purpose : Checks through the given SGNameItem's members and all linked stretchy objects to ensure that none of them have a NodeRegularShape in them as this Node will not extend in an entirely predictable fashion... Returns : BOOL - TRUE if no problems with this stretchy setup. FALSE otherwise... Argument : SGNameItem *pItem - The SGNameItem we wish to test Definition at line 1529 of file ngprop.cpp. 01530 { 01531 PORTNOTETRACE("dialog","NamedStretchProp::ValidateStretchingObjects - do nothing"); 01532 #ifndef EXCLUDE_FROM_XARALX 01533 SGUsedNames* pUsedNames = NameGallery::Instance()->GetUsedNames(); 01534 Spread *pSpread = Document::GetSelectedSpread(); 01535 if (!pItem || !pUsedNames || !pSpread) 01536 { 01537 ERROR3("NULL SGNameItem, SGUsedNames or Spread in ValidateStretchingObjects()"); 01538 return TRUE; 01539 } 01540 01541 SGNameItem *pTempItem = (SGNameItem*) pUsedNames->GetChild(); 01542 while (pTempItem) 01543 { 01544 String_256 strName; 01545 pTempItem->GetNameText(&strName); 01546 01547 if (HasTrigger(strName) || pTempItem == pItem) 01548 { 01549 Node * pNode = SliceHelper::FindNextOfClass((Node *)pSpread, (Node *)pSpread, CC_RUNTIME_CLASS(TemplateAttribute)); 01550 while (pNode) 01551 { 01552 if ((((TemplateAttribute *)pNode)->GetParam() == strName) && !pNode->FindParent()->IsNodeHidden()) 01553 { 01554 if (IS_A(pNode->FindParent(), NodeRegularShape)) 01555 { 01556 // Then we have found a NodeRegularShape in the stretching selection... 01557 return FALSE; 01558 } 01559 01560 if (IS_A(pNode->FindParent(), NodeGroup) || IS_A(pNode->FindParent(), NodeShadowController)|| IS_A(pNode->FindParent(), NodeContourController) || IS_A(pNode->FindParent(), NodeBevelController)) 01561 { 01562 // Then we've found a controller node or a group node - look at its children... 01563 Node * pChild = pNode->FindParent()->FindFirstChild(); 01564 while (pChild) 01565 { 01566 if (!pChild->IsAnAttribute() && !pChild->IsNodeHidden() && IS_A(pChild, NodeRegularShape)) 01567 { 01568 // Then we have found a NodeRegularShape in the stretching selection... 01569 return FALSE; 01570 } 01571 pChild = pChild->FindNext(); 01572 } 01573 } 01574 } 01575 01576 pNode = SliceHelper::FindNextOfClass(pNode, (Node *)pSpread, CC_RUNTIME_CLASS(TemplateAttribute)); 01577 } 01578 } 01579 01580 pTempItem = (SGNameItem*) pTempItem->GetNext(); 01581 } 01582 01583 return TRUE; 01584 #else 01585 return FALSE; 01586 #endif 01587 }
|
|
Writes out a NamedStretchProp record.
Reimplemented from NamedTickboxProp. Definition at line 1167 of file ngprop.cpp. 01168 { 01169 // Write out the base class, stretch type and relative bounds, number of trigger sets. 01170 if (!NamedTickboxProp::Write(pRec) || 01171 !pRec->WriteBYTE(GetStretchType()) || 01172 !pRec->WriteCoord(m_rTriggerBounds.lo) || 01173 !pRec->WriteCoord(m_rTriggerBounds.hi) || 01174 !pRec->WriteCoord(m_rTargetBounds.lo) || 01175 !pRec->WriteCoord(m_rTargetBounds.hi) || 01176 !pRec->WriteINT16( INT16(GetTriggers().size()) ) ) 01177 return FALSE; 01178 01179 // Write out the list of trigger sets. 01180 for (std::list<TriggerSet>::iterator pt = GetTriggers().begin(); 01181 pt != GetTriggers().end(); 01182 pt++) 01183 if (!pRec->WriteUnicode((TCHAR*) (LPCTSTR) pt->m_strSet)) 01184 return FALSE; 01185 01186 // Success. 01187 return TRUE; 01188 }
|
|
|
|
|
|
|
|
|
|
|