diff --git a/widget/src/mac/nsFileWidget.cpp b/widget/src/mac/nsFileWidget.cpp index 20f6d15c29bc..cf7a62e1ebaf 100644 --- a/widget/src/mac/nsFileWidget.cpp +++ b/widget/src/mac/nsFileWidget.cpp @@ -19,6 +19,7 @@ #include "nsFileWidget.h" #include "nsStringUtil.h" #include +#include "nsMacControl.h" #include "nsFileSpec.h" @@ -147,8 +148,8 @@ PRBool nsFileWidget::Show() Str255 title; Str255 defaultName; - StringToStr255(mTitle,title); - StringToStr255(mDefault,defaultName); + nsMacControl::StringToStr255(mTitle,title); + nsMacControl::StringToStr255(mDefault,defaultName); FSSpec theFile; PRBool userClicksOK = PR_FALSE; diff --git a/widget/src/mac/nsMacControl.cpp b/widget/src/mac/nsMacControl.cpp index 4bf5e1705958..c7c9b8992189 100644 --- a/widget/src/mac/nsMacControl.cpp +++ b/widget/src/mac/nsMacControl.cpp @@ -314,6 +314,37 @@ void nsMacControl::SetupMacControlFont() fontStyleRec.style = theStyle.tsFace; ::SetControlFontStyle(mControl, &fontStyleRec); } - - +#pragma mark - + +//------------------------------------------------------------------------- +// +// +//------------------------------------------------------------------------- + +void nsMacControl::StringToStr255(const nsString& aText, Str255& aStr255) +{ + char buffer[256]; + + aText.ToCString(buffer,255); + + PRInt32 len = strlen(buffer); + memcpy(&aStr255[1],buffer,len); + aStr255[0] = len; +} + +//------------------------------------------------------------------------- +// +// +//------------------------------------------------------------------------- + +void nsMacControl::Str255ToString(const Str255& aStr255, nsString& aText) +{ + char buffer[256]; + PRInt32 len = aStr255[0]; + + memcpy(buffer,&aStr255[1],len); + buffer[len] = 0; + + aText = buffer; +} diff --git a/widget/src/mac/nsMacControl.h b/widget/src/mac/nsMacControl.h index ff5d7c771ed5..49ca39f503e7 100644 --- a/widget/src/mac/nsMacControl.h +++ b/widget/src/mac/nsMacControl.h @@ -50,6 +50,11 @@ public: NS_IMETHOD Show(PRBool aState); NS_IMETHODIMP SetFont(const nsFont &aFont); + // Mac string utilities + // (they really should be elsewhere but, well, only the Mac controls use them) + static void StringToStr255(const nsString& aText, Str255& aStr255); + static void Str255ToString(const Str255& aStr255, nsString& aText); + protected: NS_METHOD CreateOrReplaceMacControl(short inControlType); @@ -63,8 +68,8 @@ protected: PRInt32 mValue; PRInt32 mMin; PRInt32 mMax; - ControlHandle mControl; - short mControlType; + ControlHandle mControl; + short mControlType; nsString mLastLabel; nsRect mLastBounds;