329 views
in GUI Development by

Hi

Imagine some sort of toolbox with some buttons inside. You want to use this toolbox on different screens. For simplicity you would like to design this toolbox only once. The screens themselves should be able to decide the content of the toolbox. Not just switching them visible or not. But to define the buttons themselves.

This is what I would like to have done with an the help of an Outline (placing them next to each other). i.e.:

and on another screen:

I would like to be able to make kind of my own Outline with this margin and background and border and fill it with the buttons defined in the "screens".

If I try to make my own control with a Outline iside and define the background and stuff, that would work, but now the Outline is not possible to find siblings of the Owner of the current Owner. So how do I achieve this?

Regards

1 Answer

+1 vote
by
 
Best answer

Hello,

to work correctly, the buttons and the Outline have to exist within the same GUI component. You could do following:

Approach 1 (programmatically):

a.) Implement a generic ToolBox component containing the Outline view and all other ToolBox specific decorations.

b.) Wherever you want the ToolBox to be used embedd an instance of the ToolBox component. Except its decorations, it is empty at this moment.

c.) The buttons, you want to arrange in the ToolBox have to be added directly to the ToolBox instance. Create the button instances dynamically and use the methode Add() of the ToolBox component to add the buttons to it. Depending on the configuration of the Outline view within the ToolBox, the buttons will be arranged horizontally or vertically accoring the order in which you add them. Following is the code how you would add a new button instance to the ToolBox component:

// Create new instance of a button
var YourUnit::YourButton button = new YourUnit::YourButton;

// Configure the button
button.Caption  = "Caption";
button.Icon     = SomeUnit::SomeBitmap;
button.OnAction = SomeSlotMethode;

// Now add the button to the ToolBox component
ToolBox.Add( button, 0 );

Approach 2:

a.) Implement a generic ToolBox component containing the Outline view and all other ToolBox specific decorations.

b.) For every ToolBox variant derive a new class from your ToolBox component. So you will get e.g. an OpenToolBox, EditToolBox, ProjectToolBox, etc. Every ToolBox will be specialized to contain the particular buttons.

c.) Edit and fill the derived classes with all the necessary buttons by Drag&Drop instances of the button components directly in Composer.

d.) In every derived ToolBox class add properties to connect slot methods from the outside of the ToolBox. If the ToolBox has e.g. three buttons (New, Open and Close), add three properties so you can then connect three slot methods with the ToolBox. Assigning a value to the property should store it in the OnAction property of the corresponding button. Accordingly, when the user activates the button 'Open', the button will fire a signal to the slot property assigned previously to the corresponding property in the ToolBox component. This is implemented in OnSet methods corresponding to the property. For example, the property OnOpen would be intended to connect a slot method with the Open button:

if ( value == pure OnOpen )
  return;

pure OnOpen = value;

OpenButton.OnAction = value;

d.) Finally embed instances of the adequate ToolBox class wherever you want the ToolBox to be used. Connect the slot methods to the corresponding properties, so activating the buttons will signal the slot methods.

I hope it helps you further.

Best regards

Paul Banach

 
by

Great, thanks.

I will go with the first approach. For anyone else reading this: Do not forget to set the buttons programatically to be embedded.

button.Embedded = true;

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...