Show TTreeViewItem's Expander button - delphi

I have a FireMonkey application that shows list of items in a TTreeView. Some items represent leaf objects, others represent containers.
My idea is not to pre-load the whole tree at once. I want to add the sub items to containers only after the user clicks on a particular container item.
For this to happen I need to show the user that the corresponding item is a container:
Is there any way to show the expander of a particular TTreeViewItem without adding any subitems using styles, RTTI etc.?
I'm using Delphi XE7.

There's a common trick using a "dummy" node within each unexpanded node. Each node which has items will have just an empty child node. When the user expands that node, check for this dummy node. If it's there, delete it, and then fill in the real items. I'm not exactly sure how similar the tree view is in Firemonkey and VCL, but the concept should work the same.

Related

Creating and Rendering a Custom Container Box and Container Items in C++ Builder/FMX

I am looking into sub-classing a container component to act as a "listbox" container of sub-classed TPanels that are acting as "listitem" members. Basically, my CustomListItems are TPanels that contain some images, labels, and/or other controls. These CustomListItems will be created dynamically and will have dynamic sizes. Their widths shall be equal to that of their parent container, but their heights might differ.
I want my container "listbox" to mostly behave like a standard TListBox, in that it shall be vertically SCROLLABLE, and that the added items shall be stacked on top of each other in the most automatic way possible. For example, doing:
CustomListItem* myCustomListItem = new CustomListItem(this, param1, param2, param3); // this = TOwner
myCustomListItem->Parent = myCustomListBox;
will automatically position the added child TPanel item in the first vacant slot of its CustomListBox container.
What I am seeking is the most standard way for implementing this parent/child, container/contained relationship. I am unsure what container component to sub-class and how to go about this. I am considering two approaches:
Possibly using a TLayout, TGridLayout, or TGridPanelLayout container if it is vertically scrollable and if it will handle rendering/positioning the added child TPanels (my CustomListItems) automatically.
If there is no "easy" or "standard" way to implement the above behavior, I would maybe consider using a plain TVertScrollBox as the "listbox" container, and then custom-handle the positioning and repositioning of the added items "manually".
For the latter approach, what I need is information about which events might trigger the insertion and removal of child items, and how to handle those events properly. For example, I would keep track of added items and their positions relative to the parent container. When new items are inserted, I can then manually handle positioning them correctly in the container. I can do that "internally" by overriding/overloading (not sure) the AddObject method, but I would still need to handle certain events for "external" insertion/removal of objects (e.g: myCustomListItem->Parent = myCustomListBox;)
I hope I made my question clear enough. Any help would be highly appreciated.

Create node in Cypher

I have a query I am working on neo4j making my first queries in Cypher, I noticed that when the graph is generated, when establishing the names of the properties, the generated graph only shows the id, to save this difficulty I noticed that for example for a person node instead of placing the property nom (with this name the problem already mentioned is presented) I put name and in that case if I can see the node, attached image. Why does this happen?
CREATE (Peter:Persona {nombre:'Peter Sagan', fechanac:'26-01-1990', pais:'Slovaquia'})
CREATE (Peter:Person {name:'Peter Sagan', fechanac:'26-01-1990', pais:'Slovaquia'})
I want to be able to establish my own names of nodes and properties and that in the graph view the textual value of the first property appears. How do I do it?
I hope you understand my query from now thank you very much :slight_smile:
The Neo4j Browser UI Guide should be helpful in learning how to use the neo4j browser.
The neo4j browser allows you to change the caption for each node label. If you click the red Persona(1) button at the top of the result panel, you will see several options appear at the bottom, including the available Captions. You can then select the caption you want to use for all Persona nodes.
Click on a node for which node you want to change the view.
Go to the top as shown in the image and click the label
Then you can select the color, size and the caption listed.

Copy a TPanel and all of it's Controls at runtime

Delphi-version5.
I have a file comparison app I am putting together and it has a Left and Right Panel on the main form. Each panel (pnlLeft and pnlRight) has an identical range of Controls and events only separated by name. i.e btnCheckLeft(... and btnCheckRight(... and I am having problems keeping the code changes synched between the two Panels.
I am wondering if I can make a single Panel (on a separate Form) with all of the controls and events and then at runtime, copy it twice, once for the pnlLeft an the other, the pnlRight to the main form. On that single Form, I can manage the coding just the once instead of trying to duplicate everything.
During the process, set the Align and the Event names to apply to each copy as in...
The first copy to the blank main form...
pnlLeft.Align:=alLeft;
pnlLeft.Button1Click(Sender)...
the second copy
pnlRight.Align:=alLeft;
pnlRight.Button1Click(Sender)...
How or is that possible? I think I need a Component of the full Panel, but I am not skilled enough to create a Component of this complexity yet.
I checked this
how to copy all the TLabels parented with a TPanel on delphi to another TPanel?
and this
Duplicating components at Run-Time
but don't think either will do what I need.
Thanks for anything you can help with.
The solution to your problem does not lie in duplicating a control at run time. Instead, design a TFrame object. Put all your panel-specific code on there, including any controls it needs. Then, simply instantiate it twice, and give each one a different name. Then you can refer to LeftPanel.btnCheck and RightPanel.btnCheck.

xxforms:tree view of xforms:select1 control

I am trying to display items retrieved from an XML DB using xforms:select1 control using appearance=xxforms:tree. The items appear collapsed or expanded automatically and the behaviour is not the same for all the items retrieved. I have the following questions regarding xxforms:tree view:
how to make sure this view shows sub-nodes (those expandable/collapsable using +/- icon) as collapsed or expanded always, irrespective of, for example, the no. of nodes covered by the + icon?
how to render select1 with tree appearance without making any of the items hyperlinks?
how to make sure no item is highlighted/selected by default?
...and although the docs say xxforms:menu is also a possible appearance (URL http://www.orbeon.com/orbeon/doc/reference-xforms-extensions#tree), the details are not available...
About which branches of the tree should be open — By default all the nodes leading to selected nodes are open, this so the selected values are all visible. But you can change this default behavior and specify which nodes should be open using the xxforms:open attribute. For more on this, see the section "Controlling which tree nodes are initially open" on Selection Controls. Note that this feature was added in October 2010, so it is not included in Orbeon Forms 3.8, and until Orbeon Forms 3.9 is released, you'll need to get a nightly build for this.
About using links in the tree — At this point, the nodes you can click on in the select1 appearance="xxforms:tree control are rendered as links, so users know that this is something they can click on to make a selection. I assume that you don't want them to show as links because the tree might be "read-only" in your case (for information only, not to make a selection). This isn' supported at this point. As a workaround, you could use CSS to change the pointer and appearance of links in the tree so to users they don't even notice that this those are links.
About the menu appearance — It works very much like the tree appearance. See for instance this example using the menu.

how to set the tabwidth of the listbox portion of a TComboBox in Delphi

You can easily achieve a multicolumn effect in a listbox by setting the TabWidth property of TListbox. For example, http://delphi.about.com/cs/adptips2000/a/bltip1200_3.htm
I need to do the same in the drop down list of a ComboBox, but comboboxes don't publish any TabWidth property.
Any ideas?
In a comment to this answer advising you to owner-draw the list box items you say:
I'm wondering why I must do that when the required functionality already exists on a listbox
A combo box is actually composed of three native child windows - the combo box itself, an embedded edit, and a list box. You can use the GetComboBoxInfo() function to fill a COMBOBOXINFO structure (i.e. a TComboBoxInfo record) with information about the control, and it will return the 3 HWND elements in it. With that you are able to alter the appearance and behaviour of the list box. In principle.
For the list box to use the tab stops it needs to have the LBS_USETABSTOPS style flag set. Unfortunately this can't be turned on later, the list box has to be created with it. So you could use the functionality only if you were able to turn the style flag on for the list box, which is created during the CreateWindowEx() call for the combo box. AFAICS this can only be done by hooking the CreateWindowEx() call itself, identifying the internal call that creates the list box, and altering the passed style. This means runtime modification of code, and not in your executable but in a Windows DLL.
Owner-drawing the list items looks like it would be much easier.
From what I know there is not so simple way as TabWidth here but you can override Paint method and draw it yourself. Looking at listbox and combobox sources may help.

Resources