Commit e5fb3375 authored by Claes Sjofors's avatar Claes Sjofors

Ge, new script functions and colortheme fix for subwindows

parent 34491186
......@@ -685,9 +685,12 @@ void Graph::update_color_theme( int ct)
int sts;
sprintf( color_theme_file, "pwr_colortheme%d", ct);
sts = grow_ReadCustomColorFile( grow->ctx, color_theme_file);
sts = grow_ReadCustomColorFile( grow->base_ctx(), color_theme_file);
if ( EVEN(sts)) return;
grow_SetDefaultColorTheme( color_theme_file);
color_theme = ct;
if ( update_colorpalette_cb)
......@@ -1591,19 +1594,19 @@ int Graph::get_attr_items( grow_tObject object, attr_sItem **itemlist,
"Scale9", "Folder9.Scale",
"VerticalScrollbar9", "Folder9.VerticalScrollbar",
"HorizontalScrollbar9", "Folder9.HorizontalScrollbar",
"Owner10", "Folder9.Object",
"Owner9", "Folder9.Object",
"FileName10", "Folder10.FileName",
"Text10", "Folder10.Text",
"Scale10", "Folder10.Scale",
"VerticalScrollbar10", "Folder10.VerticalScrollbar",
"HorizontalScrollbar10","Folder10.HorizontalScrollbar",
"Owner11", "Folder10.Object",
"Owner10", "Folder10.Object",
"FileName11", "Folder11.FileName",
"Text11", "Folder11.Text",
"Scale11", "Folder11.Scale",
"VerticalScrollbar11", "Folder11.VerticalScrollbar",
"HorizontalScrollbar11","Folder11.HorizontalScrollbar",
"Owner12", "Folder11.Object",
"Owner11", "Folder11.Object",
"FileName12", "Folder12.FileName",
"Text12", "Folder12.Text",
"Scale12", "Folder12.Scale",
......
......@@ -399,6 +399,12 @@ class GraphGrow {
if ( stack_cnt > 0)
ctx = ctx_stack[--stack_cnt];
}
GrowCtx *base_ctx() {
if ( stack_cnt > 0)
return ctx_stack[0];
else
return ctx;
}
};
......
This diff is collapsed.
......@@ -2025,7 +2025,7 @@ void GlowDrawGtk::clear( GlowWind *wind)
if ( !w->double_buffer_on)
gdk_window_clear( w->window);
else
buffer_background( w);
buffer_background( w, 0);
}
void GlowDrawGtk::copy_buffer( GlowWind *wind,
......@@ -2410,7 +2410,7 @@ void GlowDrawGtk::set_background( GlowWind *wind, glow_eDrawType drawtype, glow_
gtk_widget_modify_bg( w->toplevel, GTK_STATE_NORMAL, &background);
if ( w->buffer)
buffer_background( w);
buffer_background( w, 0);
}
else {
GdkBitmap *mask;
......@@ -2425,7 +2425,7 @@ void GlowDrawGtk::set_background( GlowWind *wind, glow_eDrawType drawtype, glow_
w->background_pixmap_height = pixmap_height;
gdk_window_set_back_pixmap( w->window, w->background_pixmap, FALSE);
if ( w->buffer)
buffer_background( w);
buffer_background( w, 0);
}
}
......@@ -2622,7 +2622,7 @@ int GlowDrawGtk::create_buffer( GlowWind *wind)
w->buffer_width = window_width;
w->buffer_height = window_height;
buffer_background( w);
buffer_background( w, 0);
return 1;
}
......@@ -2637,7 +2637,7 @@ void GlowDrawGtk::delete_buffer( GlowWind *wind)
w->buffer_height = 0;
}
void GlowDrawGtk::buffer_background( DrawWind *wind)
void GlowDrawGtk::buffer_background( DrawWind *wind, GlowCtx *cctx)
{
DrawWindGtk *w = (DrawWindGtk *) wind;
int window_width, window_height, subwindow_x, subwindow_y;
......@@ -2687,14 +2687,21 @@ void GlowDrawGtk::buffer_background( DrawWind *wind)
reset_clip( w, get_gc( this, glow_eDrawType_Line, 0));
}
else {
glow_eDrawType bg;
if ( cctx)
bg = ((GrowCtx *)cctx)->background_color;
else
bg = ((GrowCtx *)ctx)->background_color;
//glow_eDrawType bg = glow_eDrawType_CustomColor1;
//glow_eDrawType bg = glow_eDrawType_LineErase;
if ( w->clip_on)
set_clip( w, get_gc( this, glow_eDrawType_LineErase, 0));
set_clip( w, get_gc( this, bg, 0));
gdk_draw_rectangle( w->buffer,
get_gc( this, glow_eDrawType_LineErase, 0), 1,
get_gc( this, bg, 0), 1,
subwindow_x, subwindow_y, window_width, window_height);
if ( w->clip_on)
reset_clip( w, get_gc( this, glow_eDrawType_LineErase, 0));
reset_clip( w, get_gc( this, bg, 0));
}
}
......
......@@ -191,7 +191,7 @@ class GlowDrawGtk : public GlowDraw {
virtual void draw_background( GlowWind *wind, int x, int y, int w, int h);
virtual int create_buffer( GlowWind *w);
virtual void delete_buffer( GlowWind *w);
virtual void buffer_background( DrawWind *w);
virtual void buffer_background( DrawWind *w, GlowCtx *cctx);
virtual int print( char *filename, double x0, double x1, int end);
virtual int export_image( char *filename);
void set_clip( DrawWind *w, GdkGC *gc);
......
......@@ -1938,7 +1938,7 @@ void GlowDrawXLib::clear( GlowWind *wind)
if ( !w->double_buffer_on)
XClearWindow( display, w->window);
else
buffer_background( w);
buffer_background( w, 0);
}
void GlowDrawXLib::copy_buffer( GlowWind *wind,
......@@ -2341,7 +2341,7 @@ void GlowDrawXLib::set_background( GlowWind *wind, glow_eDrawType drawtype, glow
XtSetValues( w->toplevel, args, i);
if ( w->buffer)
buffer_background( w);
buffer_background( w, 0);
}
else {
if ( w->background_pixmap)
......@@ -2352,7 +2352,7 @@ void GlowDrawXLib::set_background( GlowWind *wind, glow_eDrawType drawtype, glow
w->background_pixmap_height = pixmap_height;
XSetWindowBackgroundPixmap( display, w->window, (Pixmap)pixmap);
if ( w->buffer)
buffer_background( w);
buffer_background( w, 0);
}
}
......@@ -2580,7 +2580,7 @@ int GlowDrawXLib::create_buffer( GlowWind *wind)
w->buffer_width = window_width;
w->buffer_height = window_height;
buffer_background( w);
buffer_background( w, 0);
return 1;
}
......@@ -2595,7 +2595,7 @@ void GlowDrawXLib::delete_buffer( GlowWind *wind)
w->buffer_height = 0;
}
void GlowDrawXLib::buffer_background( DrawWind *wind)
void GlowDrawXLib::buffer_background( DrawWind *wind, GlowCtx *cctx)
{
DrawWindXLib *w = (DrawWindXLib *) wind;
int window_width, window_height, subwindow_x, subwindow_y;
......
......@@ -212,7 +212,7 @@ class GlowDrawXLib : public GlowDraw {
virtual void draw_background( GlowWind *wind, int x, int y, int w, int h);
virtual int create_buffer( GlowWind *w);
virtual void delete_buffer( GlowWind *w);
virtual void buffer_background( DrawWind *w);
virtual void buffer_background( DrawWind *w, GlowCtx *cctx);
virtual int print( char *filename, double x0, double x1, int end);
void set_clip( DrawWind *w, GC gc);
void reset_clip( DrawWind *w, GC gc);
......
......@@ -222,6 +222,7 @@ class GlowArrayElem {
virtual glow_eDrawType get_border_color() { return glow_eDrawType_No;}
virtual glow_eDrawType get_text_color() { return glow_eDrawType_No;}
virtual glow_eGradient get_gradient() { return glow_eGradient_No;}
virtual void get_gradient( glow_eGradient gradient) {}
virtual void set_colortheme_lightness() {}
virtual ~GlowArrayElem() {};
......
......@@ -562,6 +562,41 @@ int ColPalCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
event_callback[event]( this, &e);
}
}
else if ( strcmp( name, "ColorEntryBg") == 0) {
if ( event_callback[event]) {
static glow_sEvent e;
e.event = event;
e.any.type = glow_eEventType_ColorTone;
e.any.x_pixel = x;
e.any.y_pixel = y;
e.any.x = 1.0 * (x + mw.offset_x) / mw.zoom_factor_x;
e.any.y = 1.0 * (y + mw.offset_y) / mw.zoom_factor_y;
e.colortone.tone = (glow_eDrawTone) glow_eDrawType_LineErase;
event_callback[event]( this, &e);
}
}
}
else if ( callback_object->type() == glow_eObjectType_GrowText) {
GrowText *text;
char name[32];
text = (GrowText *)callback_object;
text->get_object_name( name);
if ( strcmp( name, "ColorEntryBg") == 0) {
if ( event_callback[event]) {
static glow_sEvent e;
e.event = event;
e.any.type = glow_eEventType_ColorTone;
e.any.x_pixel = x;
e.any.y_pixel = y;
e.any.x = 1.0 * (x + mw.offset_x) / mw.zoom_factor_x;
e.any.y = 1.0 * (y + mw.offset_y) / mw.zoom_factor_y;
e.colortone.tone = (glow_eDrawTone) glow_eDrawType_LineErase;
event_callback[event]( this, &e);
}
}
}
}
break;
......
......@@ -140,7 +140,7 @@ class GlowDraw {
virtual void draw_background( GlowWind *wind, int x, int y, int w, int h) {}
virtual int create_buffer( GlowWind *w) {return 1;}
virtual void delete_buffer( GlowWind *w) {}
virtual void buffer_background( DrawWind *w) {}
virtual void buffer_background( DrawWind *w, GlowCtx *cctx) {}
virtual int export_image( char *filename) { return 1;}
virtual int print( char *filename, double x0, double x1, int end) { return 1;}
//virtual void set_clip( DrawWind *w, GC gc) {}
......
......@@ -4945,6 +4945,16 @@ void grow_SetNodeClassExtern( grow_tNodeClass nodeclass, int ext)
((GlowNodeClass *)nodeclass)->set_extern( ext);
}
void grow_SetNodeClassExternAll( grow_tCtx ctx, int ext)
{
GlowNodeClass **nc_list;
int num;
ctx->get_nodeclasslist( (GlowArrayElem ***)&nc_list, &num);
for ( int i = 0; i < num; i++)
nc_list[i]->set_extern( ext);
}
int grow_GetBackgroundObjectLimits( grow_tCtx ctx, glow_eTraceType type,
double x, double y, grow_tObject *background,
double *min, double *max, glow_eDirection *direction)
......@@ -5497,6 +5507,11 @@ glow_eGradient grow_GetObjectGradient( grow_tObject o)
return ((GlowArrayElem *)o)->get_gradient();
}
void grow_SetObjectGradient( grow_tObject o, glow_eGradient gradient)
{
((GlowArrayElem *)o)->set_gradient( gradient);
}
int grow_GetObjectShadow( grow_tObject o)
{
return ((GlowArrayElem *)o)->get_shadow();
......@@ -5532,6 +5547,22 @@ void grow_ResetObjectBackgroundColor( grow_tObject object)
((GlowArrayElem *)object)->reset_background_color();
}
int grow_SetObjectClass( grow_tObject object, grow_tNodeClass nodeclass)
{
if ( ((GlowArrayElem *)object)->type() == glow_eObjectType_GrowNode ||
((GlowArrayElem *)object)->type() == glow_eObjectType_GrowSlider ||
((GlowArrayElem *)object)->type() == glow_eObjectType_GrowConGlue ||
((GlowArrayElem *)object)->type() == glow_eObjectType_GrowGroup) {
((GrowNode *)object)->nc = (GlowNodeClass *)nodeclass;
((GrowNode *)object)->nc_root = (GlowNodeClass *)nodeclass;
((GrowNode *)object)->get_node_borders();
}
else
return 0;
return 1;
}
/*@}*/
......
......@@ -2754,6 +2754,8 @@ extern "C" {
*/
void grow_SetNodeClassExtern( grow_tNodeClass nodeclass, int ext);
void grow_SetNodeClassExternAll( grow_tCtx ctx, int ext);
//! Get the limits configured in a background object for a slider.
/*!
\param ctx Grow context.
......@@ -3114,6 +3116,7 @@ extern "C" {
glow_eDrawType grow_GetObjectBorderColor( grow_tObject o);
glow_eDrawType grow_GetObjectTextColor( grow_tObject o);
glow_eGradient grow_GetObjectGradient( grow_tObject o);
void grow_SetObjectGradient( grow_tObject o, glow_eGradient gradient);
int grow_GetObjectShadow( grow_tObject o);
void grow_SetObjectOriginalFillColor( grow_tObject o, glow_eDrawType color);
void grow_SetObjectOriginalBorderColor( grow_tObject o, glow_eDrawType color);
......@@ -3121,6 +3124,7 @@ extern "C" {
void grow_SetObjectBackgroundColor( grow_tObject o, glow_eDrawType color);
void grow_SetObjectOriginalBackgroundColor( grow_tObject o, glow_eDrawType color);
void grow_ResetObjectBackgroundColor( grow_tObject object);
int grow_SetObjectClass( grow_tObject object, grow_tNodeClass nodeclass);
/*@}*/
......
......@@ -99,11 +99,13 @@ class NextElem {
GrowCtx::~GrowCtx()
{
if ( gdraw)
if ( gdraw) {
set_nodraw();
clear_all( 0);
}
if ( dynamic)
free( dynamic);
if ( ctx_type == glow_eCtxType_Grow && customcolors) {
if ( gdraw && ctx_type == glow_eCtxType_Grow && customcolors) {
gdraw->reset_customcolors( customcolors);
free( customcolors);
}
......@@ -2528,6 +2530,7 @@ void GrowCtx::clear_all( int keep_paste)
nav_clear();
set_nodraw();
reset_custom_colors();
zoom_absolute( mw.base_zoom_factor);
mw.offset_x = 0;
mw.offset_y = 0;
......@@ -2571,11 +2574,11 @@ void GrowCtx::clear_all( int keep_paste)
}
}
}
reset_custom_colors();
reset_nodraw();
// if ( show_grid)
// draw_grid( 0, 0, mw.window_width, mw.window_height);
draw( &mw, mw.subwindow_x, mw.subwindow_y, mw.subwindow_x + mw.window_width, mw.subwindow_y + mw.window_height);
reset_custom_colors();
}
void GrowCtx::redraw_defered()
......@@ -2615,7 +2618,7 @@ void GrowCtx::draw( GlowWind *w, int ll_x, int ll_y, int ur_x, int ur_y)
if ( redraw_callback)
(redraw_callback) ( redraw_data);
if ( w->double_buffer_on())
gdraw->buffer_background( w->window);
gdraw->buffer_background( w->window, this);
for ( i = 0; i < a.a_size; i++) {
if ( a.a[i]->type() == glow_eObjectType_Con)
a.a[i]->draw( w, ll_x, ll_y, ur_x, ur_y);
......@@ -4692,11 +4695,21 @@ int GrowCtx::read_customcolor_file( char *name)
{
int sts;
if ( environment == glow_eEnv_Runtime && strcmp( color_theme, "$default") != 0)
return 0;
if ( customcolors) {
sts = customcolors->read_colorfile( this, name);
if ( ODD(sts)) {
set_background( background_color);
}
for ( int i = 0; i < a.a_size; i++) {
if ( a[i]->type() == glow_eObjectType_GrowWindow ||
a[i]->type() == glow_eObjectType_GrowFolder) {
((GrowWindow *)a[i])->window_ctx->read_customcolor_file( name);
}
}
return sts;
}
else
......
......@@ -99,7 +99,7 @@ class GrowCtx : public GlowCtx {
is_javaapplication(0), cycle(glow_eCycle_Slow),
mb3_action(glow_eMB3Action_PopupMenu), scale_equal(0), translate_on(0),
input_focus_mark(glow_eInputFocusMark_Relief), background_disabled(0),
redraw_callback(0), redraw_data(0), has_subwindows(-1), bitmap_fonts(0),
redraw_callback(0), redraw_data(0), has_subwindows(-1), is_subwindow(0), bitmap_fonts(0),
environment(glow_eEnv_Runtime), text_coding(glow_eTextCoding_ISO8859_1), recursive_trace(0),
edit_set_mode(glow_eEditSetMode_None)
{ ctx_type = glow_eCtxType_Grow;
......@@ -964,6 +964,7 @@ class GrowCtx : public GlowCtx {
void (*redraw_callback)( void *); //!< Backcall function before drawing (if ctx is window component).
void *redraw_data; //!< Data for redraw callback.
int has_subwindows; //!< Graph contains subwindow objects (GrowWindow or GrowFolder)
int is_subwindow; //!< Is a subwindow context.
char owner[256]; //!< Owner, used by application
int bitmap_fonts; //!< Use bitmap fonts
glow_eEnv environment; //!< Environment Development or Runtime.
......
......@@ -298,10 +298,10 @@ void GrowWindow::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, vo
window_ctx->mw.zoom_factor_y = window_ctx->mw.subwindow_scale * w->zoom_factor_y;
// window_ctx->draw_buffer_only = ctx->draw_buffer_only;
ctx->gdraw->push_customcolors( window_ctx->customcolors);
if ( fill)
ctx->gdraw->fill_rect( w, ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, fill_drawtype);
ctx->gdraw->push_customcolors( window_ctx->customcolors);
window_ctx->draw( &window_ctx->mw, ll_x, ll_y, ur_x, ur_y);
ctx->gdraw->pop_customcolors();
}
......@@ -903,6 +903,7 @@ void GrowWindow::new_ctx()
window_ctx = new GrowCtx( "WindowComponent", ctx->mw.zoom_factor_x * window_scale);
window_ctx->gdraw = ctx->gdraw;
window_ctx->is_subwindow = 1;
window_ctx->mw.window = ctx->mw.window;
window_ctx->navw.window = ctx->navw.window;
window_ctx->userdata_save_callback = ctx->userdata_save_callback;
......
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