Commit 1027205d authored by claes's avatar claes

More fix for subwindows

parent 0b5be29d
/*
* Proview $Id: glow_ctx.cpp,v 1.8 2006-01-23 08:46:54 claes Exp $
* Proview $Id: glow_ctx.cpp,v 1.9 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -53,7 +53,7 @@ GlowCtx::GlowCtx( char *ctx_name, double zoom_fact, int offs_x, int offs_y)
offset_x(offs_x), offset_y(offs_y), nav_zoom_factor_x(zoom_fact),
nav_zoom_factor_y(zoom_fact), print_zoom_factor(100),
x_right(0), x_left(0), y_high(0), y_low(0),
window_width(0), window_height(0), window_x(0), window_y(0),
window_width(0), window_height(0), subwindow_x(0), subwindow_y(0), subwindow_scale(1),
nav_window_width(0), nav_window_height(0),
nav_rect_ll_x(0), nav_rect_ll_y(0), nav_rect_ur_x(0), nav_rect_ur_y(0),
node_movement_active(0),
......@@ -402,7 +402,7 @@ void GlowCtx::zoom( double factor)
// offset_x << "," << offset_y << endl;
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
change_scrollbar();
}
......@@ -415,7 +415,7 @@ void GlowCtx::zoom_x( double factor)
zoom_factor_x = factor;
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
change_scrollbar();
}
......@@ -428,7 +428,7 @@ void GlowCtx::zoom_y( double factor)
zoom_factor_y = factor;
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
change_scrollbar();
}
......@@ -445,7 +445,7 @@ void GlowCtx::zoom_absolute( double factor)
zoom_factor_x = zoom_factor_y = factor;
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
}
......@@ -617,7 +617,7 @@ void GlowCtx::cut()
}
select_clear();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
}
......@@ -1014,7 +1014,7 @@ int GlowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
glow_draw_get_window_size( ctx, &window_width, &window_height);
if ( glow_draw_create_buffer( ctx))
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
else
draw( x, y, x + w, y + h);
nav_zoom();
......@@ -1584,7 +1584,7 @@ void GlowCtx::remove_trace_objects()
}
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
}
......@@ -1674,7 +1674,7 @@ void GlowCtx::center_object( GlowArrayElem *object)
offset_y = int( ((ur_y + ll_y)/2 ) * zoom_factor_y - window_height/2);
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
change_scrollbar();
}
......@@ -1746,7 +1746,7 @@ void GlowCtx::reconfigure()
reset_nodraw();
a.zoom();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
}
......@@ -1755,7 +1755,7 @@ void GlowCtx::redraw()
glow_draw_get_window_size( this, &window_width, &window_height);
get_borders();
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
change_scrollbar();
}
......
/*
* Proview $Id: glow_ctx.h,v 1.8 2006-01-23 08:46:54 claes Exp $
* Proview $Id: glow_ctx.h,v 1.9 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -83,8 +83,9 @@ class GlowCtx {
double y_low; //!< Low border of work area.
int window_width; //!< Window width in pixel.
int window_height; //!< Window height in pixel.
int window_x; //!< Subwindow x coordinate in pixel.
int window_y; //!< Subwindow y coordinate in pixel.
int subwindow_x; //!< Subwindow x coordinate in pixel.
int subwindow_y; //!< Subwindow y coordinate in pixel.
double subwindow_scale; //!< Subwindow scale.
int nav_window_width; //!< Navigation window width in pixel.
int nav_window_height; //!< Navigation window height in pixel.
int nav_rect_ll_x; //!< x coordinate for lower left corner of navigation rectangle in nav window.
......
/*
* Proview $Id: glow_draw.cpp,v 1.8 2006-01-23 08:46:54 claes Exp $
* Proview $Id: glow_draw.cpp,v 1.9 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -3173,7 +3173,7 @@ void glow_draw_buffer_background( GlowCtx *ctx)
XFillRectangle( draw_ctx->display, draw_ctx->buffer,
get_gc( draw_ctx, glow_eDrawType_LineErase, 0),
ctx->window_x, ctx->window_y, ctx->window_width, ctx->window_height);
ctx->subwindow_x, ctx->subwindow_y, ctx->window_width, ctx->window_height);
if ( draw_ctx->clip_on)
glow_reset_clip( draw_ctx, get_gc( draw_ctx, glow_eDrawType_LineErase, 0));
......@@ -3261,7 +3261,7 @@ int glow_print( GlowCtx *ctx, char *filename, double x0, double x1, int end)
if ( new_file) {
ps->fp <<
"%!PS-Adobe-2.0 EPSF-1.2" << endl <<
"%%Creator: Proview $Id: glow_draw.cpp,v 1.8 2006-01-23 08:46:54 claes Exp $ Glow" << endl <<
"%%Creator: Proview $Id: glow_draw.cpp,v 1.9 2006-01-25 10:46:23 claes Exp $ Glow" << endl <<
"%%EndComments" << endl << endl;
}
else
......
/*
* Proview $Id: glow_growctx.cpp,v 1.15 2006-01-23 08:46:54 claes Exp $
* Proview $Id: glow_growctx.cpp,v 1.16 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -132,31 +132,22 @@ int GrowCtx::subw_event_handler( glow_eEvent event, int x, int y, int w, int h)
// Initialize
for ( i = 0; i < a.a_size; i++) {
if ( a[i]->type() == glow_eObjectType_GrowWindow ||
a[i]->type() == glow_eObjectType_GrowFolder) {
a[i]->type() == glow_eObjectType_GrowFolder ||
a[i]->type() == glow_eObjectType_GrowTable) {
has_subwindows = 1;
break;
}
if ( has_subwindows != 1) {
has_subwindows = 0;
return 0;
}
}
}
// Check if any menue is active
if ( a.a_size && a[a.a_size-1]->type() == glow_eObjectType_GrowMenu) {
switch ( event) {
case glow_eEvent_CursorMotion:
sts = a[a.a_size-1]->event_handler( event, x, y, fx, fy);
return 1;
default: ;
if ( has_subwindows != 1) {
has_subwindows = 0;
return 0;
}
}
for ( i = a.a_size - 1; i >= 0; i--) {
if ( a[i]->type() == glow_eObjectType_GrowWindow ||
a[i]->type() == glow_eObjectType_GrowFolder) {
a[i]->type() == glow_eObjectType_GrowFolder ||
a[i]->type() == glow_eObjectType_GrowTable) {
switch ( event) {
case glow_eEvent_Leave:
case glow_eEvent_Enter:
......@@ -178,6 +169,30 @@ int GrowCtx::subw_event_handler( glow_eEvent event, int x, int y, int w, int h)
if ( sts) {
return sts;
}
case glow_eEvent_MB1Click:
case glow_eEvent_MB2Click:
case glow_eEvent_MB3Click:
sts = a[i]->event_handler( event, x, y, fx, fy);
if ( sts) {
// Check if any menue is active
if ( a.a_size && a[a.a_size-1]->type() == glow_eObjectType_GrowMenu) {
// Send backcall to reset menu
if ( event_callback[event] &&
sts != GLOW__NO_PROPAGATE && event != event_move_node) {
static glow_sEvent e;
e.event = event;
e.any.type = glow_eEventType_Object;
e.any.x_pixel = x;
e.any.y_pixel = y;
e.any.x = 1.0 * (x + offset_x) / zoom_factor_x;
e.any.y = 1.0 * (y + offset_y) / zoom_factor_y;
e.object.object_type = glow_eObjectType_NoObject;
event_callback[event]( this, &e);
}
}
return sts;
}
default:
sts = a[i]->event_handler( event, x, y, fx, fy);
if ( sts) {
......@@ -206,8 +221,26 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
callback_object_type = glow_eObjectType_NoObject;
callback_object = 0;
// Check if any menue is active
if ( a.a_size && a[a.a_size-1]->type() == glow_eObjectType_GrowMenu) {
switch ( event) {
case glow_eEvent_CursorMotion:
sts = a[a.a_size-1]->event_handler( event, x, y, fx, fy);
return 1;
case glow_eEvent_MB1Down:
case glow_eEvent_MB1Up:
case glow_eEvent_MB1Click:
sts = a[a.a_size-1]->event_handler( event, x, y, fx, fy);
if ( sts)
return 1;
break;
default: ;
return 0;
}
}
// Dispach to event to subwindows
if ( has_subwindows) {
if ( trace_started && has_subwindows) {
sts = subw_event_handler( event, x, y, w, h);
if ( sts)
return sts;
......@@ -587,7 +620,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
}
if ( glow_draw_create_buffer( ctx))
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
else
draw( x, y, x + w, y + h);
nav_zoom();
......@@ -701,6 +734,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
case glow_eEvent_ButtonMotion:
tiptext->remove();
#if 0
for ( i = 0; i < a.a_size; i++) {
if ( a[i]->type() == glow_eObjectType_GrowWindow ||
a[i]->type() == glow_eObjectType_GrowTable ||
......@@ -713,6 +747,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
}
}
}
#endif
if ( node_movement_active && edit_mode != grow_eMode_EditPolyLine)
{
int move_x, move_y;
......@@ -2212,7 +2247,7 @@ void GrowCtx::clear_all( int keep_paste)
reset_nodraw();
// if ( show_grid)
// draw_grid( 0, 0, window_width, window_height);
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
}
void GrowCtx::redraw_defered()
......@@ -3588,7 +3623,7 @@ void GrowCtx::restore_geometry()
grid_on = stored_grid_on;
show_grid = stored_show_grid;
clear();
draw( window_x, window_y, window_width, window_height);
draw( subwindow_x, subwindow_y, subwindow_x + window_width, subwindow_y + window_height);
nav_zoom();
}
......
/*
* Proview $Id: glow_growmenu.cpp,v 1.7 2005-12-06 09:13:08 claes Exp $
* Proview $Id: glow_growmenu.cpp,v 1.8 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -49,6 +49,14 @@ GrowMenu::GrowMenu( GlowCtx *glow_ctx, char *name, glow_sMenuInfo *menu_info, do
GrowMenu::~GrowMenu()
{
// Remove this as parent from any submenu
for ( int i = 0; i < ctx->a.a_size; i++) {
if ( ctx->a[i]->type() == glow_eObjectType_GrowMenu) {
if ( ((GrowMenu *)ctx->a[i])->parent_menu == this)
((GrowMenu *)ctx->a[i])->parent_menu = 0;
}
}
if ( input_focus && parent_menu)
((GrowMenu *)parent_menu)->set_input_focus( 1);
......
/*
* Proview $Id: glow_growwindow.cpp,v 1.5 2006-01-23 08:46:54 claes Exp $
* Proview $Id: glow_growwindow.cpp,v 1.6 2006-01-25 10:46:23 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -276,12 +276,12 @@ void GrowWindow::draw( GlowTransform *t, int highlight, int hot, void *node, voi
window_ctx->window_width = int((x_right - x_left) * ctx->zoom_factor_x);
window_ctx->window_height = int((y_high - y_low) * ctx->zoom_factor_y);
window_ctx->window_x = int(x_left * ctx->zoom_factor_x - ctx->offset_x);
window_ctx->window_y = int(y_low * ctx->zoom_factor_y - ctx->offset_y);
window_ctx->subwindow_x = int(x_left * ctx->zoom_factor_x - ctx->offset_x);
window_ctx->subwindow_y = int(y_low * ctx->zoom_factor_y - ctx->offset_y);
window_ctx->offset_x = - ll_x + int( h_value * ctx->zoom_factor_x);
window_ctx->offset_y = - ll_y + int( v_value * ctx->zoom_factor_y);
window_ctx->zoom_factor_x = window_scale * ctx->zoom_factor_x;
window_ctx->zoom_factor_y = window_scale * ctx->zoom_factor_y;
window_ctx->zoom_factor_x = window_ctx->subwindow_scale * ctx->zoom_factor_x;
window_ctx->zoom_factor_y = window_ctx->subwindow_scale * ctx->zoom_factor_y;
window_ctx->draw_buffer_only = ctx->draw_buffer_only;
if ( fill)
......@@ -459,11 +459,11 @@ int GrowWindow::trace_init()
window_ctx->offset_x = - ll_x + int( h_value * ctx->zoom_factor_x);
window_ctx->offset_y = - ll_y + int( v_value * ctx->zoom_factor_y);
memcpy( window_ctx->event_callback, ctx->event_callback, sizeof( ctx->event_callback));
window_ctx->event_move_node = ctx->event_move_node;
window_ctx->trace_init( ctx->trace_connect_func,
ctx->trace_disconnect_func,
ctx->trace_scan_func);
memcpy( window_ctx->event_callback, ctx->event_callback, sizeof( ctx->event_callback));
window_ctx->event_move_node = ctx->event_move_node;
}
return sts;
......@@ -701,6 +701,11 @@ void GrowWindow::update_attributes()
window_ctx->draw_buffer_only = ctx->draw_buffer_only;
glow_draw_set_clip_rectangle( ctx, ll_x, ll_y, ur_x, ur_y);
#endif
int ur_x = int( x_right * ctx->zoom_factor_x) - ctx->offset_x;
int ll_x = int( x_left * ctx->zoom_factor_x) - ctx->offset_x;
int ur_y = int( y_high * ctx->zoom_factor_y) - ctx->offset_y;
int ll_y = int( y_low * ctx->zoom_factor_y) - ctx->offset_y;
glow_draw_set_clip_rectangle( ctx, ll_x, ll_y, ur_x, ur_y);
if ( window_ctx) {
if ( window_ctx->trace_started)
......@@ -712,12 +717,14 @@ void GrowWindow::update_attributes()
strcpy( file_name, input_file_name);
new_ctx();
#if 0
//#if 0
glow_draw_reset_clip_rectangle( ctx);
#endif
//#endif
}
if ( window_ctx) {
window_ctx->zoom_factor_x = window_ctx->zoom_factor_y = window_scale * ctx->zoom_factor_x;
window_ctx->subwindow_scale = window_scale;
window_ctx->zoom_factor_x = window_ctx->zoom_factor_y =
window_ctx->subwindow_scale * ctx->zoom_factor_x;
window_ctx->a.zoom();
}
......@@ -752,27 +759,34 @@ void GrowWindow::configure_scrollbars()
glow_eDir_Vertical, glow_eDrawType_Line, 1, display_level,
scrollbar_bg_color, scrollbar_color, 1);
v_scrollbar->register_value_changed_cb( (void *)this, &v_value_changed_cb);
v_scrollbar->set_value( wctx_y0 * window_scale, y_high - (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
if ( window_ctx)
v_scrollbar->set_range( wctx_y0 * window_scale, wctx_y1 * window_scale);
if ( window_ctx) {
v_scrollbar->set_value( wctx_y0 * window_ctx->subwindow_scale, y_high -
(y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
v_scrollbar->set_range( wctx_y0 * window_ctx->subwindow_scale, wctx_y1 * window_scale);
v_value = wctx_y0 * window_ctx->subwindow_scale;
}
v_scrollbar->set_shadow( shadow);
v_value = wctx_y0 * window_scale;
}
else if ( !vertical_scrollbar && v_scrollbar) {
delete v_scrollbar;
v_scrollbar = 0;
v_value = wctx_y0 * window_scale;
if ( window_ctx)
v_value = wctx_y0 * window_ctx->subwindow_scale;
}
else if ( v_scrollbar) {
// Reconfigure range and length
v_scrollbar->set_value( wctx_y0 * window_scale, y_high - (y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
v_value = wctx_y0 * window_scale;
if ( window_ctx)
v_scrollbar->set_range( wctx_y0 * window_scale, wctx_y1 * window_scale);
if ( window_ctx) {
v_scrollbar->set_value( wctx_y0 * window_ctx->subwindow_scale, y_high -
(y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
v_value = wctx_y0 * window_ctx->subwindow_scale;
v_scrollbar->set_range( wctx_y0 * window_ctx->subwindow_scale, wctx_y1 * window_ctx->subwindow_scale);
}
v_scrollbar->set_shadow( shadow);
}
else
v_value = wctx_y0 * window_scale;
else {
if ( window_ctx)
v_value = wctx_y0 * window_ctx->subwindow_scale;
}
if ( horizontal_scrollbar && ! h_scrollbar) {
x0 = x_left;
......@@ -787,27 +801,34 @@ void GrowWindow::configure_scrollbars()
glow_eDir_Horizontal, glow_eDrawType_Line, 1, display_level,
scrollbar_bg_color, scrollbar_color, 1);
h_scrollbar->register_value_changed_cb( (void *)this, &h_value_changed_cb);
h_scrollbar->set_value( wctx_x0 * window_scale, x_right - x_left - scrollbar_width * vertical_scrollbar);
if ( window_ctx)
h_scrollbar->set_range( wctx_x0 * window_scale, wctx_x1 * window_scale);
if ( window_ctx) {
h_scrollbar->set_value( wctx_x0 * window_ctx->subwindow_scale,
x_right - x_left - scrollbar_width * vertical_scrollbar);
h_scrollbar->set_range( wctx_x0 * window_ctx->subwindow_scale, wctx_x1 * window_ctx->subwindow_scale);
h_value = wctx_x0 * window_ctx->subwindow_scale;
}
h_scrollbar->set_shadow( shadow);
h_value = wctx_x0 * window_scale;
}
else if ( !horizontal_scrollbar && h_scrollbar) {
delete h_scrollbar;
h_scrollbar = 0;
h_value = wctx_x0 * window_scale;
if ( window_ctx)
h_value = wctx_x0 * window_ctx->subwindow_scale;
}
else if ( h_scrollbar) {
// Reconfigure lenght and range
h_scrollbar->set_value( wctx_x0 * window_scale, x_right - x_left - scrollbar_width * vertical_scrollbar);
h_value = wctx_x0 * window_scale;
if ( window_ctx)
h_scrollbar->set_range( wctx_x0 * window_scale, wctx_x1 * window_scale);
if ( window_ctx) {
h_scrollbar->set_value( wctx_x0 * window_ctx->subwindow_scale,
x_right - x_left - scrollbar_width * vertical_scrollbar);
h_value = wctx_x0 * window_ctx->subwindow_scale;
h_scrollbar->set_range( wctx_x0 * window_ctx->subwindow_scale, wctx_x1 * window_ctx->subwindow_scale);
}
h_scrollbar->set_shadow( shadow);
}
else
h_value = wctx_x0 * window_scale;
else {
if ( window_ctx)
h_value = wctx_x0 * window_ctx->subwindow_scale;
}
}
void GrowWindow::v_value_changed_cb( void *o, double value)
......@@ -874,9 +895,10 @@ void GrowWindow::new_ctx()
}
window_ctx->window_width = int((x_right - x_left) * ctx->zoom_factor_x);
window_ctx->window_height = int((y_high - y_low) * ctx->zoom_factor_y);
window_ctx->window_x = int(x_left * ctx->zoom_factor_x - ctx->offset_x);
window_ctx->window_y = int(y_low * ctx->zoom_factor_y - ctx->offset_y);
window_ctx->zoom_factor_x = window_ctx->zoom_factor_y = ctx->zoom_factor_x * window_scale;
window_ctx->subwindow_x = int(x_left * ctx->zoom_factor_x - ctx->offset_x);
window_ctx->subwindow_y = int(y_low * ctx->zoom_factor_y - ctx->offset_y);
window_ctx->subwindow_scale = ctx->subwindow_scale * window_scale;
window_ctx->zoom_factor_x = window_ctx->zoom_factor_y = ctx->zoom_factor_x * window_ctx->subwindow_scale;
window_ctx->move_restriction = glow_eMoveRestriction_Disable;
window_ctx->a.zoom();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment