Guest User

Untitled

a guest
Jan 22nd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.38 KB | None | 0 0
  1.     public override void get_preferred_width (Widget widget,
  2.                         out int      min_width,
  3.                         out int      nat_width) {
  4.  
  5.        
  6.         int xpad=0;
  7.        
  8.  
  9.         TreeView tree = widget as TreeView;
  10.         TreeViewColumn column = tree.get_column(0);
  11.  
  12.         default_width = column.width;
  13.         nat_width = min_width = column.width;
  14.     }
  15.  
  16.     public override void get_preferred_height_for_width (Widget widget,
  17.                                int          width,
  18.                                out int      minimum_height,
  19.                                out int      natural_height) {
  20.         int a;
  21.         Pango.Rectangle rect;
  22.         Pango.Layout layout = widget.create_pango_layout(text);
  23.         layout.set_width(width*Pango.SCALE);
  24.         layout.set_wrap(Pango.WrapMode.WORD);
  25.        
  26.         layout.get_pixel_size(null, out a);
  27.  
  28.         if ( a < 100 ) {
  29.             minimum_height = a;
  30.             natural_height = a;
  31.             TreeView tree = widget as TreeView;
  32.             TreeViewColumn column = tree.get_column(0);
  33.             column.queue_resize();
  34.         }
  35.         else {
  36.             minimum_height = 100;
  37.             natural_height = 100;
  38.         }
  39.         print("%d %d\n", minimum_height, natural_height);
  40.     }
  41.  
  42.     public override void get_preferred_height (Widget widget,
  43.                          out int      minimum_size,
  44.                          out int      natural_size) {
  45.         int min_width;
  46.  
  47.         get_preferred_width (widget, out min_width, null);
  48.         get_preferred_height_for_width (widget, min_width,
  49.                     out minimum_size, out natural_size);
  50.         print("minimum size %d\n", minimum_size);
  51.     }
Add Comment
Please, Sign In to add comment