1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 19:29:09 +00:00

GUI List Box items => plString

This commit is contained in:
2014-01-11 01:06:59 -08:00
parent 262cc65f57
commit f370c65ad3
7 changed files with 57 additions and 218 deletions

View File

@ -81,12 +81,12 @@ class pfColorListElement : public pfGUIListText
if ( string1 )
{
fString1 = hsStringToWString(string1);
fText = nil;
fText = plString::Null;
}
else
{
fString1 = nil;
fText = L"";
fText = "";
}
fTextColor1 = color1;
if (string2)
@ -105,12 +105,12 @@ class pfColorListElement : public pfGUIListText
{
fString1 = new wchar_t[wcslen(string1)+1];
wcscpy(fString1,string1);
fText = nil;
fText = plString::Null;
}
else
{
fString1 = nil;
fText = L"";
fText = "";
}
fTextColor1 = color1;
if (string2)
@ -132,7 +132,7 @@ class pfColorListElement : public pfGUIListText
{
delete [] fString1;
fString1 = nil;
fText = nil;
fText = plString::Null;
}
if ( fString2 )
delete [] fString2;
@ -287,14 +287,7 @@ class pfListTextInBox : public pfGUIListText
uint32_t fMinHeight;
public:
pfListTextInBox( const char *text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
{
fMinWidth = min_width;
fMinHeight = min_height;
fJustify = pfGUIListText::kCenter;
}
pfListTextInBox( const wchar_t *text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
pfListTextInBox( const plString &text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
{
fMinWidth = min_width;
fMinHeight = min_height;
@ -510,14 +503,7 @@ uint16_t pyGUIControlListBox::GetNumElements( void )
return 0;
}
void pyGUIControlListBox::SetElement( uint16_t idx, const char* text )
{
wchar_t *wText = hsStringToWString(text);
SetElementW(idx,wText);
delete [] wText;
}
void pyGUIControlListBox::SetElementW( uint16_t idx, std::wstring text )
void pyGUIControlListBox::SetElement( uint16_t idx, const plString& text )
{
if ( fGCkey )
{
@ -532,7 +518,7 @@ void pyGUIControlListBox::SetElementW( uint16_t idx, std::wstring text )
{
// if its a text element type then it should be safe to cast it to a pfGUIListText
pfGUIListText* letext = (pfGUIListText*)le;
letext->SetText(text.c_str());
letext->SetText(text);
}
}
}
@ -562,16 +548,7 @@ void pyGUIControlListBox::SetStringJustify( uint16_t idx, uint32_t justify)
}
std::string pyGUIControlListBox::GetElement( uint16_t idx )
{
std::wstring wRetVal = GetElementW(idx);
char *temp = hsWStringToString(wRetVal.c_str());
std::string retVal = temp;
delete [] temp;
return retVal;
}
std::wstring pyGUIControlListBox::GetElementW( uint16_t idx )
plString pyGUIControlListBox::GetElement( uint16_t idx )
{
if ( fGCkey )
{
@ -596,18 +573,10 @@ std::wstring pyGUIControlListBox::GetElementW( uint16_t idx )
}
}
}
return L"";
return "";
}
int16_t pyGUIControlListBox::AddString( const char *string )
{
wchar_t *wString = hsStringToWString(string);
int16_t retVal = AddStringW(wString);
delete [] wString;
return retVal;
}
int16_t pyGUIControlListBox::AddStringW( std::wstring string )
int16_t pyGUIControlListBox::AddString( const plString &string )
{
if ( fGCkey )
{
@ -615,7 +584,7 @@ int16_t pyGUIControlListBox::AddStringW( std::wstring string )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfGUIListText *element = new pfGUIListText( string.c_str() );
pfGUIListText *element = new pfGUIListText(string);
if( fBuildRoots.GetCount() > 0 )
fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element );
return plbmod->AddElement( element );
@ -642,22 +611,14 @@ int16_t pyGUIControlListBox::AddImage( pyImage& image, bool respectAlpha )
}
int16_t pyGUIControlListBox::FindString( const char *toCompareTo )
{
wchar_t *wToCompareTo = hsStringToWString(toCompareTo);
int16_t retVal = FindStringW(wToCompareTo);
delete [] wToCompareTo;
return retVal;
}
int16_t pyGUIControlListBox::FindStringW( std::wstring toCompareTo )
int16_t pyGUIControlListBox::FindString( const plString &toCompareTo )
{
if ( fGCkey )
{
// get the pointer to the modifier
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
return plbmod->FindString(toCompareTo.c_str());
return plbmod->FindString(toCompareTo);
}
return -1;
}
@ -737,7 +698,7 @@ void pyGUIControlListBox::Add2TextWColorW( std::wstring str1, pyColor& textcolor
}
}
int16_t pyGUIControlListBox::AddStringInBox( const char *string, uint32_t min_width, uint32_t min_height )
int16_t pyGUIControlListBox::AddStringInBox( const plString &string, uint32_t min_width, uint32_t min_height )
{
if ( fGCkey )
{
@ -754,23 +715,6 @@ int16_t pyGUIControlListBox::AddStringInBox( const char *string, uint32_t min_wi
return -1;
}
int16_t pyGUIControlListBox::AddStringInBoxW( std::wstring string, uint32_t min_width, uint32_t min_height )
{
if ( fGCkey )
{
// get the pointer to the modifier
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfListTextInBox *element = new pfListTextInBox( string.c_str(), min_width, min_height );
if( fBuildRoots.GetCount() > 0 )
fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element );
return plbmod->AddElement( element );
}
}
return -1;
}
int16_t pyGUIControlListBox::AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha )
{
if ( fGCkey )
@ -927,14 +871,7 @@ void pyGUIControlListBox::Unclickable( void )
}
}
void pyGUIControlListBox::AddBranch( const char *name, bool initiallyOpen )
{
wchar_t *wName = hsStringToWString(name);
AddBranchW(wName,initiallyOpen);
delete [] wName;
}
void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
void pyGUIControlListBox::AddBranch( const plString &name, bool initiallyOpen )
{
if ( fGCkey )
{
@ -942,7 +879,7 @@ void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfGUIListTreeRoot *root = new pfGUIListTreeRoot( name.c_str() );
pfGUIListTreeRoot *root = new pfGUIListTreeRoot(name);
root->ShowChildren( initiallyOpen );
if( fBuildRoots.GetCount() > 0 )

View File

@ -88,15 +88,12 @@ public:
virtual int32_t GetSelection( void );
virtual void SetSelection( int32_t item );
virtual void Refresh( void );
virtual void SetElement( uint16_t idx, const char* text );
virtual void SetElementW( uint16_t idx, std::wstring text );
virtual void SetElement( uint16_t idx, const plString& text );
virtual void RemoveElement( uint16_t index );
virtual void ClearAllElements( void );
virtual uint16_t GetNumElements( void );
virtual std::string GetElement( uint16_t idx );
virtual std::wstring GetElementW( uint16_t idx );
virtual int16_t AddString( const char *string );
virtual int16_t AddStringW( std::wstring string );
virtual plString GetElement( uint16_t idx );
virtual int16_t AddString( const plString &string );
virtual int16_t AddImage( pyImage& image, bool respectAlpha );
virtual int16_t AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha );
virtual int16_t AddImageAndSwatchesInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha,
@ -104,16 +101,14 @@ public:
virtual void SetSwatchSize( uint32_t size );
virtual void SetSwatchEdgeOffset( uint32_t size );
virtual void SetStringJustify( uint16_t idx, uint32_t justify);
virtual int16_t FindString( const char *toCompareTo );
virtual int16_t FindStringW( std::wstring toCompareTo );
virtual int16_t FindString( const plString &toCompareTo );
virtual int16_t AddTextWColor( const char *str, pyColor& textcolor, uint32_t inheritalpha);
virtual int16_t AddTextWColorW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha);
virtual int16_t AddTextWColorWSize( const char *str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize);
virtual int16_t AddTextWColorWSizeW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize);
virtual void Add2TextWColor( const char *str1, pyColor& textcolor1,const char *str2, pyColor& textcolor2, uint32_t inheritalpha);
virtual void Add2TextWColorW( std::wstring str1, pyColor& textcolor1, std::wstring str2, pyColor& textcolor2, uint32_t inheritalpha);
virtual int16_t AddStringInBox( const char *string, uint32_t min_width, uint32_t min_height );
virtual int16_t AddStringInBoxW( std::wstring string, uint32_t min_width, uint32_t min_height );
virtual int16_t AddStringInBox( const plString &string, uint32_t min_width, uint32_t min_height );
virtual void ScrollToBegin( void );
virtual void ScrollToEnd( void );
virtual void SetScrollPos( int32_t pos );
@ -125,8 +120,7 @@ public:
// To create tree branches, call AddBranch() with a name, then add elements as usual, including new sub-branches
// via additional AddBranch() calls. Call CloseBranch() to stop writing elements to that branch.
void AddBranch( const char *name, bool initiallyOpen );
void AddBranchW( std::wstring name, bool initiallyOpen );
void AddBranch( const plString &name, bool initiallyOpen );
void CloseBranch( void );
void RemoveSelection( int32_t item );

View File

@ -136,7 +136,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, setElementW, args)
PyErr_SetString(PyExc_TypeError, "setElementW expects an unsigned short and a unicode string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetElementW(index, text);
self->fThis->SetElement(index, plString::FromWchar(text));
PYTHON_RETURN_NONE;
}
@ -148,7 +148,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElement, args)
PyErr_SetString(PyExc_TypeError, "getElement expects an unsigned short");
PYTHON_RETURN_ERROR;
}
return PyString_FromString(self->fThis->GetElement(index).c_str());
return PyString_FromPlString(self->fThis->GetElement(index));
}
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args)
@ -159,8 +159,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args)
PyErr_SetString(PyExc_TypeError, "getElementW expects an unsigned short");
PYTHON_RETURN_ERROR;
}
std::wstring retVal = self->fThis->GetElementW(index);
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyUnicode_FromStringEx(self->fThis->GetElement(index));
}
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, setStringJustify, args)
@ -195,7 +194,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addStringW, args)
PyErr_SetString(PyExc_TypeError, "addStringW expects a unicode string");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->AddStringW(text));
return PyInt_FromLong(self->fThis->AddString(plString::FromWchar(text)));
}
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findString, args)
@ -217,7 +216,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findStringW, args)
PyErr_SetString(PyExc_TypeError, "findStringW expects a unicode string");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->FindStringW(text));
return PyInt_FromLong(self->fThis->FindString(plString::FromWchar(text)));
}
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addImage, args)
@ -387,7 +386,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addBranchW, args)
wchar_t* name = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, name, strLen);
name[strLen] = L'\0';
self->fThis->AddBranchW(name, initiallyOpen != 0);
self->fThis->AddBranch(plString::FromWchar(name), initiallyOpen != 0);
delete [] name;
PYTHON_RETURN_NONE;
}