Browse Source

GUI List Box items => plString

Michael Hansen 11 years ago
parent
commit
f370c65ad3
  1. 15
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp
  2. 6
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h
  3. 100
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp
  4. 24
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.h
  5. 97
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.cpp
  6. 18
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.h
  7. 13
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBoxGlue.cpp

15
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp

@ -1152,23 +1152,12 @@ void pfGUIListBoxMod::ClearAllElements( void )
HandleExtendedEvent( pfGUIListBoxMod::kListCleared ); HandleExtendedEvent( pfGUIListBoxMod::kListCleared );
} }
uint16_t pfGUIListBoxMod::AddString( const char *string ) uint16_t pfGUIListBoxMod::AddString( const plString &string )
{ {
return AddElement( new pfGUIListText( string ) ); return AddElement( new pfGUIListText( string ) );
} }
uint16_t pfGUIListBoxMod::AddString( const wchar_t *string ) int16_t pfGUIListBoxMod::FindString( const plString &toCompareTo )
{
return AddElement( new pfGUIListText( string ) );
}
int16_t pfGUIListBoxMod::FindString( const char *toCompareTo )
{
pfGUIListText text( toCompareTo );
return FindElement( &text );
}
int16_t pfGUIListBoxMod::FindString( const wchar_t *toCompareTo )
{ {
pfGUIListText text( toCompareTo ); pfGUIListText text( toCompareTo );
return FindElement( &text ); return FindElement( &text );

6
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h

@ -186,10 +186,8 @@ class pfGUIListBoxMod : public pfGUIControlMod
uint16_t GetNumElements( void ); uint16_t GetNumElements( void );
pfGUIListElement *GetElement( uint16_t idx ); pfGUIListElement *GetElement( uint16_t idx );
uint16_t AddString( const char *string ); uint16_t AddString( const plString &string );
uint16_t AddString( const wchar_t *string ); int16_t FindString( const plString &toCompareTo );
int16_t FindString( const char *toCompareTo );
int16_t FindString( const wchar_t *toCompareTo );
// Export only // Export only
void SetScrollCtrl( pfGUIValueCtrl *ctrl ) { fScrollControl = ctrl; } void SetScrollCtrl( pfGUIValueCtrl *ctrl ) { fScrollControl = ctrl; }

100
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp

@ -77,28 +77,14 @@ void pfGUIListElement::Write( hsStream *s, hsResMgr *mgr )
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
pfGUIListText::pfGUIListText() : pfGUIListElement( kText ) pfGUIListText::pfGUIListText()
: pfGUIListElement(kText), fJustify(kLeftJustify)
{ {
fText = nil;
fJustify = kLeftJustify;
} }
pfGUIListText::pfGUIListText( const char *text ) : pfGUIListElement( kText ) pfGUIListText::pfGUIListText( const plString &text )
: pfGUIListElement(kText), fText(text), fJustify(kLeftJustify)
{ {
fText = hsStringToWString(text);
fJustify = kLeftJustify;
}
pfGUIListText::pfGUIListText( const wchar_t *text ) : pfGUIListElement( kText )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
fJustify = kLeftJustify;
}
pfGUIListText::~pfGUIListText()
{
delete [] fText;
} }
//// Virtuals //////////////////////////////////////////////////////////////// //// Virtuals ////////////////////////////////////////////////////////////////
@ -107,18 +93,14 @@ void pfGUIListText::Read( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Read( s, mgr ); pfGUIListElement::Read( s, mgr );
char *text = s->ReadSafeString(); fText = s->ReadSafeString_TEMP();
fText = hsStringToWString(text);
delete [] text;
} }
void pfGUIListText::Write( hsStream *s, hsResMgr *mgr ) void pfGUIListText::Write( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Write( s, mgr ); pfGUIListElement::Write( s, mgr );
char *text = hsWStringToString(fText); s->WriteSafeString(fText);
s->WriteSafeString(text);
delete [] text;
} }
bool pfGUIListText::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight ) bool pfGUIListText::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight )
@ -158,26 +140,7 @@ int pfGUIListText::CompareTo( pfGUIListElement *rightSide )
if( text->fType != kText ) if( text->fType != kText )
return -2; return -2;
return wcscmp( GetText(), text->GetText() ); return GetText().Compare(text->GetText());
}
void pfGUIListText::SetText( const char *text )
{
wchar_t *wText = hsStringToWString(text);
SetText(wText);
delete [] wText;
}
void pfGUIListText::SetText( const wchar_t *text )
{
delete [] fText;
if( text != nil )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
else
fText = nil;
} }
void pfGUIListText::SetJustify( JustifyTypes justify ) void pfGUIListText::SetJustify( JustifyTypes justify )
@ -295,26 +258,14 @@ int pfGUIListPicture::CompareTo( pfGUIListElement *rightSide )
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
pfGUIListTreeRoot::pfGUIListTreeRoot() : pfGUIListElement( kTreeRoot ) pfGUIListTreeRoot::pfGUIListTreeRoot()
: pfGUIListElement(kTreeRoot), fShowChildren(true)
{ {
fText = nil;
fShowChildren = true;
} }
pfGUIListTreeRoot::pfGUIListTreeRoot( const char *text ) : pfGUIListElement( kTreeRoot ) pfGUIListTreeRoot::pfGUIListTreeRoot( const plString &text )
: pfGUIListElement(kTreeRoot), fText(text)
{ {
fText = hsStringToWString(text);
}
pfGUIListTreeRoot::pfGUIListTreeRoot( const wchar_t *text ) : pfGUIListElement( kTreeRoot )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
pfGUIListTreeRoot::~pfGUIListTreeRoot()
{
delete [] fText;
} }
//// Virtuals //////////////////////////////////////////////////////////////// //// Virtuals ////////////////////////////////////////////////////////////////
@ -323,18 +274,14 @@ void pfGUIListTreeRoot::Read( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Read( s, mgr ); pfGUIListElement::Read( s, mgr );
char *temp = s->ReadSafeString(); fText = s->ReadSafeString_TEMP();
fText = hsStringToWString(temp);
delete [] temp;
} }
void pfGUIListTreeRoot::Write( hsStream *s, hsResMgr *mgr ) void pfGUIListTreeRoot::Write( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Write( s, mgr ); pfGUIListElement::Write( s, mgr );
char *temp = hsWStringToString(fText); s->WriteSafeString(fText);
s->WriteSafeString( temp );
delete [] temp;
} }
bool pfGUIListTreeRoot::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight ) bool pfGUIListTreeRoot::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight )
@ -416,26 +363,7 @@ int pfGUIListTreeRoot::CompareTo( pfGUIListElement *rightSide )
if( text->fType != kTreeRoot ) if( text->fType != kTreeRoot )
return -2; return -2;
return wcscmp( GetTitle(), text->GetTitle() ); return GetTitle().Compare(text->GetTitle());
}
void pfGUIListTreeRoot::SetTitle( const char *text )
{
wchar_t *wText = hsStringToWString(text);
SetTitle(wText);
delete [] wText;
}
void pfGUIListTreeRoot::SetTitle( const wchar_t *text )
{
delete [] fText;
if( text != nil )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
else
fText = nil;
} }
void pfGUIListTreeRoot::AddChild( pfGUIListElement *el ) void pfGUIListTreeRoot::AddChild( pfGUIListElement *el )

24
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.h

@ -118,15 +118,13 @@ class pfGUIListText : public pfGUIListElement
protected: protected:
wchar_t *fText; plString fText;
uint8_t fJustify; // This is not our JustifyTypes, but from plDynamicTextMap uint8_t fJustify; // This is not our JustifyTypes, but from plDynamicTextMap
public: public:
pfGUIListText(); pfGUIListText();
pfGUIListText( const char *text ); pfGUIListText( const plString &text );
pfGUIListText( const wchar_t *text );
virtual ~pfGUIListText();
virtual void Read( hsStream *s, hsResMgr *mgr ); virtual void Read( hsStream *s, hsResMgr *mgr );
virtual void Write( hsStream *s, hsResMgr *mgr ); virtual void Write( hsStream *s, hsResMgr *mgr );
@ -139,9 +137,8 @@ class pfGUIListText : public pfGUIListElement
virtual void SetJustify( JustifyTypes justify ); virtual void SetJustify( JustifyTypes justify );
// These two are virtual so we can derive and override them // These two are virtual so we can derive and override them
virtual const wchar_t *GetText( void ) { return fText; } virtual plString GetText() const { return fText; }
virtual void SetText( const char *text ); virtual void SetText(const plString &text) { fText = text; }
virtual void SetText( const wchar_t *text );
}; };
class pfGUIListPicture : public pfGUIListElement class pfGUIListPicture : public pfGUIListElement
@ -176,7 +173,7 @@ class pfGUIListTreeRoot : public pfGUIListElement
{ {
protected: protected:
wchar_t *fText; plString fText;
bool fShowChildren; bool fShowChildren;
hsTArray<pfGUIListElement *> fChildren; hsTArray<pfGUIListElement *> fChildren;
@ -184,9 +181,7 @@ class pfGUIListTreeRoot : public pfGUIListElement
public: public:
pfGUIListTreeRoot(); pfGUIListTreeRoot();
pfGUIListTreeRoot( const char *text ); pfGUIListTreeRoot( const plString &text );
pfGUIListTreeRoot( const wchar_t *text );
virtual ~pfGUIListTreeRoot();
virtual void Read( hsStream *s, hsResMgr *mgr ); virtual void Read( hsStream *s, hsResMgr *mgr );
virtual void Write( hsStream *s, hsResMgr *mgr ); virtual void Write( hsStream *s, hsResMgr *mgr );
@ -197,11 +192,10 @@ class pfGUIListTreeRoot : public pfGUIListElement
virtual bool MouseClicked( uint16_t localX, uint16_t localY ); virtual bool MouseClicked( uint16_t localX, uint16_t localY );
const wchar_t *GetTitle( void ) { return fText; } const plString GetTitle() const { return fText; }
void SetTitle( const char *text ); void SetTitle(const plString &text) { fText = text; }
void SetTitle( const wchar_t *text );
uint32_t GetNumChildren( void ) const { return fChildren.GetCount(); } uint32_t GetNumChildren() const { return fChildren.GetCount(); }
pfGUIListElement *GetChild( uint32_t i ) const { return fChildren[ i ]; } pfGUIListElement *GetChild( uint32_t i ) const { return fChildren[ i ]; }
void AddChild( pfGUIListElement *el ); void AddChild( pfGUIListElement *el );

97
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.cpp

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

18
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.h

@ -88,15 +88,12 @@ public:
virtual int32_t GetSelection( void ); virtual int32_t GetSelection( void );
virtual void SetSelection( int32_t item ); virtual void SetSelection( int32_t item );
virtual void Refresh( void ); virtual void Refresh( void );
virtual void SetElement( uint16_t idx, const char* text ); virtual void SetElement( uint16_t idx, const plString& text );
virtual void SetElementW( uint16_t idx, std::wstring text );
virtual void RemoveElement( uint16_t index ); virtual void RemoveElement( uint16_t index );
virtual void ClearAllElements( void ); virtual void ClearAllElements( void );
virtual uint16_t GetNumElements( void ); virtual uint16_t GetNumElements( void );
virtual std::string GetElement( uint16_t idx ); virtual plString GetElement( uint16_t idx );
virtual std::wstring GetElementW( uint16_t idx ); virtual int16_t AddString( const plString &string );
virtual int16_t AddString( const char *string );
virtual int16_t AddStringW( std::wstring string );
virtual int16_t AddImage( pyImage& image, bool respectAlpha ); 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 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, 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 SetSwatchSize( uint32_t size );
virtual void SetSwatchEdgeOffset( uint32_t size ); virtual void SetSwatchEdgeOffset( uint32_t size );
virtual void SetStringJustify( uint16_t idx, uint32_t justify); virtual void SetStringJustify( uint16_t idx, uint32_t justify);
virtual int16_t FindString( const char *toCompareTo ); virtual int16_t FindString( const plString &toCompareTo );
virtual int16_t FindStringW( std::wstring toCompareTo );
virtual int16_t AddTextWColor( const char *str, pyColor& textcolor, uint32_t inheritalpha); 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 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 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 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 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 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 AddStringInBox( const plString &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 void ScrollToBegin( void ); virtual void ScrollToBegin( void );
virtual void ScrollToEnd( void ); virtual void ScrollToEnd( void );
virtual void SetScrollPos( int32_t pos ); 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 // 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. // via additional AddBranch() calls. Call CloseBranch() to stop writing elements to that branch.
void AddBranch( const char *name, bool initiallyOpen ); void AddBranch( const plString &name, bool initiallyOpen );
void AddBranchW( std::wstring name, bool initiallyOpen );
void CloseBranch( void ); void CloseBranch( void );
void RemoveSelection( int32_t item ); void RemoveSelection( int32_t item );

13
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBoxGlue.cpp

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

Loading…
Cancel
Save