Back to index

texmacs  1.0.7.15
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Friends
qt_ui_element_rep Class Reference

Texmacs expects widgets to behave in three different ways: as embedded widgets, as menus and as regular widgets, all of which are essentially different in QT. More...

#include <qt_ui_element.hpp>

Inheritance diagram for qt_ui_element_rep:
Inheritance graph
[legend]
Collaboration diagram for qt_ui_element_rep:
Collaboration graph
[legend]

List of all members.

Public Types

enum  types {
  horizontal_menu, vertical_menu, horizontal_list, vertical_list,
  tile_menu, minibar_menu, menu_separator, menu_group,
  pulldown_button, pullright_button, menu_button, balloon_widget,
  text_widget, xpm_widget, toggle_widget, enum_widget,
  choice_widget, scrollable_widget, hsplit_widget, vsplit_widget,
  aligned_widget, tabs_widget, wrapped_widget, glue_widget
}

Public Member Functions

 qt_ui_element_rep (types _type, blackbox _load)
 ~qt_ui_element_rep ()
virtual widget make_popup_widget ()
virtual widget popup_window_widget (string s)
virtual widget plain_window_widget (string s, command q)
 Returns the widget as window.
virtual QAction * as_qaction ()
virtual QMenu * get_qmenu ()
 This method must not give ownership of the menu to the caller, thus allowing menu caching at the TeXmacs level.
virtual QLayoutItem * as_qlayoutitem ()
 Returns a QLayoutItem...
virtual QWidget * as_qwidget ()
 Returns the actual QWidget wrapped by this qt_widget_rep.
virtual QWidget * get_canvas ()
 Get a texmacs canvas (if available).
virtual tm_ostreamprint (tm_ostream &out)
virtual void send (slot s, blackbox val)
virtual blackbox query (slot s, int type_id)
virtual widget read (slot s, blackbox index)
virtual void write (slot s, blackbox index, widget w)
virtual void notify (slot s, blackbox new_val)
virtual void connect (slot s, widget w2, slot s2)
virtual void deconnect (slot s, widget w2, slot s2)

Static Public Member Functions

template<class X1 >
static widget create (types _type, X1 x1)
template<class X1 , class X2 >
static widget create (types _type, X1 x1, X2 x2)
template<class X1 , class X2 , class X3 >
static widget create (types _type, X1 x1, X2 x2, X3 x3)
template<class X1 , class X2 , class X3 , class X4 >
static widget create (types _type, X1 x1, X2 x2, X3 x3, X4 x4)
template<class X1 , class X2 , class X3 , class X4 , class X5 >
static widget create (types _type, X1 x1, X2 x2, X3 x3, X4 x4, X5 x5)

Public Attributes

types type
blackbox load
QAction * cachedAction
int ref_count

Protected Attributes

list< widget_connectionin
list< widget_connectionout

Friends

class widget

Detailed Description

Texmacs expects widgets to behave in three different ways: as embedded widgets, as menus and as regular widgets, all of which are essentially different in QT.

Hence the need to construct the QT widgets differently on a request basis via the 4 methods (), (), (), ()

Definition at line 32 of file qt_ui_element.hpp.


Member Enumeration Documentation

Enumerator:
horizontal_menu 
vertical_menu 
horizontal_list 
vertical_list 
tile_menu 
minibar_menu 
menu_separator 
menu_group 
pulldown_button 
pullright_button 
menu_button 
balloon_widget 
text_widget 
xpm_widget 
toggle_widget 
enum_widget 
choice_widget 
scrollable_widget 
hsplit_widget 
vsplit_widget 
aligned_widget 
tabs_widget 
wrapped_widget 
glue_widget 

just for non-colored ones (skips qt_glue_widget_rep)

Definition at line 35 of file qt_ui_element.hpp.


Constructor & Destructor Documentation

qt_ui_element_rep::qt_ui_element_rep ( types  _type,
blackbox  _load 
) [inline]

Definition at line 51 of file qt_ui_element.hpp.

  : type(_type), load(_load), cachedAction(NULL)  {};

Definition at line 335 of file qt_ui_element.cpp.

{
  if (cachedAction) delete cachedAction;
}

Member Function Documentation

QAction * qt_ui_element_rep::as_qaction ( ) [virtual]

Reimplemented from qt_widget_rep.

Definition at line 467 of file qt_ui_element.cpp.

                               {
  switch (type) {
    case horizontal_menu:
    case vertical_menu:
    case horizontal_list:
    case vertical_list:
    {
      typedef array<widget> T;
      array<widget> arr = open_box<T> (load);
      
      // a horizontal menu made up of the widgets in a
      QAction* act= new QTMAction (NULL);
      act->setText("Menu");
      QMenu* m= new QMenu ();
      for (int i = 0; i < N(arr); i++) {
        if (is_nil (arr[i])) break;
        QAction* a= concrete (arr[i]) -> as_qaction ();
        m->addAction (a);
        a->setParent (m);
      }
      act->setMenu (m);
      return act;
    }
      break;
      
    case tile_menu: 
    {
      typedef pair<array<widget>, int> T;
      T x = open_box<T>(load);
      array<widget> a = x.x1;
      int cols = x.x2;
      
      // a menu rendered as a table of cols columns wide & made up of widgets in a
      QWidgetAction* act= new QTMTileAction (NULL, a, cols);
      return act;
    }
      break;
      
    case minibar_menu: 
    {
      typedef array<widget> T;
      array<widget> arr = open_box<T> (load);

      QWidgetAction* act= new QTMMinibarAction (NULL, arr);
      return act;
    }
      break;
      
    case menu_separator: 
    {
      typedef bool T;
      bool vertical = open_box<T> (load);
      // a horizontal or vertical menu separator
      (void) vertical;
      QAction* a= new QTMAction (NULL);
      a->setSeparator (true);
      return a;
    }
      break;
    case glue_widget:
    {
      QTMAction* a = new QTMAction();
      a->setEnabled(false);
      return a;
    }
      break;
    case menu_group: 
    {
      typedef pair<string, int> T;
      T x = open_box<T>(load);
      string name = x.x1;
      int style = x.x2;

      // a menu group; the name should be greyed and centered
      QAction* a= new QTMAction (NULL);
      a->setText(to_qstring(tm_var_encode ((name))));
      a->setEnabled (false);
      if (style == WIDGET_STYLE_MINI) {
        QFont f = a->font();
        f.setPointSize(10);
        a->setFont(f);
      }  
      return a;
    }
      break;
      
    case pulldown_button:
    case pullright_button:
    {
      typedef pair<widget, promise<widget> > T;
      T x = open_box<T>(load);
      widget w = x.x1;
      promise<widget> pw = x.x2;
      
      // a button w with a lazy pulldown menu pw
      QAction* a= concrete (w) -> as_qaction ();
      QTMLazyMenu* lm= new QTMLazyMenu (pw);
      QMenu *old_menu = a->menu();
      a->setMenu (lm);
      a->setEnabled(true);
      if (old_menu) {
        cout << "this should not happen\n";
        delete old_menu;
      }
      return a;
    }
      break;
      
    case menu_button:
    {
      typedef quintuple<widget, command, string, string, int> T;
      T x = open_box<T>(load);
      widget w = x.x1;
      command cmd = x.x2;
      string pre = x.x3;
      string ks = x.x4;
      int style = x.x5;
      
      // a command button with an optional prefix (o, * or v) and
      // keyboard shortcut; if ok does not hold, then the button is greyed
      bool ok= (style & WIDGET_STYLE_INERT) == 0;
      QAction* a= NULL;
      a= concrete(w)->as_qaction();
#ifdef Q_WS_MAC
      if (search_forwards (" ", ks) != -1) ks= "";
#endif
      QTMCommand* c;
      if (N(ks) > 0) {
        string qtks = conv (ks);
        QKeySequence qks (to_qstring (qtks));
        if (DEBUG_QT)
          cout << "ks: " << ks << " " << qks.toString().toAscii().data() << "\n";
        a->setShortcut (qks);
        command key_cmd = tm_new<qt_key_command_rep>(ks);
        c= new QTMCommand (key_cmd);
      } else {
        c= new QTMCommand (cmd);
      }
      c->setParent (a);
        
      // NOTE: this used to be a Qt::QueuedConnection, but the slot would not
      // be called if in a contextual menu
      QObject::connect (a, SIGNAL (triggered ()), c, SLOT (apply ()));    
  
      // FIXME: implement complete prefix handling
      a->setEnabled (ok? true: false);
      
      bool check = (pre != "") || (style & WIDGET_STYLE_PRESSED);
      
      a->setCheckable (check? true: false);
      a->setChecked (check? true: false);
      if (pre == "v") {}
      else if (pre == "*") {}
      // [mi setOnStateImage:[NSImage imageNamed:@"TMStarMenuBullet"]];
      else if (pre == "o") {}
      return a;
    }
      break;
      
    case balloon_widget:
    {
      typedef pair<widget, widget> T;
      T x = open_box<T>(load);
      widget text = x.x1;
      widget help = x.x2;
      
      // given a button widget w, specify a help balloon which should be displayed
      // when the user leaves the mouse pointer on the button for a small while
      QAction* a= concrete(text)->as_qaction();
      {
        typedef quartet<string, int, color, bool> T1;
        T1 x = open_box<T1>(static_cast<qt_ui_element_rep*>(help.rep)->load);
        string str = x.x1;
        a->setToolTip (to_qstring (str));
        // HACK: force displaying of the tooltip (needed for items in the QMenuBar)
        QObject::connect(a, SIGNAL(hovered()), a, SLOT(showToolTip()));
      }
      return a;
    }
      break;
      
    case text_widget:
    {
      typedef quartet<string, int, color, bool> T;
      T x = open_box<T>(load);
      string str = x.x1;
      int style = x.x2;
      //color col = x.x3;
      //bool tsp = x.x4;
      
      // a text widget with a given color and transparency

      QTMAction* a= new QTMAction (NULL);
      string t= tm_var_encode (str);
      if (t == "Help") t= "Help "; // HACK to avoid MacOS autodetection of the Help menu?
      a->setText(to_qstring (t));
      a->str = str;
      if (style == WIDGET_STYLE_MINI) {
        QFont f = a->font();
        f.setPointSize(10);
        a->setFont(f);
      }
      return a;
    }
      break;
      
    case xpm_widget:
    {
      url image = open_box<url>(load);

      // return widget ();
      // a widget with an X pixmap icon
      QAction* a= new QTMAction (NULL);
      QPixmap* img= the_qt_renderer () -> xpm_image (image);
      QIcon icon (*img);
      a->setIcon (icon);
      return a;
    }
      break;
      
    default:
      ;
  }
  
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QLayoutItem * qt_ui_element_rep::as_qlayoutitem ( ) [virtual]

Returns a QLayoutItem...

Reimplemented from qt_widget_rep.

Definition at line 710 of file qt_ui_element.cpp.

                                   {
  //cout << "as_qlayoutitem " << ui_type_string[type] << LF;

  switch (type) {
    case horizontal_menu:
    case vertical_menu:
    case horizontal_list:
    case vertical_list:
    {
      typedef array<widget> T;
      array<widget> arr = open_box<T> (load);
      
      // a horizontal/vertical menu made up of the widgets in a
      QLayout *l;
      if ((type == horizontal_list) || (type==horizontal_menu))
        l =  new QHBoxLayout();
      else
        l =  new QVBoxLayout();

      for (int i = 0; i < N(arr); i++) {
        if (is_nil (arr[i])) break;
        QLayoutItem* li= concrete (arr[i]) -> as_qlayoutitem ();
        if (li) l->addItem(li); // ownership transferred
      }
      return l;
    }
      break;

    // a menu rendered as a table of 'cols' columns wide & made up of widgets in
    // the array 'a'
    case tile_menu: 
    {
      typedef pair<array<widget>, int> T;
      T x = open_box<T>(load);
      array<widget> a = x.x1;
      int cols = x.x2;
            
      QGridLayout* l= new QGridLayout ();
      l->setSizeConstraint (QLayout::SetFixedSize);
      l->setHorizontalSpacing (2);
      l->setVerticalSpacing (2);
      l->setContentsMargins (4, 0, 4, 0);
      int row= 0, col= 0;
      for (int i=0; i < N(a); i++) {
        QLayoutItem *li = concrete(a[i])->as_qlayoutitem();
        l->addItem(li, row, col);
        col++;
        if (col >= cols) { col = 0; row++; }
      }
      return l;
    }
      break;

    //  a table with two columns
    case aligned_widget:       
    {
      typedef quartet<SI, SI, SI, SI> T1;
      typedef triple<array<widget>, array<widget>, T1 > T;
      T x = open_box<T>(load);
      array<widget> lhs = x.x1;
      array<widget> rhs = x.x2;
      T1 y = x.x3;

      // FIXME: lpad and rpad ignored.
      SI hsep = y.x1; SI vsep = y.x2; SI lpad = y.x3; SI rpad = y.x4;
      
      if (N(lhs) != N(rhs)) FAILED("aligned_widget: N(lhs) != N(rhs) ");

      QGridLayout* l= new QGridLayout ();
      l->setSizeConstraint (QLayout::SetMinimumSize);
      l->setHorizontalSpacing (6+hsep/PIXEL);
      l->setVerticalSpacing (2+vsep/PIXEL);
      for (int i=0; i < N(lhs); i++) {
        QLayoutItem* lli = concrete(lhs[i])->as_qlayoutitem();
        QLayoutItem* rli = concrete(rhs[i])->as_qlayoutitem();
        if (lli) l->addItem(lli, i, 0, 1, 1, Qt::AlignRight);
        if (rli) l->addItem(rli, i, 1, 1, 1, Qt::AlignLeft);
      }
      return l;
    }
      break;
      
      
    case minibar_menu: 
    {
      typedef array<widget> T;
      array<widget> arr = open_box<T> (load);
      QBoxLayout* l= new QBoxLayout (QBoxLayout::LeftToRight);
      l->setContentsMargins (0, 0, 0, 0);
      l->setSpacing(0);
      for (int i=0; i < N(arr); i++) {
        QLayoutItem *li = concrete(arr[i])->as_qlayoutitem();
        l->addItem(li);
      }
      return l;
    }
      break;
      
    case menu_separator: 
    {
      typedef bool T;
      bool vertical = open_box<T> (load);
      QSizePolicy::Policy hpolicy = vertical ? QSizePolicy::Fixed 
                                             : QSizePolicy::Preferred;
      QSizePolicy::Policy vpolicy = vertical ? QSizePolicy::Preferred 
                                             : QSizePolicy::Fixed;
      return new QSpacerItem (1, 1, hpolicy, vpolicy);
    }
      break;
      
    case menu_group: 
    {
      typedef pair<string, int> T;
      T x = open_box<T>(load);
      string name = x.x1;
      int style = x.x2;
      
      (void) style;
      // a menu group; the name should be greyed and centered
      return NULL;
    }
      break;
      
    case pulldown_button:
    case pullright_button:
    case menu_button:
    case text_widget:
    case xpm_widget:
    case toggle_widget:
    case enum_widget:
    case choice_widget:
    case scrollable_widget:
    case hsplit_widget:
    case vsplit_widget:
    case tabs_widget:
    case wrapped_widget:
    {
      QWidget *w = this->as_qwidget();
      return new QWidgetItem(w);
    }
      break;
      
    case balloon_widget:
    {
      typedef pair<widget, widget> T;
      T x = open_box<T>(load);
      widget text = x.x1;
      widget help = x.x2;
      
      // given a button widget w, specify a help balloon which should be displayed
      // when the user leaves the mouse pointer on the button for a small while
      QLayoutItem* li= concrete(text)->as_qlayoutitem();
      if (li->widget())
      {
        typedef quartet<string, int, color, bool> T;
        T x = open_box<T>(static_cast<qt_ui_element_rep*>(help.rep)->load);
        string str = x.x1;
        li->widget()->setToolTip (to_qstring (str));
      }
      return li;
    }
      break;

    case glue_widget:
    {
      typedef quartet<bool, bool, SI, SI> T;
      T x = open_box<T>(load);
      QSizePolicy::Policy hpolicy = x.x1 ? QSizePolicy::Preferred 
                                         : QSizePolicy::Fixed;
      QSizePolicy::Policy vpolicy = x.x2 ? QSizePolicy::Preferred
                                         : QSizePolicy::Fixed;
      return new QSpacerItem (x.x3, x.x4, hpolicy, vpolicy);
    }
      break;
    default:
      ;
  }
  
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QWidget * qt_ui_element_rep::as_qwidget ( ) [virtual]

Returns the actual QWidget wrapped by this qt_widget_rep.

This is used to connect to signals, to change properties of the QWidget, etc.

Reimplemented from qt_widget_rep.

Definition at line 962 of file qt_ui_element.cpp.

                               {
  //cout << "as_qwidget " << ui_type_string[type] << LF;

  switch (type) {
    case horizontal_menu:
    case vertical_menu:
    case horizontal_list:
    case vertical_list:
    case tile_menu: 
    case minibar_menu: 
    case aligned_widget: 
    {
      QLayoutItem *li = this->as_qlayoutitem();
      QWidget *w = new QWidget();
      if (QLayout *l = li->layout()) {
        // note that the QLayout is the same object as the QLayoutItem 
        // so no need to free li
        w->setLayout(l);
      } else {
        cout << "qt_ui_element_rep::as_qwidget : invalid situation" << LF;
      }
      return w;
    }
      break;
      
    case menu_separator: 
    case menu_group:
    case glue_widget:
    {
      return NULL;
    }
      break;
      
    case pulldown_button:
    case pullright_button:
    {
      typedef pair<widget, promise<widget> > T;
      T x = open_box<T>(load);
      widget w = x.x1;
      promise<widget> pw = x.x2;
      
      // a button w with a lazy pulldown menu pw
      
      QAction* a= concrete (this) -> as_qaction ();
      QToolButton *b = new QTMUIButton();
      a->setParent(b);
      b->setDefaultAction(a);
      return b;
    }
      break;
      
    case menu_button:
    {
      typedef quintuple<widget, command, string, string, int> T;
      T x = open_box<T>(load);
      widget w = x.x1;
      command cmd = x.x2;
      string pre = x.x3;
      string ks = x.x4;
      int style = x.x5;
      
      
      // a command button with an optional prefix (o, * or v) and
      // keyboard shortcut; if ok does not hold, then the button is greyed
      QAction* a= concrete(this)->as_qaction();
      QToolButton *b = (style & WIDGET_STYLE_BUTTON) ? new QToolButton() : new QTMUIButton();
      b->setDefaultAction(a);
      a->setParent(b);
      return b;
    }
      break;
      
    case balloon_widget:
    {
      typedef pair<widget, widget> T;
      T x = open_box<T>(load);
      widget text = x.x1;
      widget help = x.x2;
      
      // given a button widget w, specify a help balloon which should be displayed
      // when the user leaves the mouse pointer on the button for a small while
      QWidget* w= concrete(text)->as_qwidget();
      if (w)
      {
        typedef quartet<string, int, color, bool> T1;
        T1 x = open_box<T1>(static_cast<qt_ui_element_rep*>(help.rep)->load);
        string str = x.x1;
        w->setToolTip (to_qstring (str));
      }
      return w;
    }
      break;
      
    case text_widget:
    {
      typedef quartet<string, int, color, bool> T;
      T x = open_box<T>(load);
      string str    = x.x1;
      QString style = to_qstylesheet(x.x2, x.x3);
      
      // a text widget with a given color and transparency
      QLabel *w = new QLabel();
#if 0
      //FIXME: implement refresh when changing language
      QTMAction* a= new QTMAction (NULL);
      //a->str = str;
#endif
      string t= tm_var_encode (str);
      if (t == "Help") t= "Help ";
      //w->setTextFormat(Qt::RichText);
      w->setText(to_qstring (t));
      w->setStyleSheet(style);
      return w;
    }
      break;
      
    case xpm_widget:
    {
      url image = open_box<url>(load);
      
      // return widget ();
      // a widget with an X pixmap icon
      QLabel* l= new QLabel (NULL);
      QPixmap* img= the_qt_renderer () -> xpm_image (image);
      QIcon icon (*img);
      l->setPixmap (*img);
      return l;
    }
      break;

    case toggle_widget:
    { 
      typedef triple<command, bool, int > T;
      T x = open_box<T>(load);
      command cmd = x.x1;
      bool check  = x.x2;
      QString style = to_qstylesheet(x.x3);
      
      QCheckBox* w  = new QCheckBox (NULL);  
      w->setCheckState(check ? Qt::Checked : Qt::Unchecked);
      w->setStyleSheet(style);
      command tcmd = tm_new<qt_toggle_command_rep> (w, cmd);
      QTMCommand* c = new QTMCommand (tcmd);
      c->setParent (w);
      QObject::connect (w, SIGNAL (stateChanged(int)), c, SLOT (apply()));

      return w;
    }
      break;
      
    case enum_widget:
    {
      typedef quintuple<command, array<string>, string, int, string> T;
      T x = open_box<T>(load);
      command cmd        = x.x1;
      QStringList values = to_qstringlist(x.x2);
      QString value      = to_qstring(x.x3);
      QString style      = to_qstylesheet(x.x4);
            
      QComboBox* w = new QComboBox(NULL);
      w->setEditable(value.isEmpty() || values.last().isEmpty());  // weird convention?!
      if (values.last().isEmpty())
        values.removeLast();
      
      w->addItems(values);
      int index = w->findText(value, Qt::MatchFixedString | Qt::MatchCaseSensitive);
      if (index != -1)
        w->setCurrentIndex(index);
   
      // The QComboBox must be already filled to calculate relative widths
      QSize size= qt_decode_length(x.x5, w);
      w->setMinimumSize(size);
      // QComboBox::AdjustToContentsOnFirstShow would fix the size. Better?
      w->setSizeAdjustPolicy(QComboBox::AdjustToContents);
      w->setStyleSheet(style);
      
      command ecmd = tm_new<qt_enum_command_rep> (w, cmd);
      QTMCommand* c = new QTMCommand (ecmd);
      c->setParent (w);
      // NOTE: with QueuedConnections, the slots are sometimes not invoked.
      QObject::connect (w, SIGNAL (currentIndexChanged(int)), c, SLOT (apply()));
      
      return w;
    }
      break;
      
    case choice_widget:
    {
      typedef quartet<command, array<string>, array<string>, bool > T;
      T x = open_box<T>(load);
      command cmd = x.x1;
      QStringList items  = to_qstringlist(x.x2);
      QStringList chosen = to_qstringlist(x.x3);
      bool multiple_sel  = x.x4;
      
      QListWidget* w = new QListWidget();
      w->addItems(items);

      if (multiple_sel)
        w->setSelectionMode(QAbstractItemView::ExtendedSelection);  // Support CTRL and SHIFT multiple selections.
      else
        w->setSelectionMode(QAbstractItemView::SingleSelection);
      
      for (int i = 0; i < chosen.size(); ++i) {
        QListWidgetItem* item = w->item(i);
        item->setSelected(chosen.contains(item->text(), Qt::CaseSensitive));  // Qt::CaseSensitive is the default anyway
      }
      
      command ecmd = tm_new<qt_choice_command_rep> (w, cmd, multiple_sel);
      QTMCommand* qcmd = new QTMCommand (ecmd);
      qcmd->setParent (w);
      QObject::connect (w, SIGNAL (itemSelectionChanged()), qcmd, SLOT (apply()));//, Qt::QueuedConnection);
      
      return w;      
    }
      break;
      
    case scrollable_widget:
    {
      typedef pair<widget, int> T;
      T x = open_box<T>(load);
      widget wid    = x.x1;
      QString style = to_qstylesheet(x.x2);
      
      QScrollArea* scroll = new QScrollArea();
      scroll->setBackgroundRole(QPalette::NoRole);
      scroll->setStyleSheet(style);
      QWidget* w = concrete(wid)->as_qwidget();
      scroll->setWidget(w);
    
      // FIXME????
      // "Note that You must add the layout of widget before you call this function; 
      //  if you add it later, the widget will not be visible - regardless of when you show() the scroll area.
      //  In this case, you can also not show() the widget later."
      return scroll;
    }
      break;
      
    case hsplit_widget:
    case vsplit_widget:
    {
      typedef pair<widget, widget> T;
      T x = open_box<T>(load);
      widget w1 = x.x1;
      widget w2 = x.x2;
      
      QWidget* qw1 = concrete(w1)->as_qwidget();
      QWidget* qw2 = concrete(w2)->as_qwidget();
      QSplitter* split = new QSplitter();
      split->setOrientation(type == hsplit_widget ? Qt::Horizontal : Qt::Vertical);
      split->addWidget(qw1);
      split->addWidget(qw2);
      
      return split;
    }
      break;

    case tabs_widget:
    {
      typedef pair<array<widget>, array<widget> > T;
      T x = open_box<T>(load);
      array<widget> tabs = x.x1;
      array<widget> bodies = x.x2;
      
      QTMTabWidget* tw = new QTMTabWidget ();
      
      int i;
      for (i = 0; i < N(tabs); i++) {
        if (is_nil (tabs[i])) break;
        QWidget* prelabel = concrete (tabs[i]) -> as_qwidget();
        QLabel* label = qobject_cast<QLabel*> (prelabel);
        QWidget* body = concrete (bodies[i]) -> as_qwidget();
        tw->addTab(body, label ? label->text() : "");
        delete prelabel;
      }
      if (i>0) tw->resizeOthers(0);   // Force the automatic resizing

      return tw;
    }

    case wrapped_widget:
    {
      typedef pair<widget, command> T;
      T x = open_box<T>(load);
      widget w = x.x1;
      command cmd = x.x2;
      
      QWidget* qw = concrete(w)->as_qwidget();
      QTMCommand* c = new QTMCommand (cmd);
      c->setParent (qw);
      QObject::connect (qw, SIGNAL (destroyed()), c, SLOT (apply()));//, Qt::QueuedConnection);
      
      return qw;
    }
      break;
      
    default:
      ;
  }
  
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void widget_rep::connect ( slot  s,
widget  w2,
slot  s2 
) [virtual, inherited]

Definition at line 150 of file widget.cpp.

                                               {
  widget_connection con (this, s, w2.rep, s2);
  insert (out, con);
  insert (w2->in, con);
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class X1 >
static widget qt_ui_element_rep::create ( types  _type,
X1  x1 
) [inline, static]

Definition at line 65 of file qt_ui_element.hpp.

                                                               {
    return tm_new <qt_ui_element_rep> (_type, close_box<X1>(x1));
  }

Here is the caller graph for this function:

template<class X1 , class X2 >
static widget qt_ui_element_rep::create ( types  _type,
X1  x1,
X2  x2 
) [inline, static]

Definition at line 70 of file qt_ui_element.hpp.

                                                   {
    typedef pair<X1,X2> T;
    return tm_new <qt_ui_element_rep> (_type, close_box<T> (T (x1,x2)));
  }
template<class X1 , class X2 , class X3 >
static widget qt_ui_element_rep::create ( types  _type,
X1  x1,
X2  x2,
X3  x3 
) [inline, static]

Definition at line 76 of file qt_ui_element.hpp.

                                                          {
    typedef triple<X1,X2,X3> T;
    return tm_new <qt_ui_element_rep> (_type, close_box<T> (T (x1,x2,x3)));
  }
template<class X1 , class X2 , class X3 , class X4 >
static widget qt_ui_element_rep::create ( types  _type,
X1  x1,
X2  x2,
X3  x3,
X4  x4 
) [inline, static]

Definition at line 82 of file qt_ui_element.hpp.

                                                                 {
    typedef quartet<X1,X2,X3,X4> T;
    return tm_new <qt_ui_element_rep> (_type, close_box<T> (T (x1,x2,x3,x4)));
  }
template<class X1 , class X2 , class X3 , class X4 , class X5 >
static widget qt_ui_element_rep::create ( types  _type,
X1  x1,
X2  x2,
X3  x3,
X4  x4,
X5  x5 
) [inline, static]

Definition at line 88 of file qt_ui_element.hpp.

                                                                        {
    typedef quintuple<X1,X2,X3,X4,X5> T;
    return tm_new <qt_ui_element_rep> (_type, close_box<T> (T (x1,x2,x3,x4,x5)));
  }
void widget_rep::deconnect ( slot  s,
widget  w2,
slot  s2 
) [virtual, inherited]

Definition at line 157 of file widget.cpp.

                                                 {
  widget_connection con (this, s, w2.rep, s2);
  remove (out, con);
  remove (w2->in, con);
}
virtual QWidget* qt_widget_rep::get_canvas ( ) [inline, virtual, inherited]

Get a texmacs canvas (if available).

Reimplemented in simple_widget_rep.

Definition at line 80 of file qt_widget.hpp.

{ return NULL; }
QMenu * qt_ui_element_rep::get_qmenu ( ) [virtual]

This method must not give ownership of the menu to the caller, thus allowing menu caching at the TeXmacs level.

Called only by code which attaches root menus in the GUI elements.

Reimplemented from qt_widget_rep.

Definition at line 433 of file qt_ui_element.cpp.

                             {
  if (!cachedAction) {
    cachedAction = as_qaction();
  }
  return (cachedAction ? cachedAction->menu() : NULL);
}

Here is the call graph for this function:

Reimplemented from qt_widget_rep.

Definition at line 341 of file qt_ui_element.cpp.

                                      {
  return tm_new<qt_menu_rep>(as_qaction());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void widget_rep::notify ( slot  s,
blackbox  new_val 
) [virtual, inherited]

Reimplemented in aqua_input_widget_rep, aqua_chooser_widget_rep, qt_window_widget_rep, aqua_view_widget_rep, aqua_chooser_widget_rep, qt_input_widget_rep, qt_chooser_widget_rep, simple_widget_rep, simple_widget_rep, qt_view_widget_rep, wk_widget_rep, and qt_window_widget_rep.

Definition at line 194 of file widget.cpp.

                                            {
  list<widget_connection> l= out;
  while (!is_nil (l)) {
    l->item->w2->send (s, new_val);
    l= l->next;
  }  
}

Here is the call graph for this function:

Returns the widget as window.

Each TeXmacs widget can at some point be asked to present itself into a window. The scheme-originating function window_create() expects this method in every widget. Widgets which are windows must declare themselves to be via the QProperty "texmacs_window_widget". This will be checked when processing messages from scheme asking to actually display the window. See qt_view_widget_rep::read() and qt_window_widget_rep::qt_window_widget_rep().

Parameters:
s(Often?) a title for the window.
q
Returns:
A pointer to this widget.

Reimplemented from qt_widget_rep.

Definition at line 411 of file qt_ui_element.cpp.

                                                               {
  QLayoutItem *li     = as_qlayoutitem();
  QTMPlainWindow* win = new QTMPlainWindow();
  win->setWindowTitle (to_qstring (s));  
  
  if (li->widget()) 
    win->layout()->addItem(li);
  else if (li->layout())
    win->setLayout(li->layout());
  

  QTMCommand* qtmcmd = new QTMCommand(quit);
  qtmcmd->setParent(win);
  QObject::connect(win, SIGNAL(closed()), qtmcmd, SLOT(apply()));

  // FIXME: using qt_plain_window_widget causes a crash when closing "secondary"
  // windows. (example widget6 in menu-test.scm)
  //return tm_new<qt_plain_window_widget_rep>(win);
  return tm_new<qt_window_widget_rep>(win, quit);
}

Here is the call graph for this function:

Reimplemented from qt_widget_rep.

Definition at line 346 of file qt_ui_element.cpp.

                                                 {
  return concrete(make_popup_widget())->popup_window_widget(s);
}

Here is the call graph for this function:

tm_ostream & widget_rep::print ( tm_ostream out) [virtual, inherited]

Reimplemented in wk_widget_rep.

Definition at line 207 of file widget.cpp.

                                  {
  return out << "widget";
}
blackbox widget_rep::query ( slot  s,
int  type_id 
) [virtual, inherited]
widget widget_rep::read ( slot  s,
blackbox  index 
) [virtual, inherited]
void widget_rep::send ( slot  s,
blackbox  val 
) [virtual, inherited]
void widget_rep::write ( slot  s,
blackbox  index,
widget  w 
) [virtual, inherited]

Friends And Related Function Documentation

friend class widget [friend, inherited]

Definition at line 59 of file widget.hpp.


Member Data Documentation

Definition at line 49 of file qt_ui_element.hpp.

list<widget_connection> widget_rep::in [protected, inherited]

Definition at line 36 of file widget.hpp.

Definition at line 47 of file qt_ui_element.hpp.

list<widget_connection> widget_rep::out [protected, inherited]

Definition at line 37 of file widget.hpp.

int abstract_struct::ref_count [inherited]

Definition at line 142 of file basic.hpp.

Definition at line 46 of file qt_ui_element.hpp.


The documentation for this class was generated from the following files: