Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » 603.r9 TreeCtrl etc. repaint optimization [BUG?]-No,feature.ParentCtrl and Ctrl
603.r9 TreeCtrl etc. repaint optimization [BUG?]-No,feature.ParentCtrl and Ctrl [message #1852] Thu, 23 March 2006 09:29 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
try this code:
#include <CtrlLib/CtrlLib.h>

class DirView : public Ctrl {
	Splitter   horz;
	TreeCtrl   tree1;
	ArrayCtrl table;

	Label      label;
	StatusBar  info;
	Array<EditString> edit;
	EditField wnd_edit, path_fld;

public:
	typedef DirView CLASSNAME;

	void OpenDir(int id);
	void CloseDir(int id); 
	void ShowPath();
	DirView();
	~DirView() {;}
};


    
void DirView::CloseDir(int id) {
		tree1.RemoveChildren(id);
	}



void DirView::OpenDir(int id) {
		String path = tree1.Get(id);
		for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next()) {
			String n = ff.GetName();
			if(n != "." && n != "..")
				tree1.Add(id, ff.IsFolder() ? CtrlImg::Dir() : CtrlImg::File(),
				          AppendFileName(path, n), n, ff.IsFolder());
			
		}
			table.Add(id,path);
	}

void DirView::ShowPath() {
		info = ~tree1;
	}


DirView::DirView() {
		path_fld.SetRect(0,0,350,50);
		Add( path_fld.TopPos(10) );
		
		horz.Add(tree1);
		horz.Add(table);
		horz.Add(wnd_edit);
		
		Add(horz.Horz().VSizePos(50,50));
	#ifdef PLATFORM_WIN32
		String dir = String(GetExeFilePath()[0], 1) + ":\\";
	#else
		String dir = "/usr";
	#endif
		tree1.SetRoot(CtrlImg::Dir(), dir);
		
		tree1.MultiSelect();

		tree1.WhenOpen = THISBACK(OpenDir);
		tree1.WhenClose = THISBACK(CloseDir);   

		tree1.WhenCursor = THISBACK(ShowPath);

		tree1.AddFrame(info);
		tree1.Open(0,true);

		table.AddColumnAt(0,"id",10);
		table.AddColumnAt(1,"path",50);
		

}


GUI_APP_MAIN
{	TopWindow w;
    DirView dirview;
    dirview.SizePos();
    w.Add(dirview);
	w.Zoomable().Sizeable().Run();
}

[Updated on: Mon, 01 May 2006 20:21]

Report message to a moderator

Re: 603.r9 TreeCtrl etc. one more repaint optimization bug? [message #1859 is a reply to message #1852] Thu, 23 March 2006 22:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Not a bug - what you requested is what you got.

You are using Ctrl as base for DirView. Ctrl is implicitly opaque, means it has to paint its content.

Add(horz.Horz().VSizePos(50,50));

creates strips at top and bottom - and you never paint them.

Either add a Paint to DirView, or make in trasparent so that TopWindow takes care of painting (by painting standard light-gray background).

As you are here composing several child Ctrls into single bigger one, you migh consider using ParentCtrl as the base class for DirView. The only real difference from Ctrl is that ParentCtrl is transparent by default.

Mirek
Re: 603.r9 TreeCtrl etc. one more repaint optimization bug? [message #1880 is a reply to message #1859] Fri, 24 March 2006 19:31 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Thu, 23 March 2006 21:58

Not a bug - what you requested is what you got.

You are using Ctrl as base for DirView. Ctrl is implicitly opaque, means it has to paint its content.

Add(horz.Horz().VSizePos(50,50));

creates strips at top and bottom - and you never paint them.

Either add a Paint to DirView, or make in trasparent so that TopWindow takes care of painting (by painting standard light-gray background).

As you are here composing several child Ctrls into single bigger one, you migh consider using ParentCtrl as the base class for DirView. The only real difference from Ctrl is that ParentCtrl is transparent by default.

Mirek


Thanks. Great. I was thinking: "Where I could use ParentCtrl..." Smile
Previous Topic: What Label.WhenAction supposed to do? - nothing [PARTLY SOLVED :)]
Next Topic: how to bind or convert Logc positions to int?
Goto Forum:
  


Current Time: Sat May 04 15:04:04 CEST 2024

Total time taken to generate the page: 0.03022 seconds