#include <ngprop.h>
Inheritance diagram for NamedExportProp:
Public Types | |
enum | { nIndex = 0 } |
Public Member Functions | |
NamedExportProp (const StringBase &strName) | |
Constructs a NamedExportProp object. | |
NamedExportProp (const NamedExportProp &other) | |
Copy-constructs a NamedExportProp object. | |
virtual | ~NamedExportProp () |
Constructs a NamedExportProp object. | |
Filter * | GetFilter () const |
PathName & | GetPath () |
BitmapExportOptions * | GetOptions () const |
void | SetFilter (Filter *pFilter) |
Replaces stored export filter with the given parameter. | |
void | SetPath (const PathName &path) |
Replaces stored export path with a copy of the given parameter. | |
BitmapExportOptions * | SetOptions (BitmapExportOptions *pOptions) |
Replaces stored export options with a copy of the given parameter. | |
BOOL | ExportPropertiesToLocationDlg (SGNameItem *&pItem) |
Outputs debugging information on this property. Brings up the Save As dlg for exporting of named items. | |
Static Public Attributes | |
static BOOL | m_fApplyNotExport = FALSE |
Protected Member Functions | |
virtual SGNameProp * | Clone () |
virtual BOOL | Write (CXaraFileRecord *pRec) |
Writes out a NamedExportProp record. | |
virtual BOOL | Read (CXaraFileRecord *pRec) |
Reads in a NamedExportProp record. | |
virtual BOOL | HandleMouse (SGNameItem *, SGMouseInfo *, SGMiscInfo *) |
Responds to mouse events according to the state of this NamedExportProp. | |
virtual void | CalcUiBounds (SGNameItem *, SGFormatInfo *, SGMiscInfo *, DocRect *) |
virtual BOOL | HandleRedraw (SGNameItem *, SGRedrawInfo *, SGMiscInfo *, const DocRect &) |
Protected Attributes | |
Filter * | m_pFilter |
BitmapExportOptions * | m_pOptions |
PathName | m_Path |
DocRect | m_drPathInvoker |
Definition at line 236 of file ngprop.h.
|
Definition at line 245 of file ngprop.h. 00245 { nIndex = 0 };
|
|
Constructs a NamedExportProp object.
Definition at line 573 of file ngprop.cpp. 00574 : SGNameProp(strName, NamedExportProp::nIndex), 00575 m_pOptions(0) 00576 { 00577 // Create a default export path from the menu operation's default and the set name. 00578 // If there is no implied extension in the set's name then use the default export 00579 // format (ie. JPEG). 00580 String_256 strPath; 00581 if( !OpMenuExport::DefaultExportFilterPath.IsEmpty() ) 00582 strPath = OpMenuExport::DefaultExportFilterPath; 00583 else 00584 { 00585 PORTNOTE("other","Removed use of GetCurrentDirectory") 00586 #ifndef EXCLUDE_FROM_XARALX 00587 FileUtil::GetCurrentDirectory( &strPath ); 00588 #else 00589 strPath = _T("Bodginess abounds."); 00590 #endif 00591 } 00592 00593 // Construct a path and set the default extension (export type) if necessary. 00594 strPath += TEXT("\\"); 00595 strPath += strName; 00596 PathName pth; 00597 pth.SetPathName(strPath); 00598 if (pth.GetType().IsEmpty()) pth.SetType(TEXT("gif")); 00599 ERROR3IF(!pth.IsValid(), "NamedExportProp::NamedExportProp: invalid path"); 00600 00601 // Try to work out the filter from it the set name's implied extension. 00602 for (m_pFilter = Filter::GetFirst(); 00603 m_pFilter != 0; 00604 m_pFilter = Filter::GetNext(m_pFilter)) 00605 if (m_pFilter->GetFlags().CanExport && 00606 m_pFilter->pOILFilter && 00607 m_pFilter->pOILFilter->DoesExtensionOfPathNameMatch(&pth)) 00608 break; 00609 00610 // If we found a filter and made a valid path then the object is essentially 00611 // well-formed. 00612 if (m_pFilter == 0) return; 00613 m_Path = pth; 00614 00615 // TODO: work out default export options (presently only bitmap exports are 00616 // supported.) 00617 if (m_pFilter->IS_KIND_OF(BaseBitmapFilter)) 00618 { 00619 // Make some default filter options. 00620 m_pOptions = ((BaseBitmapFilter*) m_pFilter)->CreateExportOptions(); 00621 if (m_pOptions == 0) 00622 { 00623 ERROR1RAW(_R(IDE_NOMORE_MEMORY)); 00624 return; 00625 } 00626 00627 m_pOptions->RetrieveDefaults(); 00628 } 00629 }
|
|
Copy-constructs a NamedExportProp object.
Definition at line 639 of file ngprop.cpp. 00640 : SGNameProp(other.GetName(), other.GetIndex()), 00641 m_pFilter(other.m_pFilter), 00642 m_pOptions(0), 00643 m_Path(other.m_Path) 00644 { 00645 SetOptions(other.m_pOptions); 00646 }
|
|
Constructs a NamedExportProp object.
Definition at line 658 of file ngprop.cpp. 00659 { 00660 if (m_pOptions != NULL) 00661 { 00662 delete m_pOptions; 00663 m_pOptions = NULL; 00664 } 00665 }
|
|
Implements SGNameProp. Definition at line 877 of file ngprop.cpp. 00879 { 00880 // The choose filter & path invoker is 16 pixels wide and right-justified. 00881 m_drPathInvoker = *pMaxBounds; 00882 m_drPathInvoker.lo.x = m_drPathInvoker.hi.x - pMiscInfo->PixelSize * 16; 00883 00884 // The extension display/choose options invoker is three chars wide. 00885 pMaxBounds->lo.x = m_drPathInvoker.lo.x - pMiscInfo->PixelSize * 24; 00886 }
|
|
Implements SGNameProp. Definition at line 781 of file ngprop.cpp. 00782 { 00783 return new NamedExportProp(*this); 00784 }
|
|
Outputs debugging information on this property. Brings up the Save As dlg for exporting of named items.
Definition at line 1726 of file ngprop.cpp. 01727 { 01728 PORTNOTETRACE("dialog","NamedExportProp::ExportPropertiesToLocationDlg - do nothing"); 01729 #ifndef EXCLUDE_FROM_XARALX 01730 NamedExportProp* pNewProp; 01731 String_256 strNewName; 01732 01733 // A click on the choose filter/path invoker. First make a working copy of this 01734 // property. 01735 pNewProp = (NamedExportProp*) Clone(); 01736 ERRORIF(pNewProp == 0, _R(IDE_NOMORE_MEMORY), FALSE); 01737 01738 // Work out which filter and filename to initially select in the dialog. 01739 UINT32 nFilterID; 01740 INT32 nChosenID; 01741 if (pNewProp->m_pFilter != 0) 01742 { 01743 // We have good filter and path information to show. 01744 nFilterID = pNewProp->m_pFilter->FilterID; 01745 nChosenID = pNewProp->m_pFilter->pOILFilter->Position; 01746 } 01747 else 01748 { 01749 // The implied format is not recognised by any filters, so suggest GIF 01750 // and suggest the name of the item stripped of the problematic extension. 01751 nFilterID = FILTERID_TI_GIF; 01752 nChosenID = Filter::FindFilterFromID(nFilterID)->pOILFilter->Position; 01753 01754 String_256 strPath; 01755 if (!OpMenuExport::DefaultExportFilterPath.IsEmpty()) 01756 strPath = OpMenuExport::DefaultExportFilterPath; 01757 else 01758 FileUtil::GetCurrentDirectory(&strPath); 01759 01760 // Construct a path and set the default extension (export type) if necessary. 01761 strPath += TEXT("\\"); 01762 strPath += GetName(); 01763 pNewProp->m_Path.SetPathName(strPath); 01764 pNewProp->m_Path.SetType(TEXT("gif")); 01765 ERROR3IF(!pNewProp->m_Path.IsValid(), 01766 "NamedExportProp::HandleMouse: invalid path"); 01767 } 01768 01769 // Build the contents of the filter listbox. 01770 char* pchList = 01771 BaseFileDialog::BuildFilterString(FALSE, nFilterID, &nChosenID, CC_RUNTIME_CLASS(BitmapFilter), pNewProp->GetOptions()->GetDepth()); 01772 if (pchList == 0) 01773 { 01774 delete pNewProp; 01775 return FALSE; 01776 } 01777 01778 // Set up the export file dialog. 01779 ExportFileDialog dlg(pchList); 01780 dlg.SetTitle(_R(IDS_NAMEGAL_EXP_TITLE)); 01781 dlg.SetSelectedFilterIndex(nChosenID); 01782 dlg.SetInitialDirectory(pNewProp->m_Path.GetLocation(TRUE)); 01783 dlg.SetDefaultFileName( 01784 String_256(pNewProp->m_Path.GetFileName(pNewProp->m_pFilter != 0))); 01785 01786 // Run it with an Apply button rather than Save/Export. 01787 NamedExportProp::m_fApplyNotExport = TRUE; 01788 BOOL fOk = dlg.OpenAndGetFileName(); 01789 NamedExportProp::m_fApplyNotExport = FALSE; 01790 CCFree(pchList); 01791 01792 // Did the user cancel without making any changes? 01793 if (!fOk) 01794 { 01795 delete pNewProp; 01796 return TRUE; 01797 } 01798 01799 // Retrieve the user's choice and look up the filter. 01800 dlg.GetChosenFileName(&pNewProp->m_Path); 01801 nChosenID = dlg.GetSelectedFilterIndex(); 01802 for (pNewProp->m_pFilter = Filter::GetFirst(); 01803 pNewProp->m_pFilter != 0; 01804 pNewProp->m_pFilter = Filter::GetNext(pNewProp->m_pFilter)) 01805 if (pNewProp->m_pFilter->GetFlags().CanExport && 01806 pNewProp->m_pFilter->pOILFilter->Position == nChosenID) 01807 break; 01808 01809 // Didn't find one? 01810 if (pNewProp->m_pFilter == 0) 01811 { 01812 delete pNewProp; 01813 Error::SetError(_R(IDT_CANT_FIND_FILTER)); 01814 return FALSE; 01815 } 01816 01817 // Needs fixing to match the extension and filter? 01818 if (!pNewProp->m_pFilter->pOILFilter->DoesExtensionOfPathNameMatch(&pNewProp->m_Path)) 01819 pNewProp->m_pFilter->pOILFilter->FixExtensionOfPathName(&pNewProp->m_Path); 01820 01821 // Still bad? 01822 if (!pNewProp->m_Path.IsValid()) 01823 { 01824 delete pNewProp; 01825 return FALSE; 01826 } 01827 01828 // Remember this good path for the next export operation. 01829 OpMenuExport::DefaultExportFilterPath = pNewProp->m_Path.GetLocation(FALSE); 01830 01831 // If the filter has been changed then restore the options to the default. 01832 // TODO: work out default export options (presently only bitmap exports are 01833 // supported.) 01834 if (m_pFilter != pNewProp->m_pFilter && 01835 pNewProp->m_pFilter->IS_KIND_OF(BaseBitmapFilter)) 01836 { 01837 // Make some default filter options. 01838 BitmapExportOptions* pOptions = 01839 ((BaseBitmapFilter*) pNewProp->m_pFilter)->CreateExportOptions(); 01840 if (pOptions == 0) 01841 { 01842 delete pNewProp; 01843 ERROR1RAW(_R(IDE_NOMORE_MEMORY)); 01844 return FALSE; 01845 } 01846 01847 pOptions->RetrieveDefaults(); 01848 pNewProp->SetOptions(pOptions); 01849 } 01850 01851 // If the filename has changed then rename the set accordingly. 01852 String_256 strOldFile(m_Path.GetFileName(FALSE)), 01853 strNewFile(pNewProp->m_Path.GetFileName(FALSE)); 01854 if (strNewFile.CompareTo(strOldFile, FALSE) != 0) 01855 strNewName = strNewFile; 01856 01857 // Undoably replace the old export property with the new, optionally renaming 01858 // it if something was put in strNewName; 01859 BOOL ok = Change(pItem, pNewProp, strNewName.IsEmpty() ? 0 : &strNewName); 01860 01861 // set pItem to point at the changed item if it has changed 01862 if (ok && !strNewName.IsEmpty()) 01863 { 01864 NameGallery * pNameGallery = NameGallery::Instance(); 01865 if (pNameGallery) 01866 { 01867 pNameGallery->FastUpdateNamedSetSizes(FALSE); // this will create any new NGItems that are found in the tree 01868 pItem = SliceHelper::LookupNameGalleryItem(strNewName); 01869 } 01870 } 01871 01872 return ok; 01873 #else 01874 return FALSE; 01875 #endif 01876 }
|
|
Definition at line 693 of file ngprop.cpp. 00694 { 00695 return m_pFilter; 00696 }
|
|
Definition at line 766 of file ngprop.cpp. 00767 { 00768 return m_pOptions; 00769 }
|
|
Definition at line 726 of file ngprop.cpp. 00727 { 00728 return m_Path; 00729 }
|
|
Responds to mouse events according to the state of this NamedExportProp.
Implements SGNameProp. Definition at line 944 of file ngprop.cpp. 00945 { 00946 NamedExportProp* pNewProp; 00947 String_256 strNewName; 00948 00949 // Work out what was clicked on. 00950 if (m_drPathInvoker.ContainsCoord(pMouseInfo->Position)) 00951 { 00952 return ExportPropertiesToLocationDlg(pItem); 00953 } 00954 else 00955 { 00956 // A click on the options invoker. Only invoke if the set knows of a filter 00957 // than can export it. 00958 if (m_pFilter == 0 || !m_Path.IsValid()) return TRUE; 00959 00960 // Make a working copy of this property. 00961 pNewProp = (NamedExportProp*) Clone(); 00962 ERRORIF(pNewProp == 0, _R(IDE_NOMORE_MEMORY), FALSE); 00963 00964 // Save the existing selection and exclusively select the associated set. 00965 OpMenuExport::SaveSelection(); 00966 if (!SelectScan(pItem, SelectScan::SELECT_EXCLUSIVE, TRUE).Scan()) 00967 { 00968 OpMenuExport::RestoreSelection(); 00969 delete pNewProp; 00970 return FALSE; 00971 } 00972 00973 // Set up the tree and dialog. 00974 OpMenuExport::NormaliseSelection(); 00975 PathName pthOld = BmapPrevDlg::m_pthExport; 00976 BmapPrevDlg::m_pthExport = pNewProp->m_Path; 00977 m_fApplyNotExport = TRUE; 00978 00979 // flush the caches so that we display/regen the preview images 00980 pNewProp->m_pOptions->BitmapSourceHasChanged(); 00981 00982 // Get some options from the user. 00983 BOOL fOk = 00984 ((BaseBitmapFilter*) pNewProp->m_pFilter)->GetExportOptions(pNewProp->m_pOptions); 00985 00986 // take responsibility for these export options 00987 // we are storing them so remove the responibility of the dlg for them 00988 // by removing the reference to them. 00989 if (BmapPrevDlg::m_pExportOptions && BmapPrevDlg::m_pExportOptions != pNewProp->m_pOptions) 00990 { 00991 // get the correct export options 00992 pNewProp->m_pOptions = BmapPrevDlg::m_pExportOptions; 00993 // change the filter 00994 pNewProp->m_pFilter = pNewProp->m_pOptions->FindBitmapFilterForTheseExportOptions(); 00995 // change the path 00996 pNewProp->m_Path = BmapPrevDlg::m_pthExport; 00997 } 00998 // we have taken charge of the export options 00999 BmapPrevDlg::m_pExportOptions = 0; 01000 // flush the caches before we store anything 01001 pNewProp->m_pOptions->BitmapSourceHasChanged(); 01002 01003 // Undo what we set up. 01004 m_fApplyNotExport = FALSE; 01005 BmapPrevDlg::m_pthExport = pthOld; 01006 OpMenuExport::RestoreSelection(); 01007 01008 // Did the user cancel without making any changes? 01009 if (!fOk) 01010 { 01011 delete pNewProp; 01012 return TRUE; 01013 } 01014 } 01015 01016 // Undoably replace the old export property with the new, optionally renaming 01017 // it if something was put in strNewName; 01018 return Change(pItem, pNewProp, strNewName.IsEmpty() ? 0 : &strNewName); 01019 }
|
|
Implements SGNameProp. Definition at line 903 of file ngprop.cpp. 00905 { 00906 // Draw the extension text within the extension display/choose options invoker. 00907 if (m_pFilter != 0) 00908 { 00909 DocRect drExtBounds(drBounds); 00910 drExtBounds.lo.x += 4; 00911 drExtBounds.hi.x = m_drPathInvoker.lo.x - 4; 00912 00913 String_8 strExt2; 00914 m_Path.GetType().Left(&strExt2, 3); 00915 strExt2.toUpper(); 00916 00917 pRedrawInfo->Renderer->SetFillColour(pRedrawInfo->Foreground); 00918 pRedrawInfo->Renderer->DrawRect(&drExtBounds); 00919 pRedrawInfo->Renderer->SetFixedSystemTextColours(&pRedrawInfo->Background, 00920 &pRedrawInfo->Foreground); 00921 pRedrawInfo->Renderer->DrawFixedSystemText(&strExt2, drExtBounds); 00922 } 00923 00924 // Draw the choose filter & path invoker. 00925 pRedrawInfo->Renderer->DrawBitmap(m_drPathInvoker.lo, _R(IDB_NAMEGAL_EXPORTABLE)); 00926 return TRUE; 00927 }
|
|
Reads in a NamedExportProp record.
Reimplemented from SGNameProp. Definition at line 823 of file ngprop.cpp. 00824 { 00825 // Read in the base class. 00826 if (!SGNameProp::Read(pRec)) return FALSE; 00827 00828 // Reconstruct the filter reference from the ID. 00829 FILTER_ID id; 00830 if (!pRec->ReadUINT32((UINT32*) &id)) return FALSE; 00831 m_pFilter = Filter::FindFilterFromID(id); 00832 ERROR3IF(id == FILTERID_NONE && m_pFilter != 0, 00833 "NamedExportProp::Read: a filter has _R(ID_NONE)?"); 00834 if (m_pFilter == 0) return id == FILTERID_NONE; 00835 ERROR3IF(!m_pFilter->IS_KIND_OF(BaseBitmapFilter), 00836 "NamedExportProp::Read: wrong filter type"); 00837 00838 // Read in the path to the target file and the export options class name. 00839 String_256 strPath; 00840 TCHAR szOptions[256]; 00841 if (!pRec->ReadUnicode(&strPath) || 00842 !m_Path.SetPathName(strPath, FALSE) || 00843 !pRec->ReadASCII(szOptions, sizeof(szOptions) / sizeof(szOptions[0]))) 00844 return FALSE; 00845 00846 // Reconstruct the export options object. 00847 CCRuntimeClass* pClass = CCObject::GetRuntimeClassByName(szOptions); 00848 00849 if ( pClass == NULL ) 00850 { 00851 return FALSE; 00852 } 00853 00854 // Delete the existing bitmap options. This prevents a memory leak on shutdown. 00855 delete m_pOptions; 00856 00857 m_pOptions = static_cast<BitmapExportOptions*> ( pClass->CreateObject () ); 00858 return ( m_pOptions != 0 && m_pOptions->Read ( pRec ) ); 00859 }
|
|
Replaces stored export filter with the given parameter.
Definition at line 677 of file ngprop.cpp. 00678 { 00679 m_pFilter = pFilter; 00680 }
|
|
Replaces stored export options with a copy of the given parameter.
Definition at line 744 of file ngprop.cpp. 00745 { 00746 if (m_pOptions != NULL) 00747 { 00748 delete m_pOptions; 00749 m_pOptions = NULL; 00750 } 00751 00752 if (pOptions != 0) m_pOptions = pOptions->MakeCopy(); 00753 00754 return m_pOptions; 00755 }
|
|
Replaces stored export path with a copy of the given parameter.
Definition at line 710 of file ngprop.cpp. 00711 { 00712 m_Path = path; 00713 }
|
|
Writes out a NamedExportProp record.
Reimplemented from SGNameProp. Definition at line 796 of file ngprop.cpp. 00797 { 00798 // Write out the base class. 00799 if (!SGNameProp::Write(pRec)) return FALSE; 00800 00801 // Check for no export settings. 00802 if (m_pFilter == 0) return pRec->WriteUINT32(FILTERID_NONE); 00803 ERROR3IF(m_pOptions == 0, "NamedExportProp::Write: no options"); 00804 00805 // Write out the filter ID, the path to the target file, the export options 00806 // class name, and the export options object. 00807 return pRec->WriteUINT32(m_pFilter->FilterID) && 00808 pRec->WriteUnicode((LPTSTR) (LPCTSTR) m_Path.GetPath()) && 00809 pRec->WriteASCII((LPTSTR) m_pOptions->GetRuntimeClass()->GetClassName() ) && 00810 m_pOptions->Write(pRec); 00811 }
|
|
|
|
|
|
|
|
|
|
|