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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » TreeGrid Control - Update 6
TreeGrid Control - Update 6 [message #45512] Thu, 26 November 2015 12:53 Go to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
Hope someone will find the attached control useful.
The control seems fairly stable & release-ready...(feedback please)
If you check it out, please let me know what you think, and also any bugs, improvements, etc ...

Update 6:
Improved control: Show/Hide treelines & header
Small changes to Demo (added options to R-click menu)
Bug fixes and improved useability of the simple file manager (Linux-only)

The 'TG6.zip' file contains all three projects.

Usage Example

1. Add the TreeGrid package to your project.
2. Add: #include <TreeGrid/treegrid.h> to your source-file.
3. Example:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#include <TreeGrid/treegrid.h>

struct MyClass : public TopWindow 
{
	typedef MyClass CLASSNAME;
	TreeGrid TG;
	MyClass();
	virtual ~MyClass() {}
};

MyClass::MyClass()
{
	Title("MyClass");
	SetRect(0,0,600,600);
	Sizeable();

	Add(TG.HSizePos().VSizePos());

	TG.AddColumn("Column 1", 200).Sorting();
	TG.AddColumn("Column 2", 200);
	TG.AddColumn("Column 3", 200);

	//indentation is just for readability..
	//AddNode can fail in two cases: a supplied key is already used, and when out-of-memory
	Node N=TG.AddNode(0, "tree-label (column 1-cell)", /*0 => at root of tree */
                             "key (if you want one)", 
                             "column2-cell", 
                             "column3-cell");
                         
		TG.AddNode(N, "tree sub-node label", /*N => parent of new node*/
                              "", /*empty user-key - keys are auto-generated if empty*/
                              "col2-cell", 
                              "col3-cell");

		TG.AddNode(N, "sub label1", 
                              "", 
                              "col2-cell", 
                              "col3-cell"); 

		TG.AddNode(N, "sub label2"); /*no key and you can have blank values*/
			//must give key (even empty string) if you want values
			//empty cells corresponding to the columns will be silently created

	N=TG.AddNode(0, "another tree-label", 
                        "", 
                        "cell2", 
                        "cell3", 
                        "cell4 - you can have extra cells for private data");

		TG.AddNode(N, "tree sub-node label", "", "col2-cell", "col3-cell");

		Node N1=TG.AddNode(N, "tree sub-node label", "", "col2-cell", "col3-cell");

			TG.AddNode(N1, "node n1", "", "value", "value");

		TG.AddNode(N, "A Label", "", "col2-cell", "col3-cell");

	TG.RefreshTreeGrid();
}

GUI_APP_MAIN
{
	MyClass().Run();
}


  • Attachment: TG6.zip
    (Size: 63.49KB, Downloaded 280 times)

[Updated on: Tue, 29 December 2015 08:10]

Report message to a moderator

Re: Tree-Grid-Widget [message #45513 is a reply to message #45512] Thu, 26 November 2015 13:57 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Hi!

I did a quick test and was not able to compile the sample. A few observations:

1. srandom and random are POSIX functions, so it will not run on Windows. I'm not sure exactly how rich U++'s random number generation is, but I remember having seen support for random numbers somewhere...
2. C++11x more advanced features, like variadic templates might be a bit of an overkill for widgets Smile.
3. It is kind of a custom for U++ packages to be achieved in their respective folder, together with the project file.

I'll gladly test it again if it is compilable under Windows.
Re: Tree-Grid-Widget [message #45514 is a reply to message #45513] Thu, 26 November 2015 14:13 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3372
Registered: August 2008
Senior Veteran
Quote:
1. srandom and random are POSIX functions, so it will not run on Windows. I'm not sure exactly how rich U++'s random number generation is, but I remember having seen support for random numbers somewhere...
You may try one of these U++ functions:
dword Random()
qword Random64()
double Randomf()


Best regards
Iñaki
Re: Tree-Grid-Widget [message #45515 is a reply to message #45513] Thu, 26 November 2015 14:49 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
Thx for feedback. I did look for the Upp random()-func's - new they were there- but not hard enough I suppose Thx koldo.

I don't have Windows available, purely Linux, so I cannot test for Windows compatability.
I tried to stay with standard functions but some POSIX things may have slipped through.


Edit: Updated demo-and-control attachment in original message

[Updated on: Fri, 27 November 2015 09:39]

Report message to a moderator

Re: Tree-Grid-Widget [message #45576 is a reply to message #45515] Mon, 07 December 2015 10:23 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Hmmm, interesting control.

And it compiles fine now.

But you may wish to add the TreeGrid package as a dependency to the ThreeGridDemo package.

One note though: the control is very slow on my system. Takes second for a tree node to open.
Re: Tree-Grid-Widget [message #45594 is a reply to message #45576] Sat, 12 December 2015 15:09 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx
I am busy cleaning-up and "upp-ising" the source (getting rid of most of the STL replacing with Upp equivalents),
and also doing some refactoring, optimizing and quite a few bug-fixes ...

Also wrote a simple file-manager (Linux-only) to help test the control (along with the demo).

[Updated on: Tue, 29 December 2015 08:14]

Report message to a moderator

Re: Tree-Grid-Widget - Update 3 [message #45673 is a reply to message #45512] Mon, 21 December 2015 09:03 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
updated (3)
Re: Tree-Grid-Widget - Update 4 [message #45693 is a reply to message #45512] Tue, 22 December 2015 14:46 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
update 4
fixed bugs in sfm
& some other odds & ends

[Updated on: Wed, 23 December 2015 09:45]

Report message to a moderator

Re: TreeGrid Control - Update 6 [message #45716 is a reply to message #45512] Tue, 29 December 2015 08:16 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
Update 6 - I think the control is now release-ready ...
Re: TreeGrid Control - Update 6 [message #45738 is a reply to message #45512] Thu, 31 December 2015 15:20 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
improved simple file manager
  • Attachment: sfm.zip
    (Size: 42.38KB, Downloaded 229 times)
Re: TreeGrid Control - Update 6 [message #45753 is a reply to message #45738] Fri, 01 January 2016 22:56 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3372
Registered: August 2008
Senior Veteran
Hello slashupp

There are some errors when compiling in Windows:

treegrid.cpp, line 134
char s[n]; while (i<n) s[i++]=0;
MSC does not like arrays with variable dimension

treegrid.h, line 141
Column& Sorting(Gate2<const Node&, const Node&> sortfunc=nullptr);
error: could not convert 'nullptr' from 'std::nullptr_t' to 'Upp::Gate2<NodeData* const&, NodeData* const&>

sfm/main.cpp can only be compiled in Linux


Best regards
Iñaki
Re: TreeGrid Control - Update 6 [message #45757 is a reply to message #45753] Sat, 02 January 2016 11:30 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx koldo

seems I'll have to get a copy of windows from somewhere to test/repair this and whatever else ...

is it possible to temporarily install windows on a stand-alone box without any internet connection?
(I will _never_ allow this spyware to connect to my local network)

Re: TreeGrid Control - Update 6 [message #45758 is a reply to message #45757] Sat, 02 January 2016 16:58 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1363
Registered: December 2006
Ultimate Contributor
slashupp wrote on Sat, 02 January 2016 05:30

is it possible to temporarily install windows on a stand-alone box without any internet connection?


Try to install Wine on Linux. It is a Windows emulator. It is not using anything native from Windows.


Regards,
Novo
Re: TreeGrid Control - Update 6 [message #45765 is a reply to message #45753] Sun, 03 January 2016 10:48 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3372
Registered: August 2008
Senior Veteran
Some proposals

Quote:
treegrid.cpp, line 134
char s[n]; while (i<n) s[i++]=0;
MSC does not like arrays with variable dimension

You can just replace char s[n] with Buffer<char> s(n);

Quote:
treegrid.h, line 141
Column& Sorting(Gate2<const Node&, const Node&> sortfunc=nullptr);
error: could not convert 'nullptr' from 'std::nullptr_t' to 'Upp::Gate2<NodeData* const&, NodeData* const&>

Could you replace std::nullptr_t with U++ Null?

Quote:
sfm/main.cpp can only be compiled in Linux

This because main.cpp uses Linux includes. This could be solved by just putting U++ includes.


Best regards
Iñaki
Re: TreeGrid Control - Update 6 [message #45802 is a reply to message #45765] Thu, 07 January 2016 07:14 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx koldo

I've started putting #ifdefs into my sources and your suggestions are really useful

I know Wine exists, have never used it (some research coming my way..)
Some questions:
- I assume I can install Upp for Windows under Wine (else you would not have suggested Wine)
- what do I use for compiler/linker - are they bundled with Wine, Upp, ??
- if my Upp-apps run in Wine can I safely assume they are OK for Windows?
- are there any other Upp-developers using Wine this way that can give me pointers/warn about 'gotcha's'?
If this works it'll be brilliant!

PS: Concerning Windows itself: insecurities, calling home, unasked/automatic
updating, ... and add that you can call the americans many things, but stupid
is not one of them, and I will not believe anybody that says Microsoft
is not in bed with the NSA. I don't have anything to hide, but I feel using
Windows is like inviting a peeping-tom in, or exposing yourself in public Wink


Re: TreeGrid Control - Update 6 [message #45805 is a reply to message #45802] Thu, 07 January 2016 19:04 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3372
Registered: August 2008
Senior Veteran
Hello slashupp

I would like to use only Linux but my final customers require me to supply Windows exes Rolling Eyes

Anyway please adapt the "Linux" areas of your code to U++, upload your code here or to Bazaar and I can fix for you all the rest of pending details using portable U++ code Smile .


Best regards
Iñaki
Re: TreeGrid Control - Update 6 [message #45806 is a reply to message #45802] Fri, 08 January 2016 04:28 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1363
Registered: December 2006
Ultimate Contributor
slashupp wrote on Thu, 07 January 2016 01:14

- I assume I can install Upp for Windows under Wine (else you would not have suggested Wine)

Yes, that is correct.
slashupp wrote on Thu, 07 January 2016 01:14

- what do I use for compiler/linker - are they bundled with Wine, Upp, ??
If this works it'll be brilliant!

You need to install a Microsoft Windows SDK.
SDKs include compilers, headers and libraries.
slashupp wrote on Thu, 07 January 2016 01:14

- if my Upp-apps run in Wine can I safely assume they are OK for Windows?

Yes, Wine is a subset of Windows. If your apps works with Wine it will work in Windows. Wine is just a loader of COFF executables and reimplementation of a million of different Windows DLLs.
slashupp wrote on Thu, 07 January 2016 01:14

- are there any other Upp-developers using Wine this way that can give me pointers/warn about 'gotcha's'?

Wine usually doesn't support latest .NET versions, latest D3Dxx API's, and so on. If an SDK installed uses unsupported .NET version, then you can have problems, but you can always install an older version of SDK.


Regards,
Novo
Re: TreeGrid Control - Update 6 [message #45807 is a reply to message #45512] Fri, 08 January 2016 09:07 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
@koldo: will do as much as I can, may take a few days though..
@Novo: thx, this is excellent!

Have installed ubuntu 15.10 in a VirtualBox VM, and is now installing Wine
following the guidelines on http://wiki.winehq.org/Ubuntu

Will then figure out how to install Upp, windows sdk, etc

umm.. koldo, add a day or two ...

(have always been worried that the big market for apps is on windows
and now I'll have access to that market without compromising my computer Smile)
Re: TreeGrid Control - Update 6 [message #45811 is a reply to message #45765] Sun, 10 January 2016 07:03 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
Quote:
You can just replace char s[n] with Buffer<char> s(n);


Nope - can't be handled with sprintf: easiest to just use s[50] - the 50 is enough to accommodate '%llu'-size


Quote:
Could you replace std::nullptr_t with U++ Null?


Nope - compiler complaint is for the type, not the value. Need to remove the default '=nullptr'
like this:
 //treegrid.h line 141:
	...
	Column& Sorting(); // <<<--- add this
	Column& Sorting(Gate2<const Node&, const Node&> sortfunc); // <<<--- remove =nullptr


and in treegrid.cpp line 41:
	//add this:
	Column& Column::Sorting()
	{
		b_sort=true;
		return *this;
	}


this is just a quick-fix for the problem.
Re: TreeGrid Control - Update 6 [message #45812 is a reply to message #45807] Sun, 10 January 2016 07:19 Go to previous messageGo to previous message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member

U15.10 - loads of difficulties to get wine working with 32-bit apps...
result:
yet-another-vm - U14.04 32-bit
this works, got wine going, installed upp-mingw+toolchain, addressbook-app worked "out-of-the-box" Smile
then copied TreeGrid in and tested - works Smile
now need to install Visual Studio-stuff ...

NB: ultimatepp-home-page: the 'Windows Vista SDK'-link should be 'https...' not http...
Previous Topic: с++ low-level
Next Topic: simmxtools v0.1
Goto Forum:
  


Current Time: Sat Jun 15 16:55:33 CEST 2024

Total time taken to generate the page: 0.02369 seconds