Set max width of a Gtk::TextView - c++

I've created a textview which is being filled by a Gtk::TextBuffer, however the buffer contains a lot of characters and the window gets wider than the width of the screen.
Is there a way to define a max width for a Gtk::TextView?

Put the text view in a Gtk::ScrolledWindow and set the size request of the scrolled window.

Related

gtkmm textview epands instead of scrolling

I have a window that's set up with a grid attached to the window, a bunch of stuff in the grid and then a textview on the rightmost column occupying the entire column.
When I add text to the textview, instead of starting to scroll, the window just expands in order to accomodate the text. How can I get it to scroll instead?
Put the text view inside a Gtk::ScrolledWindow and put the scrolled window in the rightmost column of the grid instead.

Flex Slider full height and width without stretching

I need Flex Slider to occupy the entire page, like the one on this website: http://webfire.co.uk/
I've set both height and width to 100%, but when I re-size the page, it causes the image to distort and stretch. However, setting the height to auto leaves a white space underneath the slider, so it doesn't fill up the full page. The same thing happens with background-size:cover - the width becomes responsive but the height stays the same.
On the website above, they manage to sort of re-center the image when the window is re-sized.
Any suggestions? :)

Resize QToolButton with text

I have a QToolButton with a text using toolButton->setText(....). However, the text is truncated when the button is rendered. I have tried increasing the width of the button using resize() and setFixedSize but the text is centered and still truncated. Any ideas how to make the button follow the width of the text ?
You can use QFontMetrics to calculate the minimum size needed to display the whole text. The boundingRect method returns a QRect corresponding to the size of your text. You can specify flags like Qt::AlignHCenter.
http://qt-project.org/doc/qt-5.0/qtgui/qfontmetrics.html#boundingRect-4
You can subclass QToolButton and reimplement the setText() method to include a call to resize() or manage the size when you call setText().
Try to set the same minimumSize(w,h) and maximumSize(w,h) with correct values, I mean, for example:
In Design, in the property window of your button:
width and height in geometry - 80x88, minimum and maximum must the
same.
It works for me in my case. And pay attention on icon size of the button, if it is.

How to get the inside dimensions of a decorated window in XWindows?

If I create a full screen window where m_winw and m_winh is the full screen size, it seems to create a window for me where the outside dimension is the full screen and the inside is smaller based on the "decoration" (window border) size. Is there a way to query the window to get it's inside width and height?
m_win=XCreateWindow(m_display, m_rootwin, m_winx, m_winy, m_winw, m_winh, 0,
CopyFromParent,CopyFromParent,m_visual,CWColormap|CWEventMask,&attributes);
This is on linux.
See XGetWindowAttributes, XGetGeometry. According to the man page:
The width and height members are set tothe inside size of the window, not including the border.

How to increase a cells height and width in ListControl

How can we increase the the height and width of a cell in List
It is created using Listcontrol MFC
Write a custom list control (owner
drawn).
handle message MEASUREITEM_REFLECT
set the cell height and width in the
method:
MeasureItem( LPMEASUREITEMSTRUCT
lpMeasureItemStruct )
To set the cell width take a look at the ListView_SetColumnWidth Win32 function.
One way to set the height is to attach an image list to the list control. The list control will then set the row height based on the height of the icons in the image list.
An easy way to set the cell height of a list control is by supplying an image list of the required height:
In the header:
CImageList m_imageList;
In the implementation:
m_imageList.Create(68, 68, ILC_COLOR4, 10, 10); // 68 = cell height in pixels
m_list.SetImageList(&m_imageList, LVSIL_SMALL);
Setting the cell width is achieved by simply calling SetColumnWidth (as pointed out by jussij)