Back to index

texmacs  1.0.7.15
aligned_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : aligned_widget.cpp
00004 * DESCRIPTION: aligned widgets
00005 * COPYRIGHT  : (C) 2010  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "renderer.hpp"
00013 #include "Widkit/wk_widget.hpp"
00014 
00015 wk_widget
00016 aligned_widget (array<wk_widget> lhs, array<wk_widget> rhs,
00017               SI hsep, SI vsep, SI lpad, SI rpad)
00018 {
00019   ASSERT (N(lhs) > 0, "at least one widget expected");
00020   ASSERT (N(lhs) == N(rhs), "sizes don't match");
00021   int i, n= N (lhs);
00022   SI max_w= 0;
00023   for (i=0; i<n; i++) {
00024     SI ww=1280*PIXEL, hh=64*PIXEL;
00025     lhs[i] << get_size (ww, hh, 0);
00026     max_w= max (ww, max_w);
00027   }
00028 
00029   array<wk_widget> fields_w (2*n-1);
00030   for (i=0; i<n; i++) {
00031     SI ww=1280*PIXEL, hh=64*PIXEL;
00032     lhs[i] << get_size (ww, hh, 0);
00033     array<wk_widget> line_w (5);
00034     array<string> line_n (5);
00035     line_w[0]= glue_wk_widget (false, false, lpad + max_w - ww);
00036     line_w[1]= lhs[i];
00037     line_n[1]= "prompt";
00038     line_w[2]= glue_wk_widget (false, false, hsep);
00039     line_w[3]= rhs[i];
00040     line_n[3]= "input";
00041     line_w[4]= glue_wk_widget (false, false, rpad);
00042     fields_w[2*i]= horizontal_list (line_w, line_n);
00043     if (i < n-1) fields_w[2*i + 1]= glue_wk_widget (false, false, 0, vsep);
00044   }
00045 
00046   return vertical_list (fields_w);
00047 }