Back to index

texmacs  1.0.7.15
wait_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : wait.cpp
00004 * DESCRIPTION: Popup wait indicators
00005 * COPYRIGHT  : (C) 1999  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 "analyze.hpp"
00013 #include "gui.hpp"
00014 #include "window.hpp"
00015 #include "renderer.hpp"
00016 #include "font.hpp"
00017 #include "Widkit/basic_widget.hpp"
00018 #include "dictionary.hpp"
00019 
00020 /******************************************************************************
00021 * Wait widgets
00022 ******************************************************************************/
00023 
00024 class wait_widget_rep: public basic_widget_rep {
00025   string wait_s;
00026   string message;
00027 public:
00028   wait_widget_rep (SI width, SI height, string message);
00029   operator tree ();
00030 
00031   void handle_get_size (get_size_event ev);
00032   void handle_repaint (repaint_event ev);
00033 };
00034 
00035 /******************************************************************************
00036 * Implementation of wait decoration widgets
00037 ******************************************************************************/
00038 
00039 wait_widget_rep::wait_widget_rep (SI width, SI height, string s):
00040   basic_widget_rep (0, south_west), message (s)
00041 {
00042   w= width; h= height;
00043   string out_lan= get_output_language ();
00044   wait_s = translate ("please wait");
00045   message= tm_var_encode (s);
00046   wait_s= upcase_all (wait_s);
00047 }
00048 
00049 wait_widget_rep::operator tree () {
00050   return tree (TUPLE, "wait indicator", message);
00051 }
00052 
00053 void
00054 wait_widget_rep::handle_get_size (get_size_event ev) {
00055   ev->w= w;
00056   ev->h= h;
00057 }
00058 
00059 extern font the_default_wait_font;
00060 
00061 void
00062 wait_widget_rep::handle_repaint (repaint_event ev) {
00063   (void) ev;
00064   renderer ren= win->get_renderer ();
00065   ren->set_background (rgb_color (255, 255, 160));
00066   ren->clear (0, 0, w, h);
00067   ren->set_color (black);
00068   ren->line (0, 0, w-PIXEL, 0);
00069   ren->line (0, h-PIXEL, w-PIXEL, h-PIXEL);
00070   ren->line (0, 0, 0, h);
00071   ren->line (w-PIXEL, 0, w-PIXEL, h-PIXEL);
00072 
00073   font fn= the_default_wait_font;
00074   ren->set_shrinking_factor (3);
00075   metric ex;
00076   fn->var_get_extents (wait_s, ex);
00077   SI x= (3*w - (ex->x1+ex->x2)) >> 1;
00078   SI y= 2*h - ((ex->y1+ex->y2) >> 1);
00079   ren->set_color (red);
00080   fn->var_draw (ren, wait_s, x, y);
00081   fn->var_get_extents (message, ex);
00082   x= (3*w - (ex->x1+ex->x2)) >> 1;
00083   y= h - ((ex->y1+ex->y2) >> 1);
00084   ren->set_color (black);
00085   fn->var_draw (ren, message, x, y);
00086   ren->set_shrinking_factor (1);
00087 }
00088 
00089 /******************************************************************************
00090 * exported routines
00091 ******************************************************************************/
00092 
00093 wk_widget
00094 wait_wk_widget (SI width, SI height, string message) {
00095   return tm_new<wait_widget_rep> (width, height, message);
00096 }