2012-03-23 72 views
8
<interface> 
<object class='GtkWindow' id='window'> 
    <child> 
    <object class='GtkBox' id='box'> 
    <property name='orientation'>horizontal</property> 
    <child> 
    <object class='GtkAspectFrame' id='aspect_frame'> 
     <property name='xalign'>0.0</property> 
     <property name='yalign'>0.0</property> 
     <child> 
     <object class='GtkDrawingArea' id='drawing_area_A'> 
     <property name='expand'>TRUE</property> 
     </object> 
     </child> 
    </object> 
    </child> 
    <child> 
    <!-- widget B goes here --> 
    </child> 
    </object> 
    </child> 
</object> 
</interface> 

以上GtkBuilder UI定義創建了一個正方形DrawingArea A。我希望它在窗口內儘可能大,因此我將的屬性A設置爲TRUE。但是,當窗口本身的寬度大於高度時,我需要一個窗口小部件來填充繪圖區域未使用的剩餘寬度。基本上,我想這一點:如何防止GtkAspectFrame浪費空間?

+--------------------+ 
|+-----------++-----+| 
||   ||  || 
||  A  || B || 
||   ||  || 
||   ||  || 
|+-----------++-----+| 
+--------------------+ 

,但我得到這個代替(如果expand設置爲FALSE):

+--------------------+ 
|+-----------+ +-+| 
||   | | || 
||  A  | |B|| 
||   | | || 
||   | | || 
|+-----------+ +-+| 
+--------------------+ 

還是這個(如果expand設置爲TRUE) :

+--------------------+ 
|+-------++---------+| 
||  ||   || 
|| A || B || 
||  ||   || 
|+-------+|   || 
|   +---------+| 
+--------------------+ 

如何獲取GTK to co操作?

+0

我不知道GTK + 3或GtkBuilder,但是你應該在'gtk_widget_get_preferred_width_for_height()'方向挖掘。不知道這是XML還是可行的,或者有更簡單的方法。 – doublep 2012-06-10 18:10:25

回答

0

我相信A應該是expand = true,fill = true,而B應該是expand = false和fill = true。