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  |
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 410 times)
[Updated on: Tue, 29 December 2015 08:10] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: Tree-Grid-Widget [message #45515 is a reply to message #45513] |
Thu, 26 November 2015 14:49   |
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 #45594 is a reply to message #45576] |
Sat, 12 December 2015 15:09   |
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: TreeGrid Control - Update 6 [message #45758 is a reply to message #45757] |
Sat, 02 January 2016 16:58   |
Novo
Messages: 1432 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 #45802 is a reply to message #45765] |
Thu, 07 January 2016 07:14   |
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 
|
|
|
|
|
|
| Re: TreeGrid Control - Update 6 [message #45806 is a reply to message #45802] |
Fri, 08 January 2016 04:28   |
Novo
Messages: 1432 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 #45833 is a reply to message #45827] |
Mon, 11 January 2016 15:08   |
 |
koldo
Messages: 3460 Registered: August 2008
|
Senior Veteran |
|
|
Hello slashupp
You have included in the zip just the demo but not the library. Please send the last version of the library.
Checking the code there are many things to be U++-ized:
- Sometimes it is used Upp::String and others std::string
- Loop indentation (for, if, while) is different
- Some function names does not begin with capital letter
- Some variable names does not begin with lower letter
- There is no space before/after "=", "==", "?", ":"
If you want I can do the changes for you.
Best regards
Iñaki
[Updated on: Mon, 11 January 2016 15:08] Report message to a moderator
|
|
|
|
| Re: TreeGrid Control - Update 6 [message #45837 is a reply to message #45833] |
Tue, 12 January 2016 07:58   |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
I attached TreeGrid.zip - contains treegrid as upp-project, hope that's what you meant with 'library'?
I used std::string mainly for expedience and knowing it better than String, using the latter where Upp-functions needs it, again for expedience.
Re: indentation, names (caps/lower-case, variables), spaces/spacing - is there a Upp-standards document you can point me too please?
Quote:If you want I can do the changes for you.
That would be very kind, and if you can put a copy of the fixed sources here so I can do comparison with mine and use as reference.
PS: Just an explanation for what you see in my source-code:
My personal 'standards' for coding are applied at the end when the code nears release(able)-status; before then I use the RAD-technique of Evolutionary Development (some-what similar to 'agile') and do not worry much about standards & style, the purpose being to test my algorithms and earliest detection of design issues, also: everything is public using structs or globals at the start, only later as things clarify do I convert them to classes and templates as needed; I use CamelCaseNames names for public properties and lower_case_with_underscores for private ones - I find for me this works better than any other standards-scheme I've encountered, and I try to let the names be 'documentation' as well; also differentiation between methods and attributes is a gray area, especially with the up-comming dot-operator (operator.()) which is going to cause all kinds of havoc...
-
Attachment: TreeGrid.zip
(Size: 15.37KB, Downloaded 344 times)
|
|
|
|
|
|
|
|
|
|
|
|
| Re: TreeGrid Control - Update 6 [message #45850 is a reply to message #45847] |
Wed, 13 January 2016 13:23   |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
hi koldo
I spotted one error: Cell::operator=(..) - return-type should be void not Cell&
Did you do a global replace of size_t with int? Why? I'm a bit baffled by this. I know that I sometimes rely on size_t being always >= 0 ... can't remember if I do in this code, more likely than not.
<s>I do use STL quite a lot - mainly because I know it well enough and also because I write modules that I can re-use in non-Upp apps/environments. For the treegrid-package I removed those modules, but you'll find some of them in the sfm-package as an example. As for Upp::String, Upp::Vector, Upp::others.. I'm fine with using them in Upp-UI-environment, but elsewhere?-the jury is still out on that. (on this topic: I normally delete the line "using namespace Upp;" and use Upp::.. - it is the better/conventional practice and it gives back those nice names Upp has used )</s>
edit:
needed to write a custom editor & had to use unicode extensively, and then I found that the String and LineEdit classes already
does everything I need - having had a look at what is required to implement unicode compliance from scratch I can now
truly appreciate the effort that went into creating these classes - so I guess the jury came back all positive for the Upp::*classes
(also am realizing how mush effort & time I wasted on reinventing stuff)
Will soonish republish the refactored ctrl here
[Updated on: Wed, 01 November 2017 12:07] Report message to a moderator
|
|
|
|
|
|
| Re: TreeGrid Control - Update 6 [message #46811 is a reply to message #45512] |
Tue, 16 August 2016 09:30  |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
if anyone is looking at the sfm package, just this:
the way to use lambdas as callbacks has changed (for the better!)
on line 697 [dircontent.cpp][void DirContent::OnCustomize(Bar &bar)]
old code:
bar.Add("Expandable nodes first",
Callback(lambda([&]{ custom.exd=EXD_FIRST;
Pan.SelectNTBN('T');
custom.bdirty=true;
TG.ListExpandingNodes(custom.exd);
WhenCustomized(); })));
change this to:
bar.Add("Expandable nodes first", [&]{ custom.exd=EXD_FIRST;
Pan.SelectNTBN('T');
custom.bdirty=true;
TG.ListExpandingNodes(custom.exd);
WhenCustomized(); });
as well as for the other entries below it.
|
|
|
|
Goto Forum:
Current Time: Thu Jun 18 15:21:01 GMT+2 2026
Total time taken to generate the page: 0.01712 seconds
|