I'm developing a UI using wxWidgets. I'm working with Visual Studio 2010 C++ Express.
My UI consists of 7 vertical grids and 1 horizontal grid which envelopes this 7. In each of these 7 grids, I have 2 or 3 bitmap buttons which are relatively ordered according to each other and neighbor grid boundaries. I set the main horizontal grid as sizer to the panel.
I want that these 7 grids always take place in the "middle" of my panel; which means: With every size adjustment, their coordinates should be recalculated and buttons should move to their newly calculated locations.
Is it possible to do this size adjustment with wxWidgets? I checked on the documentation and samples, but I couldn't find a simple example for my problem.
Thanks.
Write a resize event handler which recalculates the positions of the buttons and moves them to their new locations.
void myWindow::OnResize( wxSizeEvent& event )
{
wxSize sz = event.GetSize();
// calculate new positions
...
// move buttons to new locations
myButton->Move( x, y )'
}
Related
I am trying to create dashboard edit mode grid with gridstack javscript library.
Here is what I am trying to accomplish which is similar to this Databox platform. This is what it looks like when you edit any of the dashboard to view/edit it in grid mode.
So when I drag the blue border handle and scale the div(or even move with cursor hand) then the around grid(which is background layer with absolute position in reality) is automatically adjusted to match the corresponding div. Like this.
Even if there are multiple widgets there, resizing is working everything perfectly fine.
e.g. if there was any sibling widget then resizing this widget would also resize the sibling widget but can not go beyong 1 * 1 grid which is smallest size there.
Even after resizing both widgets, the background static grid boxes (with yellow border) fills the remaining vacant space similar to what is the concept of dense packing algorithm in css grid.
They are removed when widget is grown and added when it is shrinked.
As it seems super complicated to achieve this, is there any default feature like this with grid-stack library?
I'm using Xamarin, writing for iOS.
I'm trying to make keyboard view with numbers,
it will be 4x4.
How can I make that 4 buttons in line will be same width depending on screen width?
Edit: Seems like it can be done that way: make layout with hardcoded height, and width constraints calculate in runtime.
I have done my own version of the PropertyCross Demo (provided in their demo section).
The problem I currently face is the size of the "Recent Search" area. While I have a non-scrollable container, I can easily define the preferred height. As the Box Layout adheres to the preferred size, all is well, with the little issue of not being able to scroll it and see more than one result:
recentSearchContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); recentSearchContainer.setPreferredH((int)(this.getContentPane().getHeight() * 0.1f));
Once I set the container to scrollable, the preferred height gets overwritten and takes up as much space as it needs, taking too much space from the BorderLayout Center piece above it.
How to manipulate the preferred size of scrollable components?
You don't manipulate the preferred size. Scrollables take up more space so if you need them to take up a specific amount of space you need to use the right type of layout which in this case might not be border layout...
Border layout gives NORTH/SOUTH elements their preferred height which might not be what you want. You might want a grid layout which will divide the height 50/50. You might want a table layout where you can define the height in percentages etc.
For those who are interested, here is the solution:
Setup a table layout with a single column and as many rows as you need (similar to box layout y axis or border layout which only north, center and south).
Set the table layout to non-scrollable so it defaults to 100% of your screen.
add the components with height % of the screen they should take up.
those components can be scrollable and will still stick to the height constraint!
// inside a form object, setup the layout
TableLayout tl = new TableLayout(3, 1);
tl.setGrowHorizontally(true);
setScrollable(false);
setLayout(tl);
...
// and add stuff to it
add(tl.createConstraint().heightPercentage(15), labelDesc);
add(tl.createConstraint().heightPercentage(50), compGroup);
add(tl.createConstraint().heightPercentage(35), recentSearchContainer);
Works like a charm!
I'm making an emacs-esque toy text editor. At startup, there's one large window (a QTextEdit derivative) in the top center of the screen, with a minibuffer (QLineEdit derivative) underneath. Both of the actual editing widgets are contained in the grids of parent classes called Window and MiniWindow (Window also keeps track of a QLabel that appears directly beneath the QTextEdit).
My Window object is at location 1, 1 in the grid, and my MiniWindow object is at 2, 1. I've set content margins to 0 and spacing to 0, which looks great at first, but when I try to grow the window by dragging on the corner, this starts to happen:
As you can see, the screen is divided into two rows (as it should be), but half of the vertical length of the screen is dedicated to each row. What I need is for the top Window to stretch its length during resizing so that it is always adjacent to the MiniWindow underneath. Is there some other option I need to be setting?
Nevermind, got it.
I was having this problem because the QLineEdit object was in the grid of my container class, MiniWindow. The height of a MiniWindow object is free to vary with the window resizing in a way that a QLineEdit alone would not be. The fix was set to the maximumHeight of MiniWindow to approximately the height of a QLineEdit, which is around 16.
Works great now.
I want to compute the left and top border sizes of a GtkFrame. I use the following code:
static void computeborder(GtkWidget *frame)
{
GtkAllocation alloc, child_alloc;
int borderTop, borderLeft;
gtk_widget_get_allocation(frame, &alloc);
GTK_FRAME_GET_CLASS(frame)->compute_child_allocation(GTK_FRAME(frame), &child_alloc);
borderTop = child_alloc.y - alloc.y;
borderLeft = child_alloc.x - alloc.x;
printf("BORDER TOP: %d BORDER LEFT %d\n", borderTop, borderLeft);
}
This is working fine but only if the top-level window hosting the GtkFrame is already shown. However, I need to find out about border sizes before the top-level window which contains my GtkFrame widget is shown.
If the top-level window which contains my GtkFrame hasn't been opened yet, (-1,-1) is returned in alloc and (1,1) is returned in child_alloc. If the top-level window has already been opened, the correct sizes are returned and I can calculate the border sizes.
However, I need to calculate the border sizes when the top-level window is hidden. So how can I calculate the border sizes of my GtkFrame in this case?
I'm using GTK 2.
Those values depends on realization, since they need information about the target display etc. Different displays can in theory have different settings that will make the sizes change.
You can try gtk_widget_realize() or gtk_widget_map() or both on the toplevel window before requesting the sizes