Ended the use of strings to describe files in the file widget API. Made some nsString input parameters const.

This commit is contained in:
mcmullen%netscape.com 1999-05-15 22:50:20 +00:00
Родитель 7b267bbaed
Коммит 501ac5f442
3 изменённых файлов: 24 добавлений и 38 удалений

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

@ -63,6 +63,8 @@ class nsIFileWidget : public nsISupports
public: public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEWIDGET_IID)
/** /**
* Create the file filter. This differs from the standard * Create the file filter. This differs from the standard
* widget Create method because it passes in the mode * widget Create method because it passes in the mode
@ -74,7 +76,7 @@ public:
* *
*/ */
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget *aParent,
nsString& aTitle, const nsString& aTitle,
nsFileDlgMode aMode, nsFileDlgMode aMode,
nsIDeviceContext *aContext = nsnull, nsIDeviceContext *aContext = nsnull,
nsIAppShell *aAppShell = nsnull, nsIAppShell *aAppShell = nsnull,
@ -103,14 +105,6 @@ public:
virtual PRBool Show() = 0; virtual PRBool Show() = 0;
/**
* Get the file or directory including the full path.
*
* @param aFile on exit it contains the file or directory selected
*/
NS_IMETHOD GetFile(nsString& aFile) = 0;
/** /**
* Get the nsFileSpec for the file or directory. * Get the nsFileSpec for the file or directory.
* *
@ -127,7 +121,7 @@ public:
* @return void * @return void
* *
*/ */
NS_IMETHOD SetDefaultString(nsString& aString) = 0; NS_IMETHOD SetDefaultString(const nsString& aString) = 0;
/** /**
* Set the directory that the file open/save dialog initially displays * Set the directory that the file open/save dialog initially displays
@ -136,7 +130,7 @@ public:
* @return void * @return void
* *
*/ */
NS_IMETHOD SetDisplayDirectory(nsString& aDirectory) = 0; NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory) = 0;
/** /**
* Get the directory that the file open/save dialog was last displaying * Get the directory that the file open/save dialog was last displaying
@ -145,22 +139,22 @@ public:
* @return void * @return void
* *
*/ */
NS_IMETHOD GetDisplayDirectory(nsString& aDirectory) = 0; NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory) = 0;
virtual nsFileDlgResults GetFile( virtual nsFileDlgResults GetFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
virtual nsFileDlgResults GetFolder( virtual nsFileDlgResults GetFolder(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
virtual nsFileDlgResults PutFile( virtual nsFileDlgResults PutFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
}; };

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

@ -57,7 +57,7 @@ NS_IMETHODIMP nsFileWidget::Create(nsIWidget *aParent,
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP nsFileWidget:: Create(nsIWidget *aParent, NS_IMETHODIMP nsFileWidget:: Create(nsIWidget *aParent,
nsString& aTitle, const nsString& aTitle,
nsFileDlgMode aMode, nsFileDlgMode aMode,
nsIDeviceContext *aContext, nsIDeviceContext *aContext,
nsIAppShell *aAppShell, nsIAppShell *aAppShell,
@ -461,13 +461,6 @@ NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsStri
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP nsFileWidget::GetFile(nsString& aFile)
{
aFile.SetLength(0);
aFile.Append(mFile);
return NS_OK;
}
NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile)
{ {
aFile = mFileSpec; aFile = mFileSpec;
@ -480,7 +473,7 @@ NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile)
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP nsFileWidget::SetDefaultString(nsString& aString) NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString)
{ {
mDefault = aString; mDefault = aString;
return NS_OK; return NS_OK;
@ -491,7 +484,7 @@ NS_IMETHODIMP nsFileWidget::SetDefaultString(nsString& aString)
// Set the display directory // Set the display directory
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsFileWidget::SetDisplayDirectory(nsString& aDirectory) NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory)
{ {
mDisplayDirectory = aDirectory; mDisplayDirectory = aDirectory;
return NS_OK; return NS_OK;
@ -503,7 +496,7 @@ NS_METHOD nsFileWidget::SetDisplayDirectory(nsString& aDirectory)
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsFileWidget::GetDisplayDirectory(nsString& aDirectory) NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory)
{ {
aDirectory = mDisplayDirectory; aDirectory = mDisplayDirectory;
return NS_OK; return NS_OK;
@ -512,7 +505,7 @@ NS_METHOD nsFileWidget::GetDisplayDirectory(nsString& aDirectory)
nsFileDlgResults nsFileWidget::GetFile( nsFileDlgResults nsFileWidget::GetFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, const nsString & promptString,
nsFileSpec & theFileSpec) nsFileSpec & theFileSpec)
{ {
Create(aParent, promptString, eMode_load, nsnull, nsnull); Create(aParent, promptString, eMode_load, nsnull, nsnull);
@ -527,7 +520,7 @@ nsFileDlgResults nsFileWidget::GetFile(
nsFileDlgResults nsFileWidget::GetFolder( nsFileDlgResults nsFileWidget::GetFolder(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, const nsString & promptString,
nsFileSpec & theFileSpec) nsFileSpec & theFileSpec)
{ {
Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); Create(aParent, promptString, eMode_getfolder, nsnull, nsnull);
@ -542,7 +535,7 @@ nsFileDlgResults nsFileWidget::GetFolder(
nsFileDlgResults nsFileWidget::PutFile( nsFileDlgResults nsFileWidget::PutFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, const nsString & promptString,
nsFileSpec & theFileSpec) nsFileSpec & theFileSpec)
{ {
Create(aParent, promptString, eMode_save, nsnull, nsnull); Create(aParent, promptString, eMode_save, nsnull, nsnull);

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

@ -60,7 +60,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget
// nsIFileWidget interface // nsIFileWidget interface
NS_IMETHOD Create(nsIWidget *aParent, NS_IMETHOD Create(nsIWidget *aParent,
nsString& aTitle, const nsString& aTitle,
nsFileDlgMode aMode, nsFileDlgMode aMode,
nsIDeviceContext *aContext = nsnull, nsIDeviceContext *aContext = nsnull,
nsIAppShell *aAppShell = nsnull, nsIAppShell *aAppShell = nsnull,
@ -68,29 +68,28 @@ class nsFileWidget : public nsWindow, public nsIFileWidget
void *aInitData = nsnull); void *aInitData = nsnull);
virtual PRBool Show(); virtual PRBool Show();
NS_IMETHOD GetFile(nsString& aFile);
NS_IMETHOD GetFile(nsFileSpec& aFile); NS_IMETHOD GetFile(nsFileSpec& aFile);
NS_IMETHOD SetDefaultString(nsString& aString); NS_IMETHOD SetDefaultString(const nsString& aString);
NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,
const nsString aTitles[], const nsString aTitles[],
const nsString aFilters[]); const nsString aFilters[]);
NS_IMETHOD GetDisplayDirectory(nsString& aDirectory); NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory);
NS_IMETHOD SetDisplayDirectory(nsString& aDirectory); NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory);
virtual nsFileDlgResults GetFile( virtual nsFileDlgResults GetFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec); // Populate with initial path for file dialog nsFileSpec & theFileSpec); // Populate with initial path for file dialog
virtual nsFileDlgResults GetFolder( virtual nsFileDlgResults GetFolder(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec); // Populate with initial path for file dialog nsFileSpec & theFileSpec); // Populate with initial path for file dialog
virtual nsFileDlgResults PutFile( virtual nsFileDlgResults PutFile(
nsIWidget * aParent, nsIWidget * aParent,
nsString & promptString, // Window title for the dialog const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec); // Populate with initial path for file dialog nsFileSpec & theFileSpec); // Populate with initial path for file dialog
@ -113,7 +112,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget
const nsString* mTitles; const nsString* mTitles;
const nsString* mFilters; const nsString* mFilters;
nsString mDefault; nsString mDefault;
nsString mDisplayDirectory; nsFileSpec mDisplayDirectory;
nsFileSpec mFileSpec; nsFileSpec mFileSpec;
nsFileDlgResults mSelectResult; nsFileDlgResults mSelectResult;