Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Attributes | Friends
qt_plain_window_widget_rep Class Reference

Models the simplest top-level window possible. More...

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

List of all members.

Public Member Functions

 qt_plain_window_widget_rep (QWidget *w)
 ~qt_plain_window_widget_rep ()
virtual void send (slot s, blackbox val)
virtual blackbox query (slot s, int type_id)
 Querying.
virtual widget read (slot s, blackbox index)
 Read access to subwidgets.
virtual void write (slot s, blackbox index, widget w)
 Write access to subwidgets.
virtual void notify (slot s, blackbox new_val)
 Notification of state changes Overriden to provide debugging support.
virtual widget plain_window_widget (string s, command q)
 Sets the view's title to _title, then constructs a wrapper widget for the view and returns it.
void set_current_renderer (basic_renderer _r)
basic_renderer get_current_renderer ()
virtual QWidget * as_qwidget ()
 Returns the actual QWidget wrapped by this qt_widget_rep.
virtual widget make_popup_widget ()
virtual widget popup_window_widget (string s)
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 QWidget * get_canvas ()
 Get a texmacs canvas (if available).
virtual QLayoutItem * as_qlayoutitem ()
 Returns a QLayoutItem...
virtual tm_ostreamprint (tm_ostream &out)
virtual void connect (slot s, widget w2, slot s2)
virtual void deconnect (slot s, widget w2, slot s2)

Public Attributes

QWidget * view
basic_renderer current_renderer
int ref_count

Protected Attributes

list< widget_connectionin
list< widget_connectionout

Friends

class widget

Detailed Description

Models the simplest top-level window possible.

When any simple TeXmacs widgets needs promotion into a TeXmacs window, we encapsulate it into a qt_plain_window_widget. This class handles the necessary slots, in particular all those already handled by qt_view_widget_rep. It also marks the enclosed QWidget as a "texmacs_window_widget" using QObject::setProperty(). This will be checked by qt_view_widget_rep::read()'s SLOT_WINDOW.

Definition at line 360 of file qt_ui_element.cpp.


Constructor & Destructor Documentation

Definition at line 364 of file qt_ui_element.cpp.

                                          : qt_view_widget_rep(w) {
    ASSERT(w != NULL, "Null QWidgets cannot be promoted to windows");
    w->setProperty ("texmacs_window_widget", QVariant::fromValue ((void*) this));
  };

Definition at line 368 of file qt_ui_element.cpp.

{};

Member Function Documentation

QAction * qt_widget_rep::as_qaction ( ) [virtual, inherited]

Reimplemented in qt_glue_widget_rep, qt_ui_element_rep, simple_widget_rep, qt_menu_rep, and qt_input_text_widget_rep.

Definition at line 106 of file qt_menu.cpp.

                                   {
  QAction *a = new QTMAction (NULL); 
  //  a->setSeparator(true);
  a->setEnabled(false);
  return a;
};
virtual QLayoutItem* qt_widget_rep::as_qlayoutitem ( ) [inline, virtual, inherited]

Returns a QLayoutItem...

Reimplemented in qt_ui_element_rep, and qt_input_text_widget_rep.

Definition at line 84 of file qt_widget.hpp.

{ return NULL; }
virtual QWidget* qt_view_widget_rep::as_qwidget ( ) [inline, virtual, inherited]

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 42 of file qt_view_widget.hpp.

{ return view ; };
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:

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; }

Definition at line 41 of file qt_view_widget.hpp.

{  return current_renderer; }

Here is the caller graph for this function:

virtual QMenu* qt_widget_rep::get_qmenu ( ) [inline, virtual, inherited]

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 in qt_ui_element_rep, and qt_menu_rep.

Definition at line 74 of file qt_widget.hpp.

{ return NULL; }
widget qt_widget_rep::make_popup_widget ( ) [virtual, inherited]

Reimplemented in qt_ui_element_rep, and qt_menu_rep.

Definition at line 34 of file qt_widget.cpp.

                                  {
  return this;
}
void qt_view_widget_rep::notify ( slot  s,
blackbox  new_val 
) [virtual, inherited]

Notification of state changes Overriden to provide debugging support.

Can be removed.

Reimplemented from widget_rep.

Reimplemented in simple_widget_rep, and simple_widget_rep.

Definition at line 186 of file qt_view_widget.cpp.

                                                    {
  if (DEBUG_QT)
    cout << "qt_view_widget_rep::notify " << slot_name(s) << LF;
  qt_widget_rep::notify (s, new_val);
}

Here is the call graph for this function:

widget qt_view_widget_rep::plain_window_widget ( string  s,
command  q 
) [virtual, inherited]

Sets the view's title to _title, then constructs a wrapper widget for the view and returns it.

Reimplemented from qt_widget_rep.

Reimplemented in qt_tm_widget_rep.

Definition at line 237 of file qt_view_widget.cpp.

                                                                 {
  view->setWindowTitle (to_qstring (_title));
  widget wid= tm_new<qt_window_widget_rep> (view, q);
    //FIXME: is this the right thing to do?
  return wid;
}

Here is the call graph for this function:

widget qt_widget_rep::popup_window_widget ( string  s) [virtual, inherited]

Reimplemented in qt_ui_element_rep, and qt_menu_rep.

Definition at line 39 of file qt_widget.cpp.

                                            {
  (void) s;
  return widget ();
}
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 qt_view_widget_rep::query ( slot  s,
int  type_id 
) [virtual, inherited]

Querying.

Reimplemented from widget_rep.

Reimplemented in qt_tm_widget_rep, qt_tm_widget_rep, simple_widget_rep, and simple_widget_rep.

Definition at line 124 of file qt_view_widget.cpp.

                                              {
  if ((DEBUG_QT) && (s != SLOT_RENDERER))
    cout << "qt_view_widget_rep::query " << slot_name(s) << LF;
  
  switch (s) {
    case SLOT_IDENTIFIER:
      TYPE_CHECK (type_id == type_helper<int>::id);
        // return close_box<int> ((int)view->window());
        // we need only to know if the widget is attached to some gui window
      return close_box<int> (view->window() ? 1 : 0);
#if 0
    case SLOT_RENDERER:
    {
      TYPE_CHECK (type_id == type_helper<renderer>::id);
      renderer r = get_current_renderer();
        //FIXME: sometimes the renderer is queried outside repaint events 
        //       (see e.g. edit_interface_rep::idle_time)
        //       TeXmacs current policy is that we should return NULL only 
        //       if the widget is not attached (in X11 sense)
      if (!r) 
        r = the_qt_renderer();
      
      QTMWidget *canvas = qobject_cast <QTMWidget*>(view);
      if (r && canvas) {
        SI ox = -canvas->backing_pos.x()*PIXEL;
        SI oy = canvas->backing_pos.y()*PIXEL;
        r->set_origin(ox,oy);
      }
      
      return close_box<renderer> (r);
    }      
#endif
      
    case SLOT_POSITION:
    {
      typedef pair<SI,SI> coord2;
      TYPE_CHECK (type_id == type_helper<coord2>::id);
      QPoint pt= view->pos();
      if (DEBUG_QT)
        cout << "Position (" << pt.x() << "," << pt.y() << ")\n";
      return close_box<coord2> (from_qpoint (pt));
    }

    case SLOT_SIZE:
    {
      typedef pair<SI,SI> coord2;
      TYPE_CHECK (type_id == type_helper<coord2>::id);
      QSize s= view->size();
      return close_box<coord2> (from_qsize (s));
    }
      
    default:
      FAILED ("cannot handle slot type");
      return blackbox ();
  }
}

Here is the call graph for this function:

widget qt_view_widget_rep::read ( slot  s,
blackbox  index 
) [virtual, inherited]

Read access to subwidgets.

Reimplemented from widget_rep.

Reimplemented in qt_tm_widget_rep, qt_tm_widget_rep, simple_widget_rep, and simple_widget_rep.

Definition at line 196 of file qt_view_widget.cpp.

                                                {
  if (DEBUG_QT)
    cout << "qt_view_widget_rep::read " << slot_name(s) << LF;
  
  switch (s) {
    case SLOT_WINDOW:
    {
      check_type_void (index, "SLOT_WINDOW");
      QWidget* qwin = view->window();
      QVariant v= qwin->property ("texmacs_window_widget");
      if (v.canConvert<void*> ())
        return (widget_rep*) (v.value<void*> ());
      else FAILED ("QWidget property not set");
    }
      break; // not reached     
    default:
      FAILED ("cannot handle slot type");
      return widget();
  }
}

Here is the call graph for this function:

void qt_plain_window_widget_rep::send ( slot  s,
blackbox  val 
) [virtual]

Reimplemented from qt_view_widget_rep.

Definition at line 375 of file qt_ui_element.cpp.

                                                      {
  if (DEBUG_QT)
    cout << "qt_plain_widget_rep::send " << slot_name(s) << LF;
  switch (s) {
    case SLOT_POSITION:
    {
      TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
      coord2 p= open_box<coord2> (val);
      if (view) {
        QPoint pt = to_qpoint (p);
        pt.ry() += 40;
        // to avoid window under menu bar on MAC when moving at (0,0)
        if (DEBUG_QT) 
          cout << "Moving to (" << pt.x() << "," 
          << pt.y() << ")" << LF;
        view->move (pt);
      }
    }
      break;
    case SLOT_VISIBILITY:
    {   
      check_type<bool> (val, "SLOT_VISIBILITY");
      bool flag = open_box<bool> (val);
      if (flag)
        view->show();
      else 
        view->hide();
    }   
      break;
    default:
      qt_view_widget_rep::send (s,val);
  }
}

Here is the call graph for this function:

void qt_view_widget_rep::set_current_renderer ( basic_renderer  _r) [inline, inherited]

Definition at line 40 of file qt_view_widget.hpp.

{ current_renderer = _r;  }

Here is the caller graph for this function:

void qt_view_widget_rep::write ( slot  s,
blackbox  index,
widget  w 
) [virtual, inherited]

Write access to subwidgets.

Reimplemented from widget_rep.

Reimplemented in qt_tm_widget_rep, qt_tm_widget_rep, simple_widget_rep, and simple_widget_rep.

Definition at line 221 of file qt_view_widget.cpp.

                                                           {
  (void) index; (void) w;
  if (DEBUG_QT)
    cout << "qt_view_widget_rep::write " << slot_name (s) << LF;
  switch (s) {
    default:
      FAILED ("cannot handle slot type");
  }
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class widget [friend, inherited]

Definition at line 59 of file widget.hpp.


Member Data Documentation

Definition at line 27 of file qt_view_widget.hpp.

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

Definition at line 36 of file widget.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.

QWidget* qt_view_widget_rep::view [inherited]

Definition at line 26 of file qt_view_widget.hpp.


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