Add new method to find out what type of file the user selected from the type/filter list in the save dialog.

This commit is contained in:
sdagley%netscape.com 1999-05-27 20:54:53 +00:00
Родитель c7ff36efd8
Коммит 23c6b4a6e3
7 изменённых файлов: 52 добавлений и 3 удалений

Просмотреть файл

@ -96,6 +96,17 @@ public:
NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) = 0;
/**
* Get the index into the filter list for the type of file the user wants to save
*
* @param theType the index into the filter list
* @return void
*
*/
NS_IMETHOD GetSelectedType(PRInt16& theType) = 0;
/**
* Show File Dialog. The dialog is displayed modally.
*
@ -156,6 +167,7 @@ public:
nsIWidget * aParent,
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
};
#endif // nsIFileWidget_h__

Просмотреть файл

@ -115,6 +115,14 @@ NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile)
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType)
{
theType = mSelectedType;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get the file + path

Просмотреть файл

@ -73,6 +73,9 @@ public:
const nsString &promptString,
nsFileSpec &theFileSpec);
NS_IMETHOD GetSelectedType(PRInt16& theType);
protected:
static gint DestroySignal(GtkWidget * aGtkWidget,
nsFileWidget* aWidget);
@ -87,6 +90,7 @@ protected:
const nsString* mFilters;
nsString mDefault;
nsFileSpec mDisplayDirectory;
PRInt16 mSelectedType;
};
#endif // nsFileWidget_h__

Просмотреть файл

@ -599,6 +599,15 @@ bail_wo_IC:
return NS_OK;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType)
{
theType = mSelectedType;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get the file + path
@ -628,7 +637,7 @@ NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString)
// Set the display directory
//
//-------------------------------------------------------------------------
NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory)
NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory)
{
mDisplayDirectory = aDirectory;
return NS_OK;
@ -640,7 +649,7 @@ NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory)
//
//-------------------------------------------------------------------------
NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory)
NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory)
{
aDirectory = mDisplayDirectory;
return NS_OK;

Просмотреть файл

@ -94,6 +94,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec); // Populate with initial path for file dialog
NS_IMETHOD GetSelectedType(PRInt16& theType);
protected:
NS_IMETHOD OnOk();
@ -121,6 +122,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget
void GetFilterListArray(nsString& aFilterList);
NavTypeListPtr mTypeLists[kMaxTypeListCount];
PRInt16 mSelectedType;
};

Просмотреть файл

@ -125,6 +125,9 @@ PRBool nsFileWidget::Show()
else {
NS_ASSERTION(0, "Only load and save are supported modes");
}
// Remember what filter type the user selected
mSelectedType = ofn.nFilterIndex;
// Store the current directory in mDisplayDirectory
char* newCurrentDirectory = new char[MAX_PATH+1];
@ -180,10 +183,18 @@ NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsStri
return NS_OK;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType)
{
theType = mSelectedType;
return NS_OK;
}
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile)
NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile)
{
Show();
nsFilePath filePath(mFile);

Просмотреть файл

@ -70,6 +70,8 @@ class nsFileWidget : public nsIFileWidget
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec); // Populate with initial path for file dialog
NS_IMETHOD GetSelectedType(PRInt16& theType);
protected:
HWND mWnd;
@ -84,6 +86,7 @@ class nsFileWidget : public nsIFileWidget
void GetFilterListArray(nsString& aFilterList);
PRInt16 mSelectedType;
};
#endif // nsFileWidget_h__