2012-03-23 11 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が作成されます。ウィンドウ内で可能な限り大きくしたいので、expandプロパティをAからTRUEに設定しました。しかし、ウィンドウ自体の幅が高さよりも大きい場合は、描画エリアで使用されていない残りの幅を塗り潰すウィジェット、Bが必要です。GtkAspectFrameがスペースを浪費しないようにするにはどうすればよいですか?

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

またはこの(BTRUEからexpand設定されている場合):基本的に、私はこれ欲しい:

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

をしかし(BFALSEexpandセットを持っている場合は)私の代わりにこれを取得します:

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

GTKをどのようにして動作しますか?

+0

私はGTK + 3やGtkBuilderについてはわかりませんが、あなたは 'gtk_widget_get_preferred_width_for_height()'の方向を掘り下げるべきでしょう。これがXMLから実行可能かどうか、あるいはより単純な方法があるかどうかは考えられません。 – doublep

答えて

0

Aはexpand = true、fill = true、Bはexpand = false、fill = trueである必要があります。

関連する問題