wxWigets create wxPanel changing with the context - c++

My software is based on just a frame dividen into two panels
For example, if I click the button "let's draw", the first panel on the left should becone a toolbox (with colour palette, brush and so on), the second panel should become a paint like panel
If I click the button "let's sing", on the left should appear four button, on the right the song to sing
What's the best tecnique to obtain that result?
I render the four panel (two for drawing, two for singing). The two I use are in position 0,0; the other are in position -1000,0
I create some function changeLeftPanelIntoDrawing(), changeRightPanelIntoDrawing(), changeLeftPanelIntoSinging(), changeRightPanelIntoSinging(), then I call them on click
Other hint?

In wxWidgets 3.0 you have wxSimplebook which allows you to just add different pages (i.e. arbitrary windows) to it and switch between them. If you're using an earlier version you can still just drop the contents of wx/simplebook.h into your project and use it, it's a very simple class and you can read its code in 30 seconds to see how it is implemented.

Related

Replace color by area and by color with Directdraw

I need to implement a sort of "select box" on this vertical menu:
In short I like to add the possibility to navigate the vertical menu via arrow keys.
I have already hook the game, but this part I need to do manually.
I thing the best way is use directdraw API but I don't have experience about it.
Theoretically I can follow 2 ways:
Change and resume the backgroud color of the selected item by position and color.
Add and remove a rounded box outside the selected item by position (this is not best but seem more easy to do).
I ask what are the directdraw (or other) API that do it.
Any tips are much appreciated.
Best Regards

qt on Mac: Form Layout fails to stretch horizontally

I'm still trying to do some pretty basic stuff with qt, and it's been a struggle. I'm specifically targeting for Mac. My current problem is getting the forms to not suck.
The simple problem. Create a new MainWindow app. Go into the Qt Creator (open Forms -> mainwindow.ui).
Drag 3 labels into place. Then I dragged 2 Line Edits and for fun, a Dial, but that part probably doesn't matter.
Click the main window and then tell it to use Form Layout. Within Qt Creator if I resize the window, my various line edits expand to fill the available space, exactly like I want.
Run the app. All the line edit fields are a fixed length, very short (if I don't override their minimum width), and do NOT resize as I resize the window.
Three quarters of the reason to use Form Layout is for resizing capability.
I've tried clicking on the central widget before setting to Form Layout: no change in behavior.
I do get reasonable behavior if I use a grid layout, although I have to add a vertical spacer at the bottom or my dial resizes crazily as I play with the window size.
So... Am I just doing something wrong with Form Layout? Or does it not work well on Mac and I should use Grid Layout instead?
I really miss Motif's XmFormLayout. It took time to set all the constraints, but I could make my forms do exactly what I wanted. Ah, but so 1990s.
On the panel to the right where you can see the objects, click the centralWidget. In the property panel, scroll down until you get to the layout properties of the form layout. Set the layoutFieldGrowthPolicy to ExpandingFieldsGrow.
By default, the line edits are not growing to fill the available space on macOS because they are not supposed to. This is some sort of macOS UI guideline. QFormLayout follows the platform conventions by default.
It would also be nice if I can figure out how to NOT necessarily expand everything to full width. I have a few Line Edit widgets that I'd like to keep short. They're going to hold TCP port numbers.
For those, set the Horizontal Policy property (it's grouped inside the sizePolicy property group in the properties panel) of the affected line edits to something suitable. In this case, probably to Fixed, but look up the documentation first of what each setting does.

Qt / C++ - Scrolling & Wrapping Menu

I want to make a menu that will take an undetermined quantity of labels and spread them out horizontally so that 3 are visible on screen at once. When pressing left/right it will go to the next one, the one that is selected is always in the center of the screen horizontally with the other two on the left/right of the screen.
The problem is that I also want a smooth transition not just a replacement. They need to wrap endlessly.
Not sure where to begin, not finding examples on google.
The concept you are talking about was popularized by Apple under the name "Cover Flow".
There is a widget like that available under a permissive license here: https://code.google.com/p/pictureflow/
I take it you want something a bit simpler (only show three labels, less fancy 3D effect), but I assume this is a good starting point.
Another one is the PathView QML element:
http://qt-project.org/doc/qt-5/qml-qtquick-pathview.html#details
It is even closer to what you like to do, feature-wise. It is also available in Qt4 and there is a tutorial here: http://qt-project.org/doc/qt-4.8/declarative-modelviews-pathview.html

How to provide a custom column width calculation for CListCtrl?

I'm using a CListCtrl with my own "DrawItem" to draw some custom graphics into the first column, in front of the text. The text is moved ~20 pixels to the right for this. That part works.
If the user double-clicks the column divider in the header, Windows calculates the best column width. But of course Windows doesn't know my custom drawing. So the result is ~20 pixels too small for the first column.
How can I correct that?
Found a workaround:
I can trick MFC into thinking that the list control uses checkboxes:
pMyList->SetExtendedStyle(pMyList->GetExtendedStyle() | LVS_EX_CHECKBOXES);
The user will never ever see the system's checkboxes (because of my custom drawing), but this gives me just the space that I need.

creating squares and rectangles in wxwidgets

I'm working on an application, and part of it is making the user create a shapes such as squares or rectangles. I'm wondering if there is a function in wxwidgets that enable the user to do that. What i want to do is the user will click this button then he/she can draw a square or rectangle in his/her desired size. It is like in paint where you can make your own size in your desired size. Is that possible in wxwidgets and codeblocks? maybe some related links or tutorials or anything that will help. thanks !!
You should use this contrib library:
Object Graphics Library
OGL defines an API for applications that need to display objects connected by lines. The objects can be moved around and interacted with. You can find this in contrib/src/ogl, contrib/include/wx/ogl, and contrib/samples/ogl.
This is the link:
http://docs.wxwidgets.org/2.8/wx_utilities.html
Max
Titles sais context here is "drawing", ok.
But in case you are talking about user-created rectangles as means of selecting stuff (or users end up here while searching for that context), jargon for that is rectangles as selection is "marquee selection", and you would look into Wx::Overlay to accomplish that.