Esempio n. 1
0
int GrowText::event_handler( GlowWind *w, glow_eEvent event, int x, int y, double fx,
	double fy)
{
  int sts;

  sts = 0;
  if ( event == ctx->event_move_node) {
    sts = local_event_handler( event, fx, fy);
    if ( sts) {
      /* Register node for potential movement */
      ctx->move_insert( this);
    }
    return sts;
  }
  switch ( event) {
    case glow_eEvent_CursorMotion: {
      int redraw = 0;

      if ( ctx->hot_mode == glow_eHotMode_TraceAction)
        sts = 0;
      else if ( ctx->hot_found)
        sts = 0;
      else {
        sts = local_event_handler( event, fx, fy);
        if ( sts)
          ctx->hot_found = 1;
      }
      if ( sts && !hot  &&
	   !(ctx->node_movement_active || ctx->node_movement_paste_active)) {
        ctx->gdraw->set_cursor( w, glow_eDrawCursor_CrossHair);
        hot = 1;
        redraw = 1;
      }
      if ( !sts && hot) {
        if ( !ctx->hot_found)
          ctx->gdraw->set_cursor( w, glow_eDrawCursor_Normal);
        erase( w);
        hot = 0;
        redraw = 1;
      }
      if ( redraw) {
	ctx->draw( w, x_left * w->zoom_factor_x - w->offset_x - DRAW_MP,
	     y_low * w->zoom_factor_y - w->offset_y - DRAW_MP,
  	     x_right * w->zoom_factor_x - w->offset_x + DRAW_MP,
	     y_high * w->zoom_factor_y - w->offset_y + DRAW_MP);
      }
      break;
    }
    default:
      sts = local_event_handler( event, fx, fy);
  }
  if ( sts)
    ctx->register_callback_object( glow_eObjectType_Node, this);
  return sts;
}
Esempio n. 2
0
int GrowArc::event_handler( GlowWind *w, glow_eEvent event, double fx, double fy)
{
  double x, y;

  trf.reverse( fx, fy, &x, &y);
  return local_event_handler( event, x, y);
}
Esempio n. 3
0
int GrowText::event_handler( GlowWind *w, glow_eEvent event, double fx, double fy)
{
  return local_event_handler( event, fx, fy);
}
Esempio n. 4
0
int GrowWindow::event_handler( GlowWind *w, glow_eEvent event, int x, int y, double fx,
                               double fy)
{
    int sts, v_sts, h_sts;

    switch ( event) {
    case glow_eEvent_Key_Right:
    case glow_eEvent_Key_Left:
    case glow_eEvent_Key_Up:
    case glow_eEvent_Key_Down:
    case glow_eEvent_Key_BackSpace:
    case glow_eEvent_Key_Return:
    case glow_eEvent_Key_Tab:
    case glow_eEvent_Key_ShiftTab:
    case glow_eEvent_Key_Escape:
    case glow_eEvent_Key_Ascii:
        if ( input_focus) {
            window_ctx->event_handler( event, 0, 0, x, 0);
            if ( !window_ctx->inputfocus_object) {
                ctx->register_inputfocus( this, 0);
                input_focus = 0;
            }
            return 1;
        }
        else
            return 0;
    case glow_eEvent_ScrollUp:
        if ( !ctx->trace_started)
            return 0;
        if ( v_scrollbar) {
            double rx, ry;

            // Convert koordinates to local koordinates
            trf.reverse( fx, fy, &rx, &ry);
            sts = local_event_handler( event, rx, ry);
            if ( sts) {
                v_value -= (wctx_y1 - wctx_y0) * window_scale/50;
                if ( v_value < wctx_y0 * window_scale)
                    v_value = wctx_y0 * window_scale;
                draw();
                v_scrollbar->set_value( v_value, y_high -
                                        (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
                return 1;
            }
            else
                return 0;
        }
        break;
    case glow_eEvent_ScrollDown:
        if ( !ctx->trace_started)
            return 0;
        if ( v_scrollbar) {
            double rx, ry;

            // Convert koordinates to local koordinates
            trf.reverse( fx, fy, &rx, &ry);
            sts = local_event_handler( event, rx, ry);
            if ( sts) {
                v_value += (wctx_y1 - wctx_y0) * window_scale/50;
                if ( v_value > wctx_y1 * window_scale - ((y_high - (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar)))
                    v_value = wctx_y1 * window_scale - ((y_high - (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar));
                draw();
                v_scrollbar->set_value( v_value, y_high -
                                        (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
                return 1;
            }
            else
                return 0;
        }
        break;
    default:
        ;
    }

    v_sts = h_sts = 0;
    if ( v_scrollbar)
        v_sts = v_scrollbar->event_handler( w, event, x, y, fx, fy);
    if (h_scrollbar)
        h_sts = h_scrollbar->event_handler( w, event, x, y, fx, fy);
    if ( v_sts || h_sts) {
        if ( event == ctx->event_move_node)
            return 0;
        return 1;
    }

    sts = GrowRect::event_handler( w, event, x, y, fx, fy);
    if ( ctx->trace_started && ctx->callback_object == this) {
        // Disable event callback for this object, let the window ctx handle it
        ctx->callback_object = 0;
        ctx->callback_object_type = glow_eObjectType_NoObject;
    }
    if ( !ctx->trace_started) {
        if ( event == glow_eEvent_ButtonMotion)
            return 0;
    }

    if ( ctx->hot_mode == glow_eHotMode_TraceAction) {
        double rx, ry;

        // Convert koordinates to local koordinates
        trf.reverse( fx, fy, &rx, &ry);
        sts = local_event_handler( event, rx, ry);
    }

    if ( window_ctx && sts) {
        if ( !ctx->trace_started)
            return sts;

        int ur_x = int( (x_right - vertical_scrollbar * scrollbar_width) * ctx->mw.zoom_factor_x) - ctx->mw.offset_x;
        int	ll_x = int( x_left * ctx->mw.zoom_factor_x) - ctx->mw.offset_x;
        int	ur_y = int( (y_high - horizontal_scrollbar * scrollbar_width) * ctx->mw.zoom_factor_y) - ctx->mw.offset_y;
        int ll_y = int( (y_low + y_low_offs) * ctx->mw.zoom_factor_y) - ctx->mw.offset_y;

        // window_ctx->draw_buffer_only = ctx->draw_buffer_only;
        ctx->gdraw->set_clip_rectangle( &ctx->mw, ll_x, ll_y, ur_x, ur_y);

        // Set callback to redraw the background
        window_ctx->redraw_callback = redraw_cb;
        window_ctx->redraw_data = (void *)this;

        sts = window_ctx->event_handler( event, x, y, 0, 0);
        if ( sts == GLOW__TERMINATED)
            return sts;

        window_ctx->redraw_callback = 0;
        window_ctx->redraw_data = 0;
        ctx->gdraw->reset_clip_rectangle( &ctx->mw);

        if ( window_ctx->inputfocus_object && !input_focus) {
            ctx->register_inputfocus( this, 1);
            input_focus = 1;
        }
        else if ( !window_ctx->inputfocus_object && input_focus) {
            ctx->register_inputfocus( this, 0);
            input_focus = 0;
        }

        // if ( window_ctx->callback_object)
        //  ctx->register_callback_object( window_ctx->callback_object_type, window_ctx->callback_object);
    }
    return sts;
}