Back to index

texmacs  1.0.7.15
Classes | Enumerations | Functions | Variables
qt_gui.cpp File Reference
#include "iterator.hpp"
#include "dictionary.hpp"
#include "qt_gui.hpp"
#include "qt_utilities.hpp"
#include "analyze.hpp"
#include <locale.h>
#include "language.hpp"
#include "message.hpp"
#include <QDesktopWidget>
#include <QClipboard>
#include <QFileOpenEvent>
#include <QStackedLayout>
#include <QLabel>
#include <QSocketNotifier>
#include <QSetIterator>
#include "QTMGuiHelper.hpp"
#include "QTMWidget.hpp"
#include "QTMWindow.hpp"
#include "qt_renderer.hpp"
#include "tm_link.hpp"
#include "scheme.hpp"
#include "qt_simple_widget.hpp"
#include "qt_window_widget.hpp"

Go to the source code of this file.

Classes

class  qp_type
class  queued_event

Enumerations

enum  qp_type_id {
  QP_NULL, QP_KEYPRESS, QP_KEYBOARD_FOCUS, QP_MOUSE,
  QP_RESIZE, QP_SOCKET_NOTIFICATION, QP_COMMAND, QP_COMMAND_ARGS,
  QP_DELAYED_COMMANDS
}

Functions

void gui_interpose (void(*r)(void))
void exec_delayed (object cmd)
void exec_delayed_pause (object cmd)
void exec_pending_commands ()
void clear_pending_commands ()
void gui_open (int &argc, char **argv)
void gui_start_loop ()
void gui_close ()
void gui_root_extents (SI &width, SI &height)
void gui_maximal_extents (SI &width, SI &height)
void gui_refresh ()
void process_event (queued_event ev)
queued_event next_event ()
void add_event (const queued_event &ev)
void fill_event_queue ()
void set_default_font (string name)
font get_default_font (bool tt, bool mini, bool bold)
void load_system_font (string family, int size, int dpi, font_metric &fnm, font_glyphs &fng)
bool set_selection (string key, tree t, string s, string format)
bool get_selection (string key, tree &t, string &s, string format)
void clear_selection (string key)
void beep ()
void force_update ()
void needs_update ()
bool check_event (int type)
void image_gc (string name)
void show_help_balloon (widget balloon, SI x, SI y)
void show_wait_indicator (widget base, string message, string argument)
void external_event (string type, time_t t)
font x_font (string family, int size, int dpi)

Variables

window(* get_current_window )(void)
qt_gui_repthe_gui = NULL
int nr_windows = 0
time_t time_credit = 100
time_t timeout_time
time_t lapse = 0
bool disable_check_event = false
bool updating = false
bool needing_update = false
bool wait_for_delayed_commands = true
void(* the_interpose_handler )(void) = NULL
static hashmap
< socket_notifier, pointer
read_notifiers
static hashmap
< socket_notifier, pointer
write_notifiers
static array< objectdelayed_queue
static array< time_tstart_queue
static array< queued_eventwaiting_events
int char_clip = 0

Enumeration Type Documentation

enum qp_type_id
Enumerator:
QP_NULL 
QP_KEYPRESS 
QP_KEYBOARD_FOCUS 
QP_MOUSE 
QP_RESIZE 
QP_SOCKET_NOTIFICATION 
QP_COMMAND 
QP_COMMAND_ARGS 
QP_DELAYED_COMMANDS 

Definition at line 580 of file qt_gui.cpp.


Function Documentation

void add_event ( const queued_event ev)

Definition at line 738 of file qt_gui.cpp.

{
  if (updating) {
    waiting_events << ev;
    needing_update = true;
    //needs_update();
  } else {
    waiting_events << ev;
//    process_event(ev);
    needs_update();
    // NOTE: we cannot update now since sometimes this seems to give problems
    // to the update of the window size after a resize. In that situation
    // sometimes when the window take again focus, update will be called for the
    // focus_in event and interpose_handler is run which send a slot_extent
    // message to the widget causing a wrong resize of the window.
    // this seems to cure the problem.
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void beep ( )

Definition at line 1040 of file qt_gui.cpp.

        {
  // Issue a beep
  QApplication::beep();
}

Here is the call graph for this function:

bool check_event ( int  type)

Definition at line 1069 of file qt_gui.cpp.

                       {
  // Check whether an event of one of the above types has occurred;
  // we check for keyboard events while repainting windows
  return the_gui->check_event(type);
}

Here is the call graph for this function:

Definition at line 448 of file qt_gui.cpp.

Here is the caller graph for this function:

void clear_selection ( string  key)

Definition at line 1029 of file qt_gui.cpp.

                             {
  // Clear the selection on clipboard 'cb'
  the_gui->clear_selection (key);
}

Here is the call graph for this function:

void exec_delayed ( object  cmd)

Definition at line 400 of file qt_gui.cpp.

                          {
  delayed_queue << cmd;
  start_queue << (((time_t) texmacs_time ()) - 1000000000);
  lapse = texmacs_time();
  needs_update();
}

Here is the caller graph for this function:

void exec_delayed_pause ( object  cmd)

Definition at line 408 of file qt_gui.cpp.

Here is the caller graph for this function:

Definition at line 416 of file qt_gui.cpp.

                         {
  array<object> a= delayed_queue;
  array<time_t> b= start_queue;
  delayed_queue= array<object> (0);
  start_queue= array<time_t> (0);
  int i, n= N(a);
  for (i=0; i<n; i++) {
    time_t now=  texmacs_time ();
    if ((now - b[i]) >= 0) {
      object obj= call (a[i]);
      if (is_int (obj) && (now - b[i] < 1000000000)) {
        time_t pause = as_int (obj);
        //cout << "pause= " << obj << "\n";
        delayed_queue << a[i];
        start_queue << (now + pause);
      }
    }
    else {
      delayed_queue << a[i];
      start_queue << b[i];
    }
  }
  if (N(delayed_queue)>0) {
    lapse = start_queue[0];
    int n = N(start_queue);
    for (i=1; i<n; i++) {
      if (lapse > start_queue[i]) lapse = start_queue[i];
    }
  }
}

Here is the caller graph for this function:

void external_event ( string  type,
time_t  t 
)

Definition at line 1098 of file qt_gui.cpp.

                                       {
  // External events, such as pushing a button of a remote infrared commander
  QTMWidget *tm_focus = qobject_cast<QTMWidget*>(qApp->focusWidget());
  if (tm_focus) {
    simple_widget_rep *wid = tm_focus->tm_widget();
    if (wid) the_gui -> process_keypress (wid, type, t);
  }
}

Here is the call graph for this function:

void fill_event_queue ( )

Definition at line 824 of file qt_gui.cpp.

                   {
  if (N(waiting_events) == 0) {
    qApp->processEvents(QEventLoop::ExcludeSocketNotifiers, 0); 
    // if (N(waiting_events) > 0) cout << "addins some events" << LF;
  }  
}

Here is the call graph for this function:

void force_update ( )

Definition at line 1046 of file qt_gui.cpp.

               {
  if (updating) {
    needing_update = true;
  }
  else {
    the_gui->update();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

font get_default_font ( bool  tt,
bool  mini,
bool  bold 
)

Definition at line 989 of file qt_gui.cpp.

                                                 {
  (void) tt; (void) mini; (void) bold;
  // get the default font or monospaced font (if tt is true)
        
  // return a null font since this function is not called in the Qt port.
  if (DEBUG_QT) cout << "get_default_font(): SHOULD NOT BE CALLED\n";
  return NULL;
  //return tex_font (this, "ecrm", 10, 300, 0);
}
bool get_selection ( string  key,
tree t,
string s,
string  format 
)

Definition at line 1022 of file qt_gui.cpp.

                                                              {
  // Retrieve the selection 't' with string equivalent 's' from clipboard 'cb'
  // Returns true on success; sets t to (extern s) for external selections
  return the_gui->get_selection (key, t, s, format);
}

Here is the call graph for this function:

void gui_close ( )

Definition at line 476 of file qt_gui.cpp.

             {
  // cleanly close the gui
  ASSERT (the_gui != NULL, "gui not yet open");
  tm_delete (the_gui);
  the_gui=NULL;

#ifdef MACOSX_EXTENSIONS
  mac_end_remote();
#endif
}

Here is the call graph for this function:

void gui_interpose ( void(*)(void)  r)

Definition at line 309 of file qt_gui.cpp.

void gui_maximal_extents ( SI width,
SI height 
)

Definition at line 496 of file qt_gui.cpp.

                                            {
  // get the maximal size of a window (can be larger than the screen size)
  the_gui->get_max_size (width, height);
  if (DEBUG_QT) 
    cout << "gui_maximal_extents (" << width << "," << height << ")" << LF;
}

Here is the call graph for this function:

void gui_open ( int &  argc,
char **  argv 
)

Definition at line 459 of file qt_gui.cpp.

                                  {
  // start the gui
 // new QApplication (argc,argv); now in texmacs.cpp
  the_gui = tm_new<qt_gui_rep> (argc, argv);
  
#ifdef MACOSX_EXTENSIONS
  mac_begin_remote();
#endif
}

Here is the call graph for this function:

void gui_refresh ( )

Definition at line 504 of file qt_gui.cpp.

               {
  // called upon change of output language
  // emit a signal which force every QTMAction to change his text
  // according to the new language

  the_gui->gui_helper->doRefresh();
}

Here is the call graph for this function:

void gui_root_extents ( SI width,
SI height 
)

Definition at line 488 of file qt_gui.cpp.

                                         {
  // get the screen size
  the_gui->get_extents (width, height);
  if (DEBUG_QT) 
    cout << "gui_root_extents (" << width << "," << height << ")" << LF;
}

Here is the call graph for this function:

void gui_start_loop ( )

Definition at line 470 of file qt_gui.cpp.

                  {
  // start the main loop
  the_gui->event_loop ();
}

Here is the call graph for this function:

void image_gc ( string  name)

Definition at line 1075 of file qt_gui.cpp.

                            {
// Garbage collect images of a given name (may use wildcards)
// This routine only needs to be implemented if you use your own image cache
 the_qt_renderer()->image_gc(name);
}

Here is the call graph for this function:

void load_system_font ( string  family,
int  size,
int  dpi,
font_metric fnm,
font_glyphs &  fng 
)

Definition at line 1003 of file qt_gui.cpp.

{
  (void) family; (void) size; (void) dpi; (void) fnm; (void) fng;
  if (DEBUG_QT) cout << "load_system_font(): SHOULD NOT BE CALLED\n";
}
void needs_update ( )

Definition at line 1056 of file qt_gui.cpp.

                {
  // 0 ms - call immediately when all other events have 
  // been processed
  //cout << "needs_update" << LF;
  if (updating) {
    needing_update = true;
  }
  else {
    the_gui->updatetimer->start (0);
  }
}

Definition at line 692 of file qt_gui.cpp.

             {
  queued_event ev;
  if (N(waiting_events)>0) 
    ev = waiting_events[0];
  
  array<queued_event> a;

  for(int i=1; i<N(waiting_events); i++)
    a << waiting_events[i];
  waiting_events = a;
  
  return ev;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 619 of file qt_gui.cpp.

                                {
  //cout << "<" << (qp_type_id) ev.x1 << LF;
  switch ((qp_type_id) ev.x1) {
    case QP_NULL :
      break;
    case QP_KEYPRESS :
    {
      typedef triple<widget, string, time_t > T;
      T x = open_box <T> (ev.x2) ;
      concrete_simple_widget(x.x1) -> handle_keypress (x.x2, x.x3) ;
    }
      break;
    case QP_KEYBOARD_FOCUS :
    {
      typedef triple<widget, bool, time_t > T;
      T x = open_box <T> (ev.x2) ;
      concrete_simple_widget(x.x1) -> handle_keyboard_focus (x.x2, x.x3) ;
    }
      break;
    case QP_MOUSE :
    {
      typedef quintuple<string, SI, SI, int, time_t > T1;
      typedef pair<widget, T1> T;
      T x = open_box <T> (ev.x2) ;
      concrete_simple_widget(x.x1) -> handle_mouse (x.x2.x1, x.x2.x2, x.x2.x3, x.x2.x4, x.x2.x5) ;
    }
      break;
    case QP_RESIZE :
    {
      typedef triple<widget, SI, SI > T;
      T x = open_box <T> (ev.x2) ;
      concrete_simple_widget(x.x1) -> handle_notify_resize (x.x2, x.x3) ;
    }
      break;
    case QP_SOCKET_NOTIFICATION :
    {
      socket_notifier sn = open_box <socket_notifier> (ev.x2) ;
      // cout << "QP_SOCKET_NOTIFICATION " << sn->fd << LF;
      sn -> notify ();
      the_gui->enable_notifier (sn, true);
    }
      break;
    case QP_COMMAND :
    {
      command cmd = open_box <command> (ev.x2) ;
      // cout << "QP_COMMAND" << LF;
      cmd->apply();
    }
      break;
    case QP_COMMAND_ARGS :
    {
      typedef pair<command, object> T;
      T x = open_box <T> (ev.x2) ;
      // cout << "QP_COMMAND_ARGS" << LF;
      x.x1->apply(x.x2);
    }
      break;
    case QP_DELAYED_COMMANDS :
    {
      // cout << "QP_DELAYED_COMMANDS" << LF;
      exec_pending_commands();
      wait_for_delayed_commands = true;
    }
      break;
    default:   
      FAILED("Unexpected queued event");
  }
  //cout << ">" << (qp_type_id) ev.x1 << LF;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_default_font ( string  name)

Definition at line 982 of file qt_gui.cpp.

                               {
  (void) name;
  // set the name of the default font
  // this is ignored since Qt handles fonts for the widgets
}
bool set_selection ( string  key,
tree  t,
string  s,
string  format 
)

Definition at line 1015 of file qt_gui.cpp.

                                                            {
  // Copy a selection 't' with string equivalent 's' to the clipboard 'cb'
  // Returns true on success
  return the_gui->set_selection (key, t, s, format);
}

Here is the call graph for this function:

void show_help_balloon ( widget  balloon,
SI  x,
SI  y 
)

Definition at line 1082 of file qt_gui.cpp.

                                               {
  // Display a help balloon at position (x, y); the help balloon should
  // disappear as soon as the user presses a key or moves the mouse
  (void) balloon; (void) x; (void) y;
}
void show_wait_indicator ( widget  base,
string  message,
string  argument 
)

Definition at line 1089 of file qt_gui.cpp.

                                                                   {
  // Display a wait indicator with a message and an optional argument
  // The indicator might for instance be displayed at the center of
  // the base widget which triggered the lengthy operation;
  // the indicator should be removed if the message is empty
  the_gui->show_wait_indicator(base,message,argument);
}

Here is the call graph for this function:

font x_font ( string  family,
int  size,
int  dpi 
)

Definition at line 1107 of file qt_gui.cpp.

{
  (void) family; (void) size; (void) dpi;
  if (DEBUG_QT) cout << "x_font(): SHOULD NOT BE CALLED\n";
  return NULL;
}

Variable Documentation

int char_clip = 0

Definition at line 1037 of file qt_gui.cpp.

Definition at line 396 of file qt_gui.cpp.

bool disable_check_event = false

Definition at line 55 of file qt_gui.cpp.

Definition at line 52 of file qt_gui.cpp.

bool needing_update = false

Definition at line 57 of file qt_gui.cpp.

int nr_windows = 0

Definition at line 48 of file qt_gui.cpp.

Definition at line 323 of file qt_gui.cpp.

Definition at line 397 of file qt_gui.cpp.

Definition at line 47 of file qt_gui.cpp.

void(* the_interpose_handler)(void) = NULL

Definition at line 307 of file qt_gui.cpp.

Definition at line 50 of file qt_gui.cpp.

Definition at line 51 of file qt_gui.cpp.

bool updating = false

Definition at line 56 of file qt_gui.cpp.

Definition at line 58 of file qt_gui.cpp.

Definition at line 615 of file qt_gui.cpp.

Definition at line 324 of file qt_gui.cpp.