Commit 86195f54 authored by claes's avatar claes

Extended predefined dynamics for subgraphs

parent 0fefc27f
......@@ -235,6 +235,13 @@ typedef enum {
} glow_eCycle;
//! Userdata callback type
typedef enum {
glow_eUserdataCbType_Node, //!< Userdata in a GrowNode
glow_eUserdataCbType_Ctx, //!< Userdata in GrowCtx
glow_eUserdataCbType_NodeClass //!< Userdata in a GlowNodeClass
} glow_eUserdataCbType;
//! Pass for java export
typedef enum {
glow_eExportPass_Init,
......@@ -1001,6 +1008,7 @@ typedef enum {
glow_eSave_NodeClass_dyn_attr3 = 326,
glow_eSave_NodeClass_dyn_attr4 = 327,
glow_eSave_NodeClass_input_focus_mark = 328,
glow_eSave_NodeClass_userdata_cb = 329,
glow_eSave_ConClass_cc_name = 400,
glow_eSave_ConClass_con_type = 401,
glow_eSave_ConClass_corner = 402,
......@@ -1133,6 +1141,7 @@ typedef enum {
glow_eSave_GrowRect_shadow = 1915,
glow_eSave_GrowRect_shadow_contrast = 1916,
glow_eSave_GrowRect_disable_shadow = 1917,
glow_eSave_GrowRect_invisible = 1918,
glow_eSave_GrowLine_x_right = 2000,
glow_eSave_GrowLine_x_left = 2001,
glow_eSave_GrowLine_y_high = 2002,
......@@ -1195,6 +1204,7 @@ typedef enum {
glow_eSave_GrowCtx_dyn_attr3 = 2241,
glow_eSave_GrowCtx_dyn_attr4 = 2242,
glow_eSave_GrowCtx_input_focus_mark = 2243,
glow_eSave_GrowCtx_userdata_cb = 2244,
glow_eSave_GrowSubAnnot_x_right = 2300,
glow_eSave_GrowSubAnnot_x_left = 2301,
glow_eSave_GrowSubAnnot_y_high = 2302,
......
......@@ -44,6 +44,7 @@
#include "glow_growfolder.h"
#include "glow_growtable.h"
#include "glow_msg.h"
#include "co_cdh.h"
GlowArray::GlowArray( int allocate, int incr) : allocated( allocate),
alloc_incr(incr), a_size(0)
......@@ -294,7 +295,7 @@ void GlowArray::copy_from( const GlowArray& array)
// Fix, This should be done in the copy constructor !!!
if ( n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)( n,
((GrowBar *)array.a[i])->user_data, &n->user_data);
((GrowBar *)array.a[i])->user_data, &n->user_data, glow_eUserdataCbType_Node);
insert( n);
break;
}
......@@ -309,7 +310,7 @@ void GlowArray::copy_from( const GlowArray& array)
n->configure_curves();
if ( n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)( n,
((GrowTrend *)(array.a[i]))->user_data, &n->user_data);
((GrowTrend *)(array.a[i]))->user_data, &n->user_data, glow_eUserdataCbType_Node);
insert( n);
break;
}
......@@ -321,7 +322,7 @@ void GlowArray::copy_from( const GlowArray& array)
// Fix, This should be done in the copy constructor !!!
if ( n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)( n,
((GrowWindow *)array.a[i])->user_data, &n->user_data);
((GrowWindow *)array.a[i])->user_data, &n->user_data, glow_eUserdataCbType_Node);
n->window_ctx = 0;
n->v_scrollbar = 0;
n->h_scrollbar = 0;
......@@ -338,7 +339,7 @@ void GlowArray::copy_from( const GlowArray& array)
// Fix, This should be done in the copy constructor !!!
if ( n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)( n,
((GrowFolder *)array.a[i])->user_data, &n->user_data);
((GrowFolder *)array.a[i])->user_data, &n->user_data, glow_eUserdataCbType_Node);
n->window_ctx = 0;
n->v_scrollbar = 0;
n->h_scrollbar = 0;
......@@ -355,7 +356,7 @@ void GlowArray::copy_from( const GlowArray& array)
// Fix, This should be done in the copy constructor !!!
if ( n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)( n,
((GrowTable *)array.a[i])->user_data, &n->user_data);
((GrowTable *)array.a[i])->user_data, &n->user_data, glow_eUserdataCbType_Node);
n->v_scrollbar = 0;
n->h_scrollbar = 0;
n->cell_value = 0;
......@@ -1159,7 +1160,7 @@ int GlowArray::find_by_name( char *name, GlowArrayElem **element)
for ( i = 0; i < a_size; i++)
{
a[i]->get_object_name( object_name);
if ( strcmp( name, object_name) == 0)
if ( cdh_NoCaseStrcmp( name, object_name) == 0)
{
*element = a[i];
return 1;
......
......@@ -26,9 +26,9 @@ typedef struct {
int offset_y; //!< Offset from workarea border to displayed window.
} glow_sScroll;
typedef void (*glow_tUserDataSaveCb) ( ofstream *, GlowArrayElem *);
typedef void (*glow_tUserDataOpenCb) ( ifstream *, GlowArrayElem *);
typedef void (*glow_tUserDataCopyCb) ( GlowArrayElem *, void *, void **);
typedef void (*glow_tUserDataSaveCb) ( ofstream *, void *, glow_eUserdataCbType);
typedef void (*glow_tUserDataOpenCb) ( ifstream *, void *, glow_eUserdataCbType);
typedef void (*glow_tUserDataCopyCb) ( void *, void *, void **, glow_eUserdataCbType);
//! Class for a drawing window populated with drawing objects and components.
/*! GlowCtx is the base class for the drawing area in Glow. It contains array with
......
......@@ -1217,6 +1217,11 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Relief;
attrinfo[i++].size = sizeof( op->relief);
strcpy( attrinfo[i].name, "invisible");
attrinfo[i].value_p = &op->invisible;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( op->invisible);
strcpy( attrinfo[i].name, "disable_shadow");
attrinfo[i].value_p = &op->disable_shadow;
attrinfo[i].type = glow_eType_Boolean;
......@@ -2381,7 +2386,7 @@ int grow_GetSubGraphAttrInfo( grow_tCtx ctx, char *transtab, grow_sAttrInfo **in
int dynsize;
char *name;
attrinfo = (grow_sAttrInfo *) calloc( 20, sizeof(grow_sAttrInfo));
attrinfo = (grow_sAttrInfo *) calloc( 30, sizeof(grow_sAttrInfo));
i = 0;
......@@ -3526,6 +3531,12 @@ void grow_GetNodeClassDynType( grow_tNodeClass nodeclass, int *dyn_type,
*dyn_action_type = base_nc->dyn_action_type;
}
void grow_GetObjectClassUserData( grow_tObject object, void **user_data)
{
GlowNodeClass *base_nc = ((GrowNode *)object)->nc->get_base_nc();
base_nc->get_user_data( user_data);
}
void grow_GetSubGraphDynType( grow_tCtx ctx, int *dyn_type, int *dyn_action_type)
{
*dyn_type = ctx->dyn_type;
......@@ -4087,9 +4098,9 @@ int grow_ImageUpdate( grow_tObject object)
extern "C"
#endif
void grow_RegisterUserDataCallbacks( grow_tCtx ctx,
void (*save)( void *, grow_tObject),
void (*open)( void *, grow_tObject),
void (*copy)( grow_tObject, void *, void **))
void (*save)( void *, void *, glow_eUserdataCbType),
void (*open)( void *, void *, glow_eUserdataCbType),
void (*copy)( void *, void *, void **, glow_eUserdataCbType))
{
((GrowCtx *)ctx)->register_userdata_callbacks(
(glow_tUserDataSaveCb) save,
......@@ -4262,6 +4273,12 @@ int grow_GetMenuParent( grow_tObject menu, grow_tObject *parent)
{
return ((GrowMenu *)menu)->get_parent( (GlowArrayElem **)parent);
}
int grow_SetFolderIndex( grow_tObject folder, int idx)
{
return ((GrowFolder *)folder)->set_folder( idx);
}
/*@}*/
......
......@@ -1764,11 +1764,18 @@ typedef GlowTraceData glow_sTraceData;
*/
void grow_GetObjectClassCycle( grow_tObject object, glow_eCycle *cycle);
//! Get userdata for the nodeclass of an object.
/*!
\param object Object.
\param user_data Userdata of the object's nodeclass.
*/
void grow_GetObjectClassUserData( grow_tObject object, void **user_data);
//! Get nodeclass dyntype and actiontype.
/*!
\param nodeclass Nodeclass.
\param dyn_type Dyntype of the nodeclass.
\param dyn_action_type Actionetype of the nodeclass.
\param dyn_action_type Actiontype of the nodeclass.
*/
void grow_GetNodeClassDynType( grow_tNodeClass nodeclass, int *dyn_type, int *dyn_action_type);
......@@ -2585,9 +2592,9 @@ typedef GlowTraceData glow_sTraceData;
\param copy Callback function that will be called when userdata is copied.
*/
void grow_RegisterUserDataCallbacks( grow_tCtx ctx,
void (*save)( void *, grow_tObject),
void (*open)( void *, grow_tObject),
void (*copy)( grow_tObject, void *, void **));
void (*save)( void *, void *, glow_eUserdataCbType),
void (*open)( void *, void *, glow_eUserdataCbType),
void (*copy)( void *, void *, void **, glow_eUserdataCbType));
//! Get grow versions.
/*!
......@@ -2805,6 +2812,7 @@ typedef GlowTraceData glow_sTraceData;
int grow_GetMenuInputFocus( grow_tObject menu);
void grow_GetSubmenuPosition( grow_tObject menu, int item, double *x, double *y);
int grow_GetMenuParent( grow_tObject menu, grow_tObject *parent);
int grow_SetFolderIndex( grow_tObject folder, int idx);
/*@}*/
#if defined __cplusplus
......
......@@ -64,7 +64,7 @@ void GrowBar::save( ofstream& fp, glow_eSaveMode mode)
GrowRect::save( fp, mode);
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_GrowBar_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this);
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_Node);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -143,7 +143,7 @@ void GrowBar::open( ifstream& fp)
break;
case glow_eSave_GrowBar_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this);
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
break;
case glow_eSave_End: end_found = 1; break;
default:
......
......@@ -1728,6 +1728,10 @@ void GrowCtx::save_grow( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_GrowCtx_mb3_action) << FSPACE << int(mb3_action) << endl;
fp << int(glow_eSave_GrowCtx_translate_on) << FSPACE << translate_on << endl;
fp << int(glow_eSave_GrowCtx_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
if ( user_data && userdata_save_callback) {
fp << int(glow_eSave_GrowCtx_userdata_cb) << endl;
(userdata_save_callback)(&fp, this, glow_eUserdataCbType_Ctx);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -1863,6 +1867,10 @@ void GrowCtx::open_grow( ifstream& fp)
fp >> tmp;
input_focus_mark = (glow_eInputFocusMark)tmp;
break;
case glow_eSave_GrowCtx_userdata_cb:
if ( userdata_open_callback)
(userdata_open_callback)(&fp, this, glow_eUserdataCbType_Ctx);
break;
default:
cout << "GrowCtx:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
......@@ -1950,6 +1958,10 @@ int GrowCtx::save_subgraph( char *filename, glow_eSaveMode mode)
fp << int(glow_eSave_NodeClass_x0) << FSPACE << x0 << endl;
fp << int(glow_eSave_NodeClass_x1) << FSPACE << x1 << endl;
fp << int(glow_eSave_NodeClass_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
if ( user_data && userdata_save_callback) {
fp << int(glow_eSave_NodeClass_userdata_cb) << endl;
(userdata_save_callback)(&fp, this, glow_eUserdataCbType_Ctx);
}
fp << int(glow_eSave_End) << endl;
// End Array
......
......@@ -640,7 +640,24 @@ void GrowFolder::set_textbold( int bold)
draw();
}
int GrowFolder::set_folder( int idx)
{
if ( idx >= folders || idx < 0)
return 0;
// Change file
strcpy( input_file_name, folder_file_names[idx]);
window_scale = folder_scale[idx];
vertical_scrollbar = folder_v_scrollbar[idx];
horizontal_scrollbar = folder_h_scrollbar[idx];
current_folder = idx;
// ctx->set_nodraw();
GrowWindow::update_attributes();
// ctx->reset_nodraw();
draw();
return 1;
}
......
......@@ -206,6 +206,11 @@ class GrowFolder : public GrowWindow {
void set_original_text_color( glow_eDrawType drawtype)
{ text_color_drawtype = drawtype; draw();};
//! Set displayed folder.
/*!
\param idx Folder index.
*/
int set_folder( int idx);
};
......
......@@ -62,7 +62,7 @@ void GrowGroup::copy_from( const GrowGroup& n)
nc = new GlowNodeGroup( (GlowNodeGroup &)*n.nc);
if ( ctx->userdata_copy_callback)
(ctx->userdata_copy_callback)( this, user_data, &user_data);
(ctx->userdata_copy_callback)( this, user_data, &user_data, glow_eUserdataCbType_Node);
}
void GrowGroup::ungroup()
......
......@@ -83,7 +83,7 @@ void GrowNode::copy_from( const GrowNode& n)
}
if ( ctx->userdata_copy_callback)
(ctx->userdata_copy_callback)( this, user_data, &user_data);
(ctx->userdata_copy_callback)( this, user_data, &user_data, glow_eUserdataCbType_Node);
// nc = new GlowNodeClass( *nc);
}
......@@ -152,7 +152,7 @@ void GrowNode::save( ofstream& fp, glow_eSaveMode mode)
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_GrowNode_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this);
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_Node);
}
fp << int(glow_eSave_End) << endl;
......@@ -266,7 +266,7 @@ void GrowNode::open( ifstream& fp)
case glow_eSave_GrowNode_shadow: fp >> shadow; break;
case glow_eSave_GrowNode_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this);
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
break;
case glow_eSave_End: end_found = 1; break;
default:
......
......@@ -21,7 +21,7 @@ GrowRect::GrowRect( GlowCtx *glow_ctx, char *name, double x, double y,
original_fill_drawtype(fill_d_type), fill_drawtype(fill_d_type),
border(display_border),
dynamic(0), dynamicsize(0), shadow(display_shadow), shadow_width(5), relief(glow_eRelief_Up),
shadow_contrast(2), disable_shadow(0)
shadow_contrast(2), disable_shadow(0), invisible(0)
{
strcpy( n_name, name);
pzero.nav_zoom();
......@@ -262,6 +262,7 @@ void GrowRect::save( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_GrowRect_shadow_width) << FSPACE << shadow_width << endl;
fp << int(glow_eSave_GrowRect_shadow_contrast) << FSPACE << shadow_contrast << endl;
fp << int(glow_eSave_GrowRect_relief) << FSPACE << int(relief) << endl;
fp << int(glow_eSave_GrowRect_invisible) << FSPACE << invisible << endl;
fp << int(glow_eSave_GrowRect_disable_shadow) << FSPACE << disable_shadow << endl;
fp << int(glow_eSave_GrowRect_dynamicsize) << FSPACE << dynamicsize << endl;
fp << int(glow_eSave_GrowRect_dynamic) << endl;
......@@ -317,6 +318,7 @@ void GrowRect::open( ifstream& fp)
case glow_eSave_GrowRect_shadow: fp >> shadow; break;
case glow_eSave_GrowRect_relief: fp >> tmp; relief = (glow_eRelief)tmp; break;
case glow_eSave_GrowRect_disable_shadow: fp >> disable_shadow; break;
case glow_eSave_GrowRect_invisible: fp >> invisible; break;
case glow_eSave_GrowRect_dynamicsize: fp >> dynamicsize; break;
case glow_eSave_GrowRect_dynamic:
fp.getline( dummy, sizeof(dummy));
......@@ -692,6 +694,8 @@ void GrowRect::set_rotation( double angel,
void GrowRect::draw( GlowTransform *t, int highlight, int hot, void *node, void *colornode)
{
if ( invisible && !highlight)
return;
if ( !(display_level & ctx->display_level))
return;
int idx;
......@@ -860,6 +864,8 @@ void GrowRect::erase( GlowTransform *t, int hot, void *node)
void GrowRect::nav_draw( GlowTransform *t, int highlight, void *node, void *colornode)
{
if ( invisible && !highlight)
return;
if ( !(display_level & ctx->display_level))
return;
glow_eDrawType drawtype;
......
......@@ -277,6 +277,7 @@ class GrowRect : public GlowRect {
glow_eRelief relief; //!< Type of relief.
int shadow_contrast; //!< Shadow contrast.
int disable_shadow; //!< Disable shadow, even if parent node has shadow.
int invisible; //!< Invisible if not highlighted.
//! Set user data.
/*!
......
......@@ -37,7 +37,7 @@ void GrowSlider::copy_from( const GrowSlider& n)
memcpy( dynamic, n.nc->dynamic, n.dynamicsize);
}
if ( ctx->userdata_copy_callback)
(ctx->userdata_copy_callback)( this, user_data, &user_data);
(ctx->userdata_copy_callback)( this, user_data, &user_data, glow_eUserdataCbType_Node);
// nc = new GlowNodeClass( *nc);
}
......
......@@ -89,7 +89,7 @@ void GrowTable::save( ofstream& fp, glow_eSaveMode mode)
GrowRect::save( fp, mode);
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_GrowTable_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this);
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_Node);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -156,7 +156,7 @@ void GrowTable::open( ifstream& fp)
break;
case glow_eSave_GrowTable_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this);
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
break;
case glow_eSave_End: end_found = 1; break;
default:
......
......@@ -149,7 +149,7 @@ void GrowTrend::save( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_GrowTrend_scan_time) << FSPACE << scan_time << endl;
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_GrowTrend_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this);
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_Node);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -238,7 +238,7 @@ void GrowTrend::open( ifstream& fp)
break;
case glow_eSave_GrowTrend_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this);
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
break;
case glow_eSave_End: end_found = 1; break;
default:
......
......@@ -63,7 +63,7 @@ void GrowWindow::save( ofstream& fp, glow_eSaveMode mode)
GrowRect::save( fp, mode);
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_GrowWindow_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this);
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_Node);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -93,7 +93,7 @@ void GrowWindow::open( ifstream& fp)
break;
case glow_eSave_GrowWindow_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this);
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
break;
case glow_eSave_End: end_found = 1; break;
default:
......
......@@ -44,6 +44,11 @@ GlowNodeClass::GlowNodeClass( const GlowNodeClass& nc)
}
}
GlowNodeClass::~GlowNodeClass()
{
ctx->object_deleted( this);
}
void GlowNodeClass::print( GlowPoint *pos, void *node)
{
int i;
......@@ -120,6 +125,10 @@ void GlowNodeClass::save( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_NodeClass_x0) << FSPACE << x0 << endl;
fp << int(glow_eSave_NodeClass_x1) << FSPACE << x1 << endl;
fp << int(glow_eSave_NodeClass_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_NodeClass_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_NodeClass);
}
fp << int(glow_eSave_End) << endl;
}
......@@ -225,6 +234,10 @@ void GlowNodeClass::open( ifstream& fp)
fp >> tmp;
input_focus_mark = (glow_eInputFocusMark)tmp;
break;
case glow_eSave_NodeClass_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_NodeClass);
break;
case glow_eSave_End: end_found = 1; break;
default:
cout << "GlowNodeClass:open syntax error" << endl;
......
......@@ -41,6 +41,9 @@ class GlowNodeClass : public GlowArrayElem {
*/
GlowNodeClass( const GlowNodeClass& nc);
// Destructor.
~GlowNodeClass();
//! Insert a new element in the nodeclass.
/*!
\param element New element to insert.
......@@ -359,6 +362,24 @@ class GlowNodeClass : public GlowArrayElem {
int get_annotation_info( void *node, int num, int *t_size, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color);
//! Set user data.
/*!
\param data User data.
*/
void set_user_data( void *data) { user_data = data;};
//! Get user data.
/*!
\param data User data.
*/
void get_user_data( void **data) { *data = user_data;};
//! Get grow context.
/*!
\return The context.
*/
void *get_ctx() { return this->ctx;};
GlowCtx *ctx; //!< Glow context.
GlowArray a; //!< Array of nodeclass elements.
char nc_name[32]; //!< Name of nodeclass.
......@@ -394,6 +415,7 @@ class GlowNodeClass : public GlowArrayElem {
int saved; //!< The nodeclass doesn't have any unsaved changes.
glow_eCycle cycle; //!< Cycle, i.e. if dynamics is executed at fast or slow scantime.
glow_eInputFocusMark input_focus_mark; //!< How input focus in marked.
void *user_data; //!< User data.
};
/*@}*/
......
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