Exemple #1
0
/* Kreslicí funkce spoleèná pro gtk_ev_draw() a gtk_ev_expose(), která kreslí
 * vnitøní okno widgetu */
static void gtk_ev_paint_ev_win(GtkEv *ev, GdkRectangle *area)
{
    GtkWidget *widget;
    gint width, x, y;
    const char *title = "Event Window";
    GdkFont *font;

    g_return_if_fail(ev);
    g_return_if_fail(area);

    widget = GTK_WIDGET(ev);
    font = gtk_style_get_font(widget->style);
    if(!GTK_WIDGET_DRAWABLE(ev))
        return;

    gdk_window_clear_area(ev->ev_win, area->x, area->y,
                          area->width, area->height);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, area);

    width = gdk_string_width(font, title);

    x = (ev->ev_win_rect.width - width)/2;
    y = font->ascent + 2;

    gdk_draw_string(ev->ev_win, font, widget->style->black_gc, x, y, title);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, NULL);
}
Exemple #2
0
static void
gtk_pizza_draw (GtkWidget    *widget,
                GdkRectangle *area)
{
    GtkPizza *pizza;
    GtkPizzaChild *child;
    GdkRectangle child_area;
    GList *children;

    g_return_if_fail (widget != NULL);
    g_return_if_fail (GTK_IS_PIZZA (widget));

    pizza = GTK_PIZZA (widget);

    /* Sometimes, We handle all expose events in window.cpp now. */
    if (pizza->external_expose)
        return;

    children = pizza->children;
    if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) &&
         (pizza->clear_on_draw))
    {
        gdk_window_clear_area( pizza->bin_window,
                                area->x, area->y, area->width, area->height);
    }

    while (children)
    {
        child = children->data;
        children = children->next;

        if (gtk_widget_intersect (child->widget, area, &child_area))
            gtk_widget_draw (child->widget, &child_area);
    }
}
Exemple #3
0
static gboolean
transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
  gdk_window_clear_area (widget->window, event->area.x, event->area.y,
			 event->area.width, event->area.height);
  return FALSE;
}
static gboolean
transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
  GtkWidget *focus_child = NULL;
  gint border_width, x, y, width, height;
  gboolean retval = FALSE;

  gdk_window_clear_area (widget->window, event->area.x, event->area.y,
                         event->area.width, event->area.height);

  if (GTK_WIDGET_CLASS (parent_class)->expose_event)
    retval = GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);

  if (GTK_CONTAINER (widget)->focus_child)
    focus_child = GTK_CONTAINER (GTK_CONTAINER (widget)->focus_child)->focus_child;
  if (focus_child && GTK_WIDGET_HAS_FOCUS (focus_child))
    {
      border_width = GTK_CONTAINER (widget)->border_width;

      x = widget->allocation.x + border_width;
      y = widget->allocation.y + border_width;

      width  = widget->allocation.width  - 2 * border_width;
      height = widget->allocation.height - 2 * border_width;

      gtk_paint_focus (widget->style, widget->window,
                       GTK_WIDGET_STATE (widget),
                       &event->area, widget, "tray_icon",
                       x, y, width, height);
    }

  return retval;
}
/* The plug window should completely occupy the area of the child, so we won't
 * get an expose event. But in case we do (the plug unmaps itself, say), this
 * expose handler draws with real or fake transparency.
 */
static gboolean
na_tray_child_expose_event (GtkWidget      *widget,
                            GdkEventExpose *event)
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);
  GdkWindow *window = gtk_widget_get_window (widget);

  if (na_tray_child_has_alpha (child))
    {
      /* Clear to transparent */
      cairo_t *cr = gdk_cairo_create (window);
      cairo_set_source_rgba (cr, 0, 0, 0, 0);
      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
      gdk_cairo_region (cr, event->region);
      cairo_fill (cr);
      cairo_destroy (cr);
    }
  else if (child->parent_relative_bg)
    {
      /* Clear to parent-relative pixmap */
      gdk_window_clear_area (window,
                             event->area.x, event->area.y,
                             event->area.width, event->area.height);
    }

  return FALSE;
}
Exemple #6
0
/* Kreslicí funkce spoleèná pro gtk_ev_draw() a gtk_ev_expose(), která kreslí
 * hlavní okno widgetu */
static void gtk_ev_paint(GtkEv *ev, GdkRectangle *area)
{
    GtkWidget *widget;
    
    g_return_if_fail(ev);
    g_return_if_fail(area);

    widget = GTK_WIDGET(ev);

    if(!GTK_WIDGET_DRAWABLE(widget))
        return; /* Not visible and mapped */

    gdk_window_clear_area(widget->window, area->x, area->y, area->width,
                          area->height);
    gdk_gc_set_clip_rectangle(widget->style->black_gc, area);

    /* Èerný rámeèek kolem vnitøního okna */
    gdk_draw_rectangle(widget->window, widget->style->black_gc, FALSE,
                       ev->ev_win_rect.x-1, ev->ev_win_rect.y-1,
                       ev->ev_win_rect.width+2, ev->ev_win_rect.height+2);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, NULL);

    /* Text (seznam zachycených událostí) */
    if(ev->list) {
        GdkRectangle intersect;

        if(gdk_rectangle_intersect(&ev->list_rect, area, &intersect)) {
            static const gint space = 2;
            gint line, step, first_baseline;
            GList *p;
	    GdkFont *font = gtk_style_get_font(widget->style);

            step = font->ascent + font->descent + space;
            first_baseline = ev->list_rect.y + font->ascent + space;
            line = 0;
            for(p = ev->list; p; p = g_list_next(p)) {
                gchar **pev = p->data;
                gint i;
                
                for(i = 0; pev[i]; i++) {
                    gtk_paint_string(widget->style, widget->window,
                                     widget->state, &intersect, widget,
                                     (char *) "ev", ev->list_rect.x,
                                     first_baseline + line*step, pev[i]);
                    line++;
                }
                
                if(first_baseline + line*step - 2*step >
                   intersect.y + intersect.height)
                    break;
            }
        }
    }

    /* Grafické zvýraznìní, kdy¾ má okno focus */
    if(GTK_WIDGET_HAS_FOCUS(widget))
        gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(widget),
			area, widget, (char *) "ev", 0, 0, -1, -1);
}
Exemple #7
0
na_tray_child_expose_event (GtkWidget      *widget,
                            GdkEventExpose *event)
#endif
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);
  GdkWindow *window = gtk_widget_get_window (widget);

  if (na_tray_child_has_alpha (child))
    {
      /* Clear to transparent */
#if !GTK_CHECK_VERSION (3, 0, 0)
      cairo_t *cr = gdk_cairo_create (window);
#endif
      cairo_set_source_rgba (cr, 0, 0, 0, 0);
      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
#if GTK_CHECK_VERSION (3, 0, 0)
      cairo_paint (cr);
#else
      gdk_cairo_region (cr, event->region);
      cairo_fill (cr);
      cairo_destroy (cr);
#endif
    }
  else if (child->parent_relative_bg)
    {
      /* Clear to parent-relative pixmap */
#if GTK_CHECK_VERSION (3, 0, 0)
      GdkWindow *window;
      cairo_surface_t *target;
      GdkRectangle clip_rect;

      window = gtk_widget_get_window (widget);
      target = cairo_get_group_target (cr);

      gdk_cairo_get_clip_rectangle (cr, &clip_rect);

      /* Clear to parent-relative pixmap
       * We need to use direct X access here because GDK doesn't know about
       * the parent relative pixmap. */
      cairo_surface_flush (target);

      XClearArea (GDK_WINDOW_XDISPLAY (window),
                  GDK_WINDOW_XID (window),
                  clip_rect.x, clip_rect.y,
                  clip_rect.width, clip_rect.height,
                  False);
      cairo_surface_mark_dirty_rectangle (target,
                                          clip_rect.x, clip_rect.y,
                                          clip_rect.width, clip_rect.height);
#else
      gdk_window_clear_area (window,
                             event->area.x, event->area.y,
                             event->area.width, event->area.height);
#endif
    }

  return FALSE;
}
static gboolean
na_tray_manager_socket_exposed (GtkWidget      *widget,
                                GdkEventExpose *event,
                                gpointer        user_data)
{
  gdk_window_clear_area (widget->window,
                         event->area.x, event->area.y,
                         event->area.width, event->area.height);
  return FALSE;
}
Exemple #9
0
static gboolean
egg_tray_manager_socket_exposed (GtkWidget      *widget,
      GdkEventExpose *event,
      gpointer        user_data)
{
    ENTER;
    gdk_window_clear_area (widget->window,
          event->area.x, event->area.y,
          event->area.width, event->area.height);
    RET(FALSE);
}
Exemple #10
0
static gboolean
gwy_color_axis_expose(GtkWidget *widget,
                       GdkEventExpose *event)
{
    GwyColorAxis *axis;
    GdkGC *mygc;

    gwy_debug("");

    g_return_val_if_fail(widget != NULL, FALSE);
    g_return_val_if_fail(GWY_IS_COLOR_AXIS(widget), FALSE);
    g_return_val_if_fail(event != NULL, FALSE);

    if (event->count > 0)
        return FALSE;

    axis = GWY_COLOR_AXIS(widget);

    gdk_window_clear_area(widget->window,
                          0, 0,
                          widget->allocation.width,
                          widget->allocation.height);

    mygc = gdk_gc_new(widget->window);

    if (axis->orientation == GTK_ORIENTATION_HORIZONTAL)
        gdk_pixbuf_render_to_drawable(axis->pixbuf, widget->window, mygc, 0,
                                  0,
                                  0,
                                  axis->par.textarea,
                                  widget->allocation.width,
                                  widget->allocation.height
                                    - axis->par.textarea,
                                  GDK_RGB_DITHER_NONE,
                                  0,
                                  0);
    else
        gdk_pixbuf_render_to_drawable(axis->pixbuf, widget->window, mygc, 0,
                                  0,
                                  0,
                                  0,
                                  widget->allocation.width - axis->par.textarea,
                                  widget->allocation.height,
                                  GDK_RGB_DITHER_NONE,
                                  0,
                                  0);

    g_object_unref((GObject *)mygc);

    gwy_color_axis_draw_label(widget);

    return FALSE;
}
static void
awt_gtk_panel_paint (GtkWidget    *widget,
		 GdkRectangle *area)
{
  g_return_if_fail (widget != NULL);
  g_return_if_fail (area != NULL);

  if (GTK_WIDGET_DRAWABLE (widget))
    gdk_window_clear_area (widget->window,
			   area->x, area->y,
			   area->width, area->height);
}
Exemple #12
0
static gboolean
display_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
  gdk_window_clear_area(
    widget->window,
    event->area.x, event->area.y, event->area.width, event->area.height);
  gdk_draw_pixmap(
    widget->window,
    widget->style->fg_gc[GTK_STATE_NORMAL],
    pixmap,
    0, 0,
    0, 0, pixmap_width, pixmap_height);
  return FALSE;
}
Exemple #13
0
static VALUE
gdkwin_clear_area(int argc, VALUE *argv, VALUE self)
{
    VALUE gen_expose, x, y, w, h;
    rb_scan_args(argc, argv, "41", &x, &y, &w, &h, &gen_expose);

    if (! NIL_P(gen_expose) && RVAL2CBOOL(gen_expose)){
        gdk_window_clear_area_e(_SELF(self),
                                NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
    } else {
        gdk_window_clear_area(_SELF(self),
                              NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h));
    }
    return self;
}
Exemple #14
0
static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
{
#ifdef HAVE_OPENGL
    CvWindow* window = (CvWindow*)data;

    if (window->useGl)
    {
        drawGl(window);
        return TRUE;
    }
#else
    (void)data;
#endif

  CvImageWidget *image_widget;

  g_return_val_if_fail (widget != NULL, FALSE);
  g_return_val_if_fail (CV_IS_IMAGE_WIDGET (widget), FALSE);
  g_return_val_if_fail (event != NULL, FALSE);

  if (event->count > 0)
    return FALSE;

  image_widget = CV_IMAGE_WIDGET (widget);

  gdk_window_clear_area (widget->window,
                         0, 0,
                         widget->allocation.width,
                         widget->allocation.height);
  if( image_widget->scaled_image ){
      // center image in available region
      int x0 = (widget->allocation.width - image_widget->scaled_image->cols)/2;
      int y0 = (widget->allocation.height - image_widget->scaled_image->rows)/2;

      gdk_draw_rgb_image( widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
          x0, y0, MIN(image_widget->scaled_image->cols, widget->allocation.width),
          MIN(image_widget->scaled_image->rows, widget->allocation.height),
          GDK_RGB_DITHER_MAX, image_widget->scaled_image->data.ptr, image_widget->scaled_image->step );
  }
  else if( image_widget->original_image ){
      gdk_draw_rgb_image( widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
          0, 0,
          MIN(image_widget->original_image->cols, widget->allocation.width),
           MIN(image_widget->original_image->rows, widget->allocation.height),
          GDK_RGB_DITHER_MAX, image_widget->original_image->data.ptr, image_widget->original_image->step );
  }
  return TRUE;
}
Exemple #15
0
static void
draw_ball (int x, int y)
{
	int bx, by;

	if (field [x][y].color){
		by = STONE_SIZE * (field [x][y].color - 1);
		bx = STONE_SIZE * (field [x][y].frame);
		
		gdk_draw_pixmap (draw_area->window,
				 draw_area->style->black_gc, stones,
				 bx, by, x * STONE_SIZE, y * STONE_SIZE,
				 STONE_SIZE, STONE_SIZE);
	} else {
		gdk_window_clear_area (draw_area->window, x * STONE_SIZE, y * STONE_SIZE,
				       STONE_SIZE, STONE_SIZE);
	}
}
Exemple #16
0
static gboolean
gwy_graph_label_expose(GtkWidget *widget,
                       GdkEventExpose *event)
{
    GwyGraphLabel *label;

    gwy_debug("");

    if (event->count > 0)
        return FALSE;

    label = GWY_GRAPH_LABEL(widget);
    gdk_window_clear_area(widget->window,
                          0, 0,
                          widget->allocation.width,
                          widget->allocation.height);
    gwy_graph_label_draw_label(widget);

    return FALSE;
}
Exemple #17
0
static gboolean pixmap_with_overlay_expose_event_cb(GtkWidget *widget, cairo_t *cr,
        OverlayData *data)
#endif
{
#if !GTK_CHECK_VERSION(3,0,0)
    cairo_t *cr;
    GdkWindow *drawable = gtk_widget_get_window(widget);
    gboolean result;

    cr = gdk_cairo_create(drawable);
    gdk_window_clear_area (drawable, expose->area.x, expose->area.y,
                           expose->area.width, expose->area.height);

    result = do_pix_draw(widget, cr, data);
    cairo_destroy(cr);
    return result;
#else
    return do_pix_draw(widget, cr, data);
#endif
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  struct graphics *g;
  GdkGCValues saved;
  GtkWidget *widget;
  union widget_union w;

  g = (struct graphics *) NSA_GET_PTR (env, obj);

  gdk_threads_enter ();

  if (!g)
    {
      gdk_threads_leave ();
      return;
    }
  if (GDK_IS_WINDOW (g->drawable))
    {
      w.widget = &widget;
      gdk_window_get_user_data (GDK_WINDOW (g->drawable), w.void_widget);
      if (widget == NULL || !GTK_IS_EVENT_BOX (widget))
        gdk_window_clear_area ((GdkWindow *) g->drawable,
                               x + g->x_offset, y + g->y_offset,
                               width, height);
    }
  else
    {
      gdk_gc_get_values (g->gc, &saved);
      gdk_gc_set_foreground (g->gc, &(saved.background));
      gdk_draw_rectangle (g->drawable, g->gc, TRUE, 
			  x + g->x_offset, y + g->y_offset, width, height);
      gdk_gc_set_foreground (g->gc, &(saved.foreground));
    }

  gdk_flush ();
  gdk_threads_leave ();
}
static gboolean
empathy_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
  EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (widget);
  EmpathyVideoWidgetPriv *priv = GET_PRIV (self);

  if (event != NULL && event->count > 0)
    return TRUE;

  if (priv->overlay == NULL)
    {
      gdk_window_clear_area (widget->window, 0, 0,
        widget->allocation.width, widget->allocation.height);
      return TRUE;
    }

  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (priv->overlay),
    GDK_WINDOW_XID (widget->window));

  gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay));

  return TRUE;
}
Exemple #20
0
/**
 * Check if view buffer is initialized and if so, redraw portion of it defined
 * in input parameter to the window.
 *
 * If view buffer is not defined, clear the region with black color.
 *
 * \param view pointer to generic view structure
 * \param region region of screen that need to be updated
 * \return OK on success
 */
RCode view_idv_redraw(ViewGeneric *view, GdkRectangle *region) {
	ViewImageDisplay* idv_data = NULL;

	idv_data = view_idv_get_data_pointer(view);
	if ( NULL == idv_data ) {
		return FAIL;
	}

	if ( NULL == idv_data->view_buffer ) {
		gdk_window_clear_area(view->window,
				idv_data->viewport.x, idv_data->viewport.y,
				idv_data->viewport.width, idv_data->viewport.height
			);

	} else {
		gdk_draw_pixbuf(view->window, /* GdkGC */ NULL, idv_data->view_buffer,
				region->x - view->region.x, region->y - view->region.y,
				region->x, region->y,
				region->width, region->height,
				GDK_RGB_DITHER_NONE, 0, 0
			);
	}
	return OK;
}
Exemple #21
0
/*
 * (Nearly) standard Gtk+ function
 */
static void Dw_gtk_viewport_paint (GtkWidget *widget,
                                   GdkRectangle *area,
                                   GdkEventExpose *event)
{
   GtkLayout *layout;
   DwRectangle parent_area, child_area, intersection;
   GtkDwViewport *viewport;
   gboolean new_back_pixmap;

   if (GTK_WIDGET_DRAWABLE (widget)) {
      layout = GTK_LAYOUT (widget);
      viewport = GTK_DW_VIEWPORT (widget);

      DEBUG_MSG (2, "Drawing (%d, %d), %d x %d\n",
                 area->x, area->y, area->width, area->height);

      /* Make sure the backing pixmap is large enough. */
      if (viewport->child) {
         if (viewport->back_pixmap)
            new_back_pixmap =
               (widget->allocation.width > viewport->back_width ||
                widget->allocation.height > viewport->back_height);
         else
            new_back_pixmap = TRUE;

         if (new_back_pixmap) {
            if (viewport->back_pixmap)
               gdk_pixmap_unref (viewport->back_pixmap);
            viewport->back_pixmap = gdk_pixmap_new (widget->window,
                                                    widget->allocation.width,
                                                    widget->allocation.height,
                                                    viewport->depth);
            viewport->back_width = widget->allocation.width;
            viewport->back_height = widget->allocation.height;
            DEBUG_MSG (1, "   Creating new pixmap, size = %d x %d\n",
                       widget->allocation.width, widget->allocation.height);
         }

         /* Draw top-level Dw widget. */
         parent_area.x =
            p_Dw_widget_x_viewport_to_world (viewport->child, area->x);
         parent_area.y =
            p_Dw_widget_y_viewport_to_world (viewport->child, area->y);
         parent_area.width = area->width;
         parent_area.height = area->height;

         child_area.x = viewport->child->allocation.x;
         child_area.y = viewport->child->allocation.y;
         child_area.width = viewport->child->allocation.width;
         child_area.height = DW_WIDGET_HEIGHT(viewport->child);

         if (p_Dw_rectangle_intersect (&parent_area, &child_area,
                                       &intersection)) {
            intersection.x -= viewport->child->allocation.x;
            intersection.y -= viewport->child->allocation.y;

            /* "Clear" backing pixmap. */
            gdk_draw_rectangle (viewport->back_pixmap,
                                viewport->child->style->background_color->gc,
                                TRUE, area->x, area->y,
                                area->width, area->height);
            /* Widgets draw in backing pixmap. */
            p_Dw_widget_draw (viewport->child, &intersection, event);
            /* Copy backing pixmap into window. */
            gdk_draw_pixmap (layout->bin_window, widget->style->black_gc,
                             viewport->back_pixmap, area->x, area->y,
                             area->x, area->y, area->width, area->height);
         }
      } else
         gdk_window_clear_area (layout->bin_window,
                                area->x, area->y, area->width, area->height);
   }
}
Exemple #22
0
/* Redraw the contents of the lcd display. 
 * note: start BORDER pixels down and to the right.
 * TODO: we could be smart and only redraw what has changed. 
 * This does this work correctly with varriable sized fonts.
 */
void drawStackLCD(){
   int i;
   int curPos;
   int strt, stop;
   GdkGC *drawgc;
#ifdef USE_PANGO
   PangoRectangle rect;
   int pango_pos;
#endif

   /* draw the stack */
   for(i=0; i<lcdHeight; i++){

      /* draw the first unhighlighted section of the line */
      strt = 0;
      if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){
         stop = hiX1;
         if(stop > lcdWidth) stop = lcdWidth;
      } else {
         stop = lcdWidth;
      }
      if(stop-strt){
#ifdef USE_PANGO
         pango_layout_index_to_pos(pango_layout, strt, &rect);
         pango_pos = rect.x / PANGO_SCALE;
         gdk_window_clear_area(lcdDA->window, 
            pango_pos + BORDER, i*fontH + BORDER,
            2*fontW*(stop-strt), fontH);
         pango_layout_set_text(pango_layout,  &lcdText[i][strt], stop-strt);
         gdk_draw_layout(lcdDA->window, lcdGC,
            pango_pos + BORDER + SHIFT, i*fontH + BORDER,
	    pango_layout);
#else
         gdk_window_clear_area(lcdDA->window, 
            strt*fontW + BORDER, i*fontH + BORDER,
            fontW*(stop-strt), fontH);
         gdk_draw_text(lcdDA->window, lcdFont, lcdGC,
            strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER,
            &lcdText[i][strt], stop-strt);
#endif
      }

      /* draw the highlighted section of the line */
      if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){
	 strt = hiX1;
         if(strt > lcdWidth) strt = lcdWidth;
	 stop = hiX2+1;
         if(stop > lcdWidth) stop = lcdWidth;
         if(stop-strt){            
#ifdef USE_PANGO
            pango_layout_index_to_pos(pango_layout, strt, &rect);
            pango_pos = rect.x / PANGO_SCALE;
            gdk_window_clear_area(lcdDA->window, 
               pango_pos + BORDER, i*fontH + BORDER,
               2*fontW*(stop-strt), fontH);
            gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE,
               pango_pos + BORDER + SHIFT, i*fontH + BORDER,
               fontW*(stop-strt), fontH);
            pango_layout_set_text(pango_layout,  &lcdText[i][strt], stop-strt);
            gdk_draw_layout(lcdDA->window, lcdHighlightGC,
               strt*fontW + BORDER + SHIFT, i*fontH + BORDER,
	       pango_layout);
#else
            gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE,
               strt*fontW + BORDER, i*fontH + BORDER,
               fontW*(stop-strt), fontH);
	    gdk_draw_text(lcdDA->window, lcdFont, lcdHighlightGC,
	       strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER,
	       &lcdText[i][strt], stop-strt);
#endif
         }
      }

      /* draw the last unhighlighted section of the line */
      stop = lcdWidth;
      if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){
         strt = hiX2+1;
         if(strt > lcdWidth) strt = lcdWidth;
      } else {
         strt = lcdWidth;
      }
      if(stop-strt){
#ifdef USE_PANGO
         pango_layout_index_to_pos(pango_layout, strt, &rect);
         pango_pos = rect.x / PANGO_SCALE;
         gdk_window_clear_area(lcdDA->window, 
            pango_pos + BORDER, i*fontH + BORDER,
            2*fontW*(stop-strt), fontH);
         pango_layout_set_text(pango_layout,  &lcdText[i][strt], stop-strt);
         gdk_draw_layout(lcdDA->window, lcdGC,
            pango_pos + BORDER + SHIFT, i*fontH + BORDER,
	    pango_layout);
#else
	 gdk_window_clear_area(lcdDA->window, 
	    strt*fontW + BORDER, i*fontH + BORDER,
	    fontW*(stop-strt), fontH);
         gdk_draw_text(lcdDA->window, lcdFont, lcdGC,
            strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER,
            &lcdText[i][strt], stop-strt);
#endif
      }
   }

   /* draw the cursor */
   if(isEditingEditor()){
      curPos = cursorPosEditor();
      if(curPos > lcdWidth){
         curPos = lcdWidth;
      }
      if(dataSelected == DATA_SELECTED &&
	 curPos>=hiX1 && curPos<=hiX2 && 
         lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2)
      {
         drawgc = lcdHighlightGC;
      } else {
	 drawgc = lcdGC;
      }

      /* hack: draw a white line to erase any old cursor
         in position 0. XDrawImageString dosen't cover this
         up like it does with an old cursor in any other position */
      if(!(dataSelected == DATA_SELECTED && 
         0==hiX1 && lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2))
      {
         gdk_draw_line(lcdDA->window, lcdHighlightGC,
            BORDER + SHIFT, (lcdHeight-1) * fontH + BORDER,
            BORDER + SHIFT, lcdHeight * fontH - 1 + BORDER);
      }

      /* draw the cursor */
#ifdef USE_PANGO
      pango_layout_index_to_pos(pango_layout, curPos, &rect);
      pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER;
      gdk_draw_line(lcdDA->window, drawgc,
         pango_pos, (lcdHeight-1) * fontH + BORDER,
         pango_pos, lcdHeight * fontH - 1 + BORDER);
      /* Flush GDK display, seems to be needed in certain environments */
      gdk_flush();
   } else {
      pango_layout_index_to_pos(pango_layout, strt, &rect);
      pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER;
      if (pango_pos > lcdDA->allocation.width - BORDER && lcdWidth > 6) {
	 lcdWidth -= 1;
         clearLCDwindow();
         calcStackLCD();
         drawStackLCD();
      }
   }
#else
      gdk_draw_line(lcdDA->window, drawgc,
         fontW * curPos + SHIFT + BORDER, (lcdHeight-1) * fontH + BORDER,
         fontW * curPos + SHIFT + BORDER, lcdHeight * fontH - 1 + BORDER);
   }
static void
gtk_tearoff_menu_item_paint (GtkWidget   *widget,
			     GdkRectangle *area)
{
  GtkMenuItem *menu_item;
  GtkShadowType shadow_type;
  gint width, height;
  gint x, y;
  gint right_max;
  GtkArrowType arrow_type;
  GtkTextDirection direction;
  
  if (GTK_WIDGET_DRAWABLE (widget))
    {
      menu_item = GTK_MENU_ITEM (widget);

      direction = gtk_widget_get_direction (widget);

      x = widget->allocation.x + GTK_CONTAINER (menu_item)->border_width;
      y = widget->allocation.y + GTK_CONTAINER (menu_item)->border_width;
      width = widget->allocation.width - GTK_CONTAINER (menu_item)->border_width * 2;
      height = widget->allocation.height - GTK_CONTAINER (menu_item)->border_width * 2;
      right_max = x + width;

      if (widget->state == GTK_STATE_PRELIGHT)
	{
	  gint selected_shadow_type;
	  
	  gtk_widget_style_get (widget,
				"selected-shadow-type", &selected_shadow_type,
				NULL);
	  gtk_paint_box (widget->style,
			 widget->window,
			 GTK_STATE_PRELIGHT,
			 selected_shadow_type,
			 area, widget, "menuitem",
			 x, y, width, height);
	}
      else
	gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);

      if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
	{
	  gint arrow_x;

	  if (widget->state == GTK_STATE_PRELIGHT)
	    shadow_type = GTK_SHADOW_IN;
	  else
	    shadow_type = GTK_SHADOW_OUT;

	  if (menu_item->toggle_size > ARROW_SIZE)
	    {
	      if (direction == GTK_TEXT_DIR_LTR) {
		arrow_x = x + (menu_item->toggle_size - ARROW_SIZE)/2;
		arrow_type = GTK_ARROW_LEFT;
	      }
	      else {
		arrow_x = x + width - menu_item->toggle_size + (menu_item->toggle_size - ARROW_SIZE)/2; 
		arrow_type = GTK_ARROW_RIGHT;	    
	      }
	      x += menu_item->toggle_size + BORDER_SPACING;
	    }
	  else
	    {
	      if (direction == GTK_TEXT_DIR_LTR) {
		arrow_x = ARROW_SIZE / 2;
		arrow_type = GTK_ARROW_LEFT;
	      }
	      else {
		arrow_x = x + width - 2 * ARROW_SIZE + ARROW_SIZE / 2; 
		arrow_type = GTK_ARROW_RIGHT;	    
	      }
	      x += 2 * ARROW_SIZE;
	    }


	  gtk_paint_arrow (widget->style, widget->window,
			   widget->state, shadow_type,
			   NULL, widget, "tearoffmenuitem",
			   arrow_type, FALSE,
			   arrow_x, y + height / 2 - 5, 
			   ARROW_SIZE, ARROW_SIZE);
	}

      while (x < right_max)
	{
	  gint x1, x2;

	  if (direction == GTK_TEXT_DIR_LTR) {
	    x1 = x;
	    x2 = MIN (x + TEAR_LENGTH, right_max);
	  }
	  else {
	    x1 = right_max - x;
	    x2 = MAX (right_max - x - TEAR_LENGTH, 0);
	  }
	  
	  gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
			   NULL, widget, "tearoffmenuitem",
			   x1, x2, y + (height - widget->style->ythickness) / 2);
	  x += 2 * TEAR_LENGTH;
	}
    }
}