Index: src/common/paws/pawstextbox.h =================================================================== --- src/common/paws/pawstextbox.h (revision 5649) +++ src/common/paws/pawstextbox.h (working copy) @@ -168,6 +168,7 @@ virtual ~pawsMessageTextBox(); virtual bool Setup( iDocumentNode* node ); virtual bool Setup( void ); + virtual bool PostSetup(); /** * This function allows a widget to fill in its own contents from an xml node @@ -228,6 +229,8 @@ int topLine; pawsScrollBar* scrollBar; + int scrollBarWidth; + bool customScrollBar; private: static const int INITOFFSET = 20; @@ -339,6 +342,7 @@ virtual ~pawsMultiLineTextBox(); bool Setup ( iDocumentNode* node ); + bool PostSetup(); void Draw(); @@ -369,6 +373,7 @@ int maxWidth; int maxHeight; pawsScrollBar* scrollBar; + bool customScrollBar; }; //-------------------------------------------------------------------------- Index: src/common/paws/pawscrollbar.cpp =================================================================== --- src/common/paws/pawscrollbar.cpp (revision 5649) +++ src/common/paws/pawscrollbar.cpp (working copy) @@ -168,7 +168,7 @@ // down button settings csRef downNode = node->GetNode("down"); - if (upNode) + if (downNode) { attr = downNode->GetAttribute("grey"); if (attr) Index: src/common/paws/pawstextbox.cpp =================================================================== --- src/common/paws/pawstextbox.cpp (revision 5649) +++ src/common/paws/pawstextbox.cpp (working copy) @@ -374,6 +374,8 @@ { topLine = 0; maxLines = 0; + scrollBarWidth = 25; + customScrollBar = false; CalcLineHeight(); scrollBar = NULL; } @@ -404,49 +406,42 @@ csRef scrollBarNode = node->GetNode( "pawsScrollBar" ); if ( scrollBarNode ) { - CalcLineHeight(); - - // Create the optional scroll bar here as well but hidden. - scrollBar = new pawsScrollBar; - //TODO: FIGURE OUT WHY THIS FUNCTION DOESN'T SETUP SCROLLBARS CORRECTLY! - //scrollBar->Setup( scrollBarNode ); - scrollBar->SetParent( this ); - + customScrollBar = true; csRef widthAttribute = scrollBarNode->GetAttribute("width"); - int scrollBarWidth = 25; - if(widthAttribute){ + if(widthAttribute) scrollBarWidth = widthAttribute->GetValueAsInt(); - } + } - scrollBar->SetRelativeFrame( defaultFrame.Width() - scrollBarWidth, 6, scrollBarWidth, defaultFrame.Height() - 12 ); - - int attach = ATTACH_TOP | ATTACH_BOTTOM | ATTACH_RIGHT; - scrollBar->SetAttachFlags( attach ); - scrollBar->PostSetup(); - AddChild( scrollBar ); - OnResize(); - return true; - } - else - { - return Setup(); - } + CalcLineHeight(); + + return true; } bool pawsMessageTextBox::Setup() { CalcLineHeight(); + return true; +} +bool pawsMessageTextBox::PostSetup() +{ // Create the optional scroll bar here as well but hidden. - scrollBar = new pawsScrollBar; - scrollBar->SetParent( this ); - scrollBar->SetRelativeFrame( defaultFrame.Width() - 24, 6, 24, defaultFrame.Height() - 12 ); + if (customScrollBar) + scrollBar = dynamic_cast(FindWidget("scrollbar")); + if (!scrollBar) + { + scrollBar = new pawsScrollBar; + scrollBar->SetParent( this ); + scrollBar->PostSetup(); + AddChild( scrollBar ); + + scrollBar->SetTickValue( 1.0 ); + scrollBar->SetMaxValue(0.0); + } + + scrollBar->SetRelativeFrame( defaultFrame.Width() - scrollBarWidth, 6, scrollBarWidth, defaultFrame.Height() - 12 ); int attach = ATTACH_TOP | ATTACH_BOTTOM | ATTACH_RIGHT; scrollBar->SetAttachFlags( attach ); - scrollBar->PostSetup(); - scrollBar->SetTickValue( 1.0 ); - scrollBar->SetMaxValue(0.0); - AddChild( scrollBar ); OnResize(); @@ -1305,6 +1300,7 @@ canDrawLines = 0; maxHeight = 0; maxWidth = 0; + customScrollBar = false; } pawsMultiLineTextBox::~pawsMultiLineTextBox() @@ -1314,20 +1310,48 @@ bool pawsMultiLineTextBox::Setup( iDocumentNode* node ) { - csRef textNode = node->GetNode( "text" ); - + csRef textNode = node->GetNode( "text" ); if ( textNode ) - { + { csRef textAttribute = textNode->GetAttribute("string"); if ( textAttribute ) - { + { SetText( textAttribute->GetValue() ); } - } + } + csRef scrollBarNode = node->GetNode( "pawsScrollBar" ); + if ( scrollBarNode ) + { + customScrollBar = true; + } + return true; } +bool pawsMultiLineTextBox::PostSetup() +{ + if (customScrollBar) + scrollBar = dynamic_cast(FindWidget("scrollbar")); + + if (!scrollBar) + { + scrollBar = new pawsScrollBar(); + scrollBar->SetParent( this ); + AddChild( scrollBar ); + scrollBar->SetTickValue( 1.0 ); + scrollBar->PostSetup(); + } + + scrollBar->SetRelativeFrame( defaultFrame.Width() - 40, 6, 24, defaultFrame.Height() - 12 ); + scrollBar->SetAttachFlags(ATTACH_TOP | ATTACH_BOTTOM | ATTACH_RIGHT); + pawsWidget::Resize(); + + scrollBar->Show(); + scrollBar->SetMaxValue(lines.GetSize() - canDrawLines ); + scrollBar->SetCurrentValue(0); +} + void pawsMultiLineTextBox::Resize() { pawsWidget::Resize(); @@ -1471,22 +1495,12 @@ usingScrollBar = true; lines.Empty(); OrganizeText( str.GetData() ); - if ( !scrollBar ) + if ( scrollBar ) { - // Create the optional scroll bar here as well but hidden. - scrollBar = new pawsScrollBar(); - scrollBar->SetParent( this ); - scrollBar->SetRelativeFrame( defaultFrame.Width() - 40, 6, 24, defaultFrame.Height() - 12 ); - scrollBar->SetAttachFlags(ATTACH_TOP | ATTACH_BOTTOM | ATTACH_RIGHT); - scrollBar->PostSetup(); - scrollBar->SetTickValue( 1.0 ); - AddChild( scrollBar ); - pawsWidget::Resize(); + scrollBar->Show(); + scrollBar->SetMaxValue(lines.GetSize() - canDrawLines ); + scrollBar->SetCurrentValue(0); } - - scrollBar->Show(); - scrollBar->SetMaxValue(lines.GetSize() - canDrawLines ); - scrollBar->SetCurrentValue(0); } startLine = 0; text.Replace( str.GetData() );