BOOL FontDropDown::AddFontToList(TCHAR *FontName, FontClass Type) { FontDropItem *Item = new FontDropItem(FontName, Type); if(Item == NULL) { ERROR3("FontDropDown::AddFontToList couldn't create Item"); return FALSE; } // Add the item into the list, in a sorted fashion... ListItem *TheItem = Fonts.GetHead(); if(TheItem == NULL) { Fonts.AddTail(Item); return TRUE; } if( ((FontDropItem *)TheItem)->FontName > String_64(FontName)) { Fonts.InsertBefore(TheItem, Item); return TRUE; } while (TheItem != NULL) { ListItem *TheNextItem = Fonts.GetNext(TheItem); if(TheNextItem == NULL) { Fonts.InsertAfter(TheItem, Item); return TRUE; } if(((FontDropItem *)TheNextItem)->FontName > String_64(FontName)) { Fonts.InsertBefore(TheNextItem, Item); return TRUE; } // Try the next item TheItem = TheNextItem; } return TRUE; }
BOOL FontDropDown::SetSelection(FontDropItem *TheFont) { ERROR2IF(ParentDlg == NULL, FALSE, "FontDropDown not properly initialised"); INT32 SelectedIndex = -1; TRACEUSER("wuerthne", _T("SetSelection to %s"), (TCHAR*)TheFont->FontName); INT32 Index = 0; INT32 MaxIndex = GetNumberOfItems(); while (Index < MaxIndex) { if ( (TheFont->FontName == ((FontDropItem *) GetItemData(Index))->FontName) && (TheFont->Type == ((FontDropItem *) GetItemData(Index))->Type) ) { SelectedIndex = Index; break; } Index++; } if (Index == MaxIndex) { TRACEUSER("wuerthne", _T("font not in list, Index = %d"), Index); // font was not in the list, so make sure there is a special item at the // end to accomodate it String_64 NewName(TheFont->FontName); NewName += String_64(_R(IDS_FONTMISSING)); if (m_MissingItemAdded) { TRACEUSER("wuerthne", _T("update missing item")); FontDropItem *Item = (FontDropItem*)Fonts.GetTail(); Item->SetInfo(NewName, FC_UNDEFINED); SelectedIndex = Index - 1; } else { TRACEUSER("wuerthne", _T("add missing item")); FontDropItem *Item = new FontDropItem(NewName, FC_UNDEFINED); Fonts.AddTail(Item); AddItem((void*) Item); m_MissingItemAdded = TRUE; SelectedIndex = Index; } } else { // the font was in the list, so if there is a "missing" item at the end remove it // (unless of course, the selected item *is* the "missing" item, but this cannot // normally happen because our item has the added text " (missing)") if (m_MissingItemAdded && SelectedIndex != MaxIndex - 1) { TRACEUSER("wuerthne", _T("remove missing item")); delete( (FontDropItem*)((Fonts.RemoveItem(Fonts.GetTail()))) ); m_MissingItemAdded = FALSE; // delete the item from the combo box DeleteItem(MaxIndex - 1); } } TRACEUSER("wuerthne", _T("setting index to %d"), SelectedIndex); SetSelectedIndex(SelectedIndex); // And set the appropriate selected item TRACEUSER("wuerthne", _T("SetSelection done")); return(TRUE); }
BOOL GalleryLineDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget) { ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()"); if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL) return FALSE; String_256 DragString(_R(IDS_SGLDRAG_DRAG_LINE_ATTR)); // "Dragging line attribute" DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP)); //" : "; if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget)) { PageDropInfo PageDropInfo; ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo); NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit; ObjectDragTarget TargetHit = PageDropInfo.TargetHit; String_256 ObjectDesc = _R(IDS_SGLDRAG_THIS_OBJECT); // " this object"; if (pObjectHit) { ObjectDesc = pObjectHit->Describe(FALSE); } ClickModifiers ClickMods = ClickModifiers::GetClickModifiers(); BOOL IsInside = ClickMods.Constrain; if (!IsInside && pObjectHit && pObjectHit->IsCompound()) { TargetHit = MANY_TARGET; } switch (TargetHit) { case FILL_TARGET: case LINE_TARGET: case STARTCOL_TARGET: case ENDCOL_TARGET: DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY)); // "Drop to apply this attribute to this "; DragString += ObjectDesc; if (IsInside) DragString += String_64(_R(IDS_SGLDRAG_SPACE_ALONE)); // " alone"; break; case MANY_TARGET: DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY)); // "Drop to apply this attribute to this "; DragString += ObjectDesc; DragString += String_64(_R(IDS_SGLDRAG_CONTROL_DROP_INSIDE)); // "; Press 'Control' to drop 'Inside'"; break; case NO_TARGET: DragString += String_64(_R(IDS_SGLDRAG_DROP_CURRENT_ATTRIBUTE)); // "Drop to set the Current Attribute"; break; default: break; }; *TheText = DragString; return TRUE; } return FALSE; }
BOOL ColourDragInformation::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget) { ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()"); String_256 DragString(_R(IDS_DRAGCOL_DRAGGING_COLOUR)); // "Dragging colour '"); if (TheColour.IsTransparent()) DragString = _R(IDS_DRAGCOL_DRAGGING_NO_COLOUR); // "Dragging 'no colour' : "; else { IndexedColour *TheIxCol = GetInitiallyDraggedColour(); if (TheIxCol != NULL) DragString += *(TheIxCol->GetName()); // Document IndexedColour else DragString += ColourName; // Library colour DragString += String_16(_R(IDS_DRAGCOL_DRAGGING_COLOUR_RIGHT_BIT)); // "' : "; } if (pDragTarget->IS_KIND_OF(ViewDragTarget)) { PageDropInfo PageDropInfo; ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo); NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit; ObjectDragTarget TargetHit = PageDropInfo.TargetHit; String_256 ObjectDesc = _R(IDS_DRAGCOL_THIS_OBJECT); //" this object"; if (pObjectHit) { ObjectDesc = pObjectHit->Describe(FALSE); } ClickModifiers ClickMods = ClickModifiers::GetClickModifiers(); BOOL IsInside = ClickMods.Constrain; if (!IsInside && pObjectHit && pObjectHit->IsCompound()) { TargetHit = MANY_TARGET; } switch (TargetHit) { case FILL_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL)); // "Drop to set the fill colour of this "; DragString += ObjectDesc; if (IsInside) DragString += String_64(_R(IDS_DRAGCOL_ALONE)); // " alone"; break; case LINE_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_LINE)); //"Drop to set the line colour of this "; DragString += ObjectDesc; if (IsInside) DragString += String_64(_R(IDS_DRAGCOL_ALONE)); // " alone"; break; case STARTCOL_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_START)); //"Drop to set the fill start colour of this "; DragString += ObjectDesc; break; case ENDCOL_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END)); //"Drop to set the fill end colour of this "; DragString += ObjectDesc; break; case ENDCOL2_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END2)); //"Drop to set the fill end colour of this "; DragString += ObjectDesc; break; case ENDCOL3_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END3)); //"Drop to set the fill end colour of this "; DragString += ObjectDesc; break; case MANY_TARGET: DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL)); //"Drop to set the fill colour of this "; DragString += ObjectDesc; DragString += String_64(_R(IDS_DRAGCOL_PRESS_CONTROL)); // "; Press 'Control' to drop 'Inside'"; break; case NO_TARGET: if (IsInside) { DragString += String_256(_R(IDS_DRAGCOL_DROP_SETPAGEBACKGROUND)); // "Drop to set the fill colour of the page background"; } else { DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_CURRENT_FILL_COLOUR)); // "Drop to set the 'current fill colour' attribute"; } break; }; *TheText = DragString; return TRUE; } return FALSE; }