wxScrooledWindow, Scrollbars messing up? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

wxScrooledWindow, Scrollbars messing up?

Post by lowjoel »

When just shown:
<img src="http://joelsplace.sg/images/Default.PNG">

After attempting to fumble and get the bar:
<img src="http://joelsplace.sg/images/Clicked.PNG">

Here's my code for my ScrolledText control:

Code: Select all

//---------------------------------------------------------------------------
//
// Name:        ctscrolledtext.cpp
// Author:      Joel Low
// Created:     22/10/05 09:16
// Description: ClassTools Scrolled Text window
//
//---------------------------------------------------------------------------

#include "../gui/gui.h"
using namespace std;

ctScrolledText::ctScrolledText() : wxScrolledWindow()
{
}

ctScrolledText::ctScrolledText(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
{
	Create(parent, id, label, pos, size, style, name);
}

void ctScrolledText::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
{
	wxSize newSize = size;
	newSize.x -= 16;
	wxScrolledWindow::Create(parent, id, pos, newSize, style | wxVERTICAL, name);
	
	wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
	newSize.y = -1;
	m_text = new wxStaticText(this, -1, label, pos, newSize, style, name);
	sizer->Add(m_text, 1, wxALL ^ wxBOTTOM | wxEXPAND, 5);
	Wrap(m_text->GetSize().x);
	
	SetSizer(sizer);
	SetScrollRate(0, 13);
}

wxString ctScrolledText::GetLabel()
{
	return m_text->GetLabel();
}

void ctScrolledText::SetLabel(wxString label)
{
	m_text->SetLabel(label);
	m_text->Wrap(GetSize().x);
}

void ctScrolledText::Wrap(int width)
{
	m_text->Wrap(width);
}
Am I messing up somewhere?

Joel
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

You are not recalculating the new virtual size.

I assume when you remove the part you use in the Create method, and also call that from the SetLabel method (where you possibly delete the old controls first) it will work better.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

which part, and call what :? Your post seems confusing
Post Reply