Back to index

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

#include <qt_view_widget.hpp>

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

List of all members.

Public Member Functions

 qt_view_widget_rep (QWidget *v)
 Constructor.
 ~qt_view_widget_rep ()
 FIXME: I'm (MG) not sure if we should delete manually all the QWidgets we create or exclusively the top level ones (the windows)
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

See also:
qt_plain_window_widget_rep

Definition at line 24 of file qt_view_widget.hpp.


Constructor & Destructor Documentation

Constructor.

Sets the view to the specified QWidget, of which it takes ownership.

Definition at line 34 of file qt_view_widget.cpp.

 : qt_widget_rep(), view(v), current_renderer(NULL)  {}

FIXME: I'm (MG) not sure if we should delete manually all the QWidgets we create or exclusively the top level ones (the windows)

  • Qt specifies that widgets with a parent are deleted by the parent.
  • Our policy is that qt_view_widget_rep owns the QWidget (so it is responsible to delete it) Are these two requirements compatible ?

Definition at line 45 of file qt_view_widget.cpp.

                                        {
  if (view) // this is redundant: delete does nothing if view==NULL
    delete view;
  if (DEBUG_QT)
    cout << "qt_view_widget_rep::~qt_view_widget_rep()\n";
}

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]

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]

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:

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]

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]

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_view_widget_rep::send ( slot  s,
blackbox  val 
) [virtual]

Reimplemented from widget_rep.

Reimplemented in qt_plain_window_widget_rep, qt_tm_widget_rep, qt_tm_widget_rep, simple_widget_rep, and simple_widget_rep.

Definition at line 54 of file qt_view_widget.cpp.

                                              {
  if (DEBUG_QT)
    cout << "qt_view_widget_rep::send " << slot_name (s) << LF;

  switch (s) {
    case SLOT_NAME:
    {   
      check_type<string> (val, "SLOT_NAME");
      string name = open_box<string> (val);
      view->window() -> setWindowTitle (to_qstring (tm_var_encode(name)));
    }
      break;

    case SLOT_INVALIDATE:
    {
      TYPE_CHECK (type_box (val) == type_helper<coord4>::id);
      coord4 p= open_box<coord4> (val);
      if (DEBUG_QT)
        cout << "Invalidating rect " << rectangle(p.x1,p.x2,p.x3,p.x4) << LF;
      qt_renderer_rep* ren = (qt_renderer_rep*)get_renderer (this);
      QTMWidget *canvas = qobject_cast <QTMWidget*>(view);
      if (ren && canvas) {
        SI x1 = p.x1, y1 = p.x2, x2 = p.x3, y2 = p.x4;    
        ren->outer_round (x1, y1, x2, y2);
        ren->decode (x1, y1);
        ren->decode (x2, y2);
        canvas->invalidate_rect (x1,y2,x2,y1);
      }
    }
      break;
    case SLOT_INVALIDATE_ALL:
    {
      ASSERT (is_nil (val), "type mismatch");
      if (DEBUG_QT)
        cout << "Invalidating all"<<  LF;
      QTMWidget *canvas = qobject_cast <QTMWidget*>(view);
      if (canvas) canvas->invalidate_all ();
    }
      break;

    case SLOT_MOUSE_GRAB:
      NOT_IMPLEMENTED;
      //send_mouse_grab (THIS, val);
      break;
      
    case SLOT_MOUSE_POINTER:
      NOT_IMPLEMENTED;
      //send_mouse_pointer (THIS, val);
      break;
      
    case SLOT_KEYBOARD_FOCUS:
      //send_keyboard_focus (THIS, val);
      TYPE_CHECK (type_box (val) == type_helper<bool>::id);
      if (open_box<bool> (val)) 
        the_keyboard_focus = this;
      if (DEBUG_QT)
        cout << "Ignored!\n";
      break;
    case SLOT_REFRESH:
      // This message is sent to refresh special widgets. Usually we just ignore it.
      break;
    default:
      FAILED ("unhandled slot type");
  }
}

Here is the call graph for this function:

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]

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.

Definition at line 26 of file qt_view_widget.hpp.


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