I use wxWidgets 3.1.5 under Windows, in which I have developed a I have a wxGrid that contains more columns than can be displayed, so a horizontal scroll bar is needed.
The problem arises when I use FreezeTo in a virtual table base through wxGridTableBase:
if the wxGrid contains more rows than can be displayed both the horizontal and vertical scroll bars are visible,
otherwise, if all rows are displayed, the vertical scroll bar is not displayed, the horizontal scroll bar it is disabled even though it must be enabled.
To prove it you can use the example provided by wxWidgets Grid control wxWidgets sample, modifying the BigGridFrame constructor in griddemo.cpp like so:
// ============================================================================
// BigGridFrame and BigGridTable: Sample of a non-standard table
// ============================================================================
BigGridFrame::BigGridFrame(long sizeGrid)
: wxFrame(NULL, wxID_ANY, "Plugin Virtual Table")
{
m_grid = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_table = new BigGridTable(sizeGrid);
// VZ: I don't understand why this slows down the display that much,
// must profile it...
//m_table->SetAttrProvider(new MyGridCellAttrProvider);
m_grid->AssignTable(m_table);
SetClientSize(FromDIP(wxSize(500, 450)));
//if sizeGrid <12 the horizontal scrollbar will not be displayed, if sizeGrid> = 12 the horizontal scrollbar will be displayed
m_grid->FreezeTo(0, 3);
}
If sizeGrid <12 the horizontal scrollbar will not be displayed, if sizeGrid> = 12 the horizontal scrollbar will be displayed
how can i fix this bug?
(See bug reported on github)
Is it possible to solve it with some workaround on my code, instead of intervening on the wxWidgets library ?
For example shrink the height of the wxGrid so that the bottom edge coincides with the last row ? How can I do it ?
The problem is solved by applying the patch published to:
patch
Related
I see some strange behaviour in jqGrid in IE10 Standard mode, specially when grid size is bigger.
When I scroll using horizontal scroll bar to the right of the grid and then scroll up to see the column headers, they are not visible (blank).
Attaching screenshots. It happens with the jqgrid demo as well
Steps to reproduce :
1. Open the jqgrid in IE10 . http://trirand.com/blog/jqgrid/jqgrid.html -> Frozen Cols Group Header (New) -> Frozen Column
2. Drag some of the columns to the right (increase the width of the columns using mouse).
Resize the window so that all column headers are not visible in the screen.
Use horizontal scroll bar to scroll to the right of the grid.
Use vertical scroll bar to move up to see the column headers.
You will see that some column headers are not visible.
Screenshot can be found # http://postimg.org/image/u1wa4k3er/
Please let me know if anyone has come across this problem and have any suggestions ?
I'm faced with a problem where I need to display some characters in a tree-view item (those belonging to the Symbol charset) using Symbol font while others in the default System font (Segoi UI on my Windows 7).
Custom draw allows us to draw different items using different fonts, but I would like to draw the same item string using different fonts as it applies to each character in the string as told above.
So, what I've done with not-so-pleasing results w.r.t. drawing performance upon a horizontal scroll when the number of items is more so far is this:
I disabled horizontal scrolling in my tree-view control using TVS_NOHSCROLL style (since I'm using my own scroll bar control inside the tree-view window to handle all horizontal scrolling)
I sub-classed the treeview control and in the sub-classed winproc, I handle the horizontal scroll notification and mouse notification (where I do my own hittesting and send message like TVM_EXPAND and TVM_SELECT as a result of mosue clicks/double-clicks). Also the scroll bar range is set based on how wide my custom drawn string is (the maximum length amongst all items).
I draw the string for each item upon receiving CDDS_ITEMPOSTPAINT using my own fonts for each character in the item.
The above approach (I left out some details for the sake of brevity) works BUT there are some problems which makes me post this question here and look for an alternare way:
Problems:
The horizontal scroll bar control I create is hosted "inside" the tree-view control at the bottom of the tree-view window. However, when the number of items goes beyond what the tree-view client area can accommodate vertically, the last visible tree-view item gets obscured by the scroll bar control. This can be solved by not making the scroll bar a child of the tree-view and hosting it outside the tree-view window just below it. But I don't want to do this since the scroll bar should typically be a child window of the tree-view.
This is the major one. Since I draw the items myself at each horizontal scroll, the drawing performance upon horizontal scrolling is very slow and also leads to flicker upon scrolling.
Any ideas will be much appreciated as I've been grappling with this for the last one week without success.
I can also post the relevant code here if you want to see the approach I took but I'm sure there shoould be a better approach to this and there must be some other people who would've faced this problem and solved it in the past.
Thanks in advance.
Custom-draw allows you to draw items however you want. You are not limited to a single font per item. When you receive the NM_CUSTOMDRAW notification, draw whatever you want on the provided HDC for the specified item. You can draw pieces of text in one font, pieces of text in a different font, etc. Be sure to return CDRF_SKIPDEFAULT so the TreeView itself will not try to draw anything on the item.
#Anurag S Sharma: I tried to edit this into Remy's answer. It's incomplete as is, but addresses your comment/concerns and answers this particularly vexing/useful question...
The problem is that ff I return CDRF_SKIPDEFAULT, Windows does not even draw the +/- buttons (expanding/collapsing) nor the indent lines in the control which I do want Windows to draw. – Anurag S Sharma
To retain the lines, buttons, and icons you can use ExcludeClipRect to mask only the text region and instead of returning CDRF_SKIPDEFAULT, return 0 as if you didn't draw anything. This itself would not be necessary if the text of the tree item was empty, except that the margins of the text will always be drawn by the default handler (note that Microsoft's controls do not always respect clipping shapes, but in this case they do.)
To replicate the classic TreeView label style in your custom draw procedure you need to do something like the following:
HTREEITEM item = (HTREEITEM)p->dwItemSpec;
TreeView_GetItemRect(p->hdr.hwndFrom,item,&p->rc,1);
RECT cr, rc = p->rc; GetClientRect(p->hdr.hwndFrom,&cr);
DrawTextW(p->hdc,text,-1,&rc,DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP);
rc.right+=4; rc.bottom+=2; IntersectRect(&rc,&cr,&rc);
ExtTextOutW(p->hdc,rc.left+2,rc.top+1,ETO_CLIPPED|ETO_OPAQUE,&rc,text,wcslen(text),0);
I have an MFC app that embeds a Scintilla text edit control. I want to customize the Scintilla control to display some custom controls next to the vertical scrollbar. Essentially, I want to render some controls in the orange area below, where the green area represent the scroll bars:
I tried overriding the WM_NCCALCSIZE message of the Scintilla window and subtracting an offset from the right side of the client rectangle. Here is the code:
void CScintillaCtrl::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
lpncsp->rgrc[0].right -= 100;
}
However, this causes the vertical and horizontal scroll bars to reposition themselves to account for the smaller client width, as shown below:
I'm not sure if this behavior is caused by Scintilla or Windows. Is there a way I can adjust the client area and preserve the positions of the scroll bars?
I found a Scintilla specific solution. I can use the SCI_SETMARGINRIGHT command to add a margin to the right side of the client area, and then render my controls inside that.
I have the following problem:
I use Slickgrid in combination with jquery layout. Panes can be resized with this plugin. When I resize the Slickgrid pane, so that a horizontal scrollbar appears, which wasn't there at first, I am unable to scroll all the way to the bottom.
I have created a jsfiddle to demonstrate:
http://jsfiddle.net/uNMRT/2/
Steps to reproduce:
make sure the slickgrid pane doesn't have a horizontal scrollbar.
scroll all the way doen. (works nicely, you can view record 119, the last one)
resize the slickgrid pane using the vertical splitter. Make sure to make the slickgrid area smaller to have a horizontal scrollbar appear.
scroll all the way down again. Notice that you are unable to scroll completely down. Record 119 can't be seen now.
I already do a resizeCanvas upon resize:
center__onresize: function(pane, $pane, state, options) {
myGrid.resizeCanvas();
}
That's not enough obviously. Any ideas?
I ran into the same issue and it seems like that slick grid does not set the "viewportHasHScroll" flag correctly. I found the following two workarounds to fix the issue (SlickGrid v2.1)
1) Update updateCanvasWidth function (line 396) and change the following line
viewportHasHScroll = (canvasWidth > viewportW - scrollbarDimensions.width);
to (notice the "greater than or equal to" sign
viewportHasHScroll = (canvasWidth >= viewportW - scrollbarDimensions.width);
2) Update handleScroll function (line 1920) and update the if block
//only scroll if they've moved at least one row
if(vScrollDist && (vScrollDist > options.rowHeight)) {
....
}
I am facing the same issue but for vertical scroll. If the container is resized the vertical scroll bar does not scroll completely. It stops on the second last record. Although there is space for the bar to scroll it cannot be moved completely to the bottom. If I pull it down the grid jumps and the bar moves to the original position again. The last record can never be viewed.
I had the issue also when I add a row. It is because you may have not updated the grid correctly. You have to call grid.updateRowCount();
i need to put a horizontal scrollbar in a dynamically created Hbox. im writting the code like this:
hbxWallAImg = new HBox();
hbxWallAImg.horizontalScrollPolicy="on";
but still the no scrollbar is comming.
i have tried by setStyle also. but it is also not working.
The scroll bar will not be visible unless the content of the box doesn't fit in the box's view port. So just by setting the scroll policy, it won't be displayed, but rather when the element will "know" that in case its content doesn't fit, it should display scroll bars. You also need to add some children and dimensions (with, height) to the HBox.
Without dimensions, it will "stretch" as much as it needs to accommodate the content, so no scroll bars will be visible in this case also.
You can find all the info about view ports and scrolling in Flex 4 here: http://www.adobe.com/devnet/flex/articles/flex4_viewport_scrolling.html
Hope this helps.
Have a good day,
Romi