Roku-Create Selectable List - list

I am in the process of making a Roku channel. The idea is to have a full screen player going, if the user presses a particular button on remote, a small pop up menu will display in a corner of the screen with a list of available channels. I have all working with the following exception: I can't figure out how to populate the area where the menu displays. Currently I have a transparent roImageCanvas on layer 1, the menu box is drawn on layer 2. The problem is that roImageCanvas allows for a text element but only one Item. So if I have a list of 10 channels, I would have to create 10 items on the canvas. The roImageCanvas does not accept arrays. So there is no way to create the pop menu on the fly if the number of channels changes. The number of items on the canvas has to be hard coded as far as I can tell. Ideally the roListScreen is what I would like to pop up but from what I understand all screens are full screen all the time. Does anybody know of a way to populate the targetbox on the canvas or create a screen that is resizable? Thanks for any suggestions

A roImageCanvas layer is an array. There is no technical limitation to you adding >1 elements to a layer and so you can add as many separate text items as you want (not hard-coded!). It seems to me best to have 1 text element per 1 menu item, so you can use their bounding rectangles (or text color) to highlight the choice

Related

How to fit all the widgets together using grid Tkinter

I'm trying to fit all widget, I have tree frames:
First frame:
Have a label (that need to have some name with a big letter size)
A custom combobox to change the value of the label if nedded
A button to make the selection of the combobox
Second frame:
Have a treeview with some information that when I make a clic in one row another treeview appears in the 3rd frame. This treeview have occupy all the frame
Third frame:
Have three columns:
The first one have two rows:
Fist row two buttons add and remove, that have occupy all the row.
Second row a treeview that have occupy all it space. This treeview appears when click a row in the first treeview, how can I show the empty treeview and fill in when click the row. The function is OnDoubleClick
The second column:
Have two buttons that have to be in the center of the rows.
The third column:
Same as the first but with other treeview.
Here is an image of what i want to achive:
I'm not going to rewrite your whole program because that's a lot of code, but I'll explain the way I would approach the problem. Tkinter layout is really simple if you are methodical and organized, and try to solve only one problem at a time.
Main layout
First, you seem to have three main sections: a toolbar across the top, a middle section with a treeview, and a bottom section with a whole bunch of stuff. So, first thing I would do is create three frames, one for each section. Then, I would use pack like this:
toolbar.pack(side="top", fill="x")
main.pack(side="top", fill="both", expand=True)
bottom.pack(side="top", fill="both", expand=False)
I don't know if that third section should expand or not. It's not clear what sort of behavior you expect when the user resizes the window.
Toolbar layout
This one is very straight-forward. It's three widgets spread equally. You can use pack or grid, either will work just fine.
Main layout
This just has a treeview, or maybe a treeview with scrollbars? Again, pack or grid works just fine with such a simple layout.
Bottom
This one appears to be made up of three sections: a left section, a middle section, and a right section. Like with the main layout, I would start by creating three frames, all as children of the "bottom" frame created earlier. Then, I would again use pack since it's a simple horizontal layout:
left.pack(side="left", fill="both", expand=True)
middle.pack(side="left", fill="both", expand=False)
right.pack(side="left", fill="both", expand=True)
By setting expand=True to the left and right sides, if the window grows or shrinks, these will grow or shrink too while the middle section stays its natural size.
Bottom-left and Bottom-right
Both of these look identical. It looks like the easiest thing to do would be to create the widgets (ie: no more frames), and then use grid to lay them out. Though, if by "buttons" you mean you could have several, you could create a frame for the buttons so that you can more easily pack all the buttons from left to right.
Bottom-center
You can create buttons that are a child of this frame, and use either grid or pack.

How can I overlap qwidgets while using the grid layout and positioning overlapping widgets a particular distance from the window border?

I am programming a game and I have a tab widget which takes up the majority of the window. I want to use the extra space in the tab bar for buttons. I have the tab widget in a grid layout. To accomplish this, I use the code below in order to remove and add back the button widgets to the desired areas (the solution to someone else's question).
ui->centralLayout->removeWidget(ui->exitButton);
ui->centralLayout->removeWidget(ui->ResizeButton);
ui->centralLayout->addWidget(ui->ResizeButton,0,4, Qt::AlignTop|Qt::AlignRight);
ui->centralLayout->addWidget(ui->exitButton,0,4, Qt::AlignTop|Qt::AlignRight);
This does not work for me; however, because I would like the second widget-- the resize button-- to be just to the left of the exit button. What is occurring is that it instead overlaps the exit button. I simply need to move it 21 pixels to the left and have no idea how!
I tried putting both buttons in a frame and then removing and adding the frame the way I did the buttons. Unfortunately the same functions I used do not exist for the qt frame object.
Here are some pictures of my window.
https://docs.google.com/document/d/17w5USWQcCtb6OdcRShdcYcRjXTcdVpmdrG5TWLX71y8/edit?usp=sharing
you are using void QGridLayout::addWidget(QWidget * widget, int row, int column, Qt::Alignment alignment = 0) overload.
2-nd and 3-rd parameters are row and column of a grid. And you put 2 widgets in the same cell so they are overlaping each other.
I solved my problem. Earlier when I was trying to add them to a frame and reposition it I could not but using a widget as the container for my buttons let me place them the way I was earlier attempting to individually place the buttons.

Display child window on fixed position in MFC CScrollView

I have a window inherited from CScrollView that handles WM_PAINT and displays a graph. This graph has elements of different types and type of element is marked by the shape of element.
I want to display some legend so that user knows what each shape means. Since user will not look at this legend often the idea is that in the upper right corner of the view control there will be a small icon. When user moves the mouse over this icon it will expand into small rectangle displaying the legend of shapes used in graph. When mouse is moved outside this rectangle it will collapse back to small icon.
This is what I have tried so far:
Draw the hotspot icon and legend rectangle using GDI in handler of WM_PAINT of view class.
Implement hotspot as a separate window that is created as a child of a scroll view.
Implement hotspot as a separate window but create it as a popup window with no parent.
Version 1 and 2 behave strangely if user scrolls the graph view.
In version 1 I can see artifacts (button is smeared across the view) while performing scroll I guess that during the scroll existing image is not invalidated but only moved.
In version 2 there is no smearing but I need to move the child window whenever I get VM_HSCROLL and WM_VSCROLL messages and these messages are not precise enough to be used this way. During scroll I can see my button moving couple of pixels and then jumping to correct position.
Version 3 is the most disturbing and because legend is not child of a graph view I get some strange behaviour where legend button is displayed even when graph view is not shown and I think that there are too many problems with this one to be viable development path to invest time in.
I think that the version 2 is the most promising but I need to find a way to make a child window stay at one place during scroll.
Did anyone have success in implementing something like this? Is there some other implementation I can investigate?
CScrollView has OnScrollBy virtual method that scrolls the entire client area of view control. You can override this method and implement your own scroll functionality.
::ScrollWindowEx has a parameter prcScroll that can specify only a portion of client area that will be scrolled.
New OnScrollBy splits client area into 4 stripes and calls ::ScrollWindowEx for each one of them.
These stripes are:
client area above icon (rectangle width across entire client area)
client area on the left of icon (rectangle height same as icon)
client area on the right of icon (rectangle height same as icon)
client area underneath icon (rectangle width across entire client area)
1 1 1 1 1
2 2 2 * 3
4 4 4 4 4
4 4 4 4 4
After scrolling all individual client rectangles, just invalidate client area where icon is located.
You may just simply use
CPoint GetScrollPosition( ) const;
method to obtain current scroll position of scroll view and recalculate your 'static' label offset accordingly.
BTW: Instead of WM_PAINT use CScrollView's method
virtual void OnDraw( CDC* pDC );
it's important

How can I add multiple icons to an individual TreeView item?

I am trying to display multiple icons to the Treeview item but it is not displaying all the icons, it displays only one.
I am using the following code:
CImageList m_imageState;
m_cTree.m_imageState.Create(16, 16, ILC_MASK, 0, 4);
m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
m_cTree.m_imageState.Add(&bm2, RGB(255,0,255));
m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
m_cTree.m_imageState.Add(&bm1, RGB(0,255,255));
m_cTree.SetImageList( &(m_cTree.m_imageState), TVSIL_NORMAL );
But when I see Treeview, item displays only one icon.
Is it possible to display multiple icons with Treeview item?
Please suggest how can I do this.
Correct, only one icon will be displayed per item in a TreeView control. This is by design, a hard limitation of the native control that the MFC library wraps.
The only way you're going to be able to display multiple icons per item is owner drawing. It's a pretty difficult task for a TreeView control, not nearly as easy as owner drawing a button or a label control. Make sure that you really this need this functionality, and consider whether there's a better way of displaying the relevant information to your users.
Alternatively, you could create custom bitmaps that combine multiple images next to one another, and add those to your ImageList. The resulting images will be wider than they are tall, but the control doesn't care: it will display whatever size images you specify, as long as all the images in the image list have the same dimensions. This is definitely a hack, but it might work, depending on your needs.

How to edit columns in-place with CListCtrl?

I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature?
This is doable but it does require a fair bit of stuffing around with mouse clicks and focus events.
In a nutshell you trap the left mouse button down message and convert it into a cell hit details (i.e a row and column index).
With these cell details you can not determine the size and location of the list view cell and also the text value that it contains.
Now create a CEdit control directly over this cell by using size and location details from the previous step and give it the text value of the cell.
The final step is to handle the focus and keyboard enter events for the CEdit so that the text details of the CEdit can be put back into the list view cell.
It does take a fair amount of coding but when done right it does work well as an alternative to a grid control.
Don't attempt with CListCtrl.
Use the MFC Grid Control. We deploy it in an off-the-shelf app with success. It offers in-place edit, checkbox, spin, etc for all cells, as well as column and row headers, auto-size, auto-expand, colors, drag-drop.