原型 gtkmm void set_size_request(int width = -1, int height = -1); gtk void gtk_widget_set_size_request ( GtkWidget* widget, int width, int height ) 描述 ...
原型
gtkmm
void set_size_request(int width = -1, int height = -1);
gtk
void
gtk_widget_set_size_request (
GtkWidget* widget,
int width,
int height
)
描述
設置小部件的最小大小。
也就是說,小部件的大小請求將至少是寬度乘以高度。您可以使用此函數強制小部件比正常情況下更大。
在大多數情況下,對於頂級視窗,gtk\u window\u set\u default\u size()是比此函數更好的選擇;設置預設大小仍允許用戶縮小視窗。設置大小請求將強制他們離開視窗,至少與大小請求一樣大。
請註意,設置任何固定大小的固有危險-主題、翻譯成其他語言、不同字體和用戶操作都可以更改給定小部件的適當大小。因此,基本上不可能硬編碼始終正確的大小。
小部件的大小請求是小部件在正常工作和正確繪製自身時可以接受的最小大小。然而,在一些奇怪的情況下,小部件分配的空間可能小於其請求的大小,在許多情況下,小部件分配的空間可能大於其請求的空間。
如果給定方向上的大小請求為-1(未設置),則將使用小部件的“自然”大小請求。
此處設置的大小請求不包括來自屬性GtkWidget:margin start、GtkWidget:margin end、GtkWidget:margin top和GtkWidget:margin bottom的任何邊距,但它幾乎包括了GtkWidget的任何子類設置的所有其他填充或邊框屬性。
Description
Sets the minimum size of a widget.
That is, the widget’s size request will be at least width by height. You can use this function to force a widget to be larger than it normally would be.
In most cases, gtk_window_set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it’s basically impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the properties GtkWidget:margin-start, GtkWidget:margin-end, GtkWidget:margin-top, and GtkWidget:margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of GtkWidget.