moved string utilities from nsWindow to nsMacControl

This commit is contained in:
pierre%netscape.com 1999-04-20 04:02:20 +00:00
Родитель 9bd6d384e9
Коммит bdae78fb85
3 изменённых файлов: 43 добавлений и 6 удалений

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

@ -19,6 +19,7 @@
#include "nsFileWidget.h"
#include "nsStringUtil.h"
#include <StandardFile.h>
#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;

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

@ -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;
}

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

@ -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;