Commit 40516f33 authored by Claes Sjofors's avatar Claes Sjofors

Ge text object size changed to dynamic for fix 80 char

parent 0959114d
...@@ -887,7 +887,7 @@ void Graph::change_select_text() ...@@ -887,7 +887,7 @@ void Graph::change_select_text()
{ {
grow_tObject *sel_list; grow_tObject *sel_list;
int sel_count; int sel_count;
char text[80]; char text[200];
grow_GetSelectList( grow->ctx, &sel_list, &sel_count); grow_GetSelectList( grow->ctx, &sel_list, &sel_count);
if ( sel_count == 1 && if ( sel_count == 1 &&
...@@ -897,7 +897,7 @@ void Graph::change_select_text() ...@@ -897,7 +897,7 @@ void Graph::change_select_text()
{ {
journal_store( journal_eAction_AntePropertiesSelect, 0); journal_store( journal_eAction_AntePropertiesSelect, 0);
grow_GetObjectText( *sel_list, text); grow_GetObjectText( *sel_list, text, sizeof(text));
(change_text_cb)( parent_ctx, *sel_list, text); (change_text_cb)( parent_ctx, *sel_list, text);
journal_store( journal_eAction_PostPropertiesSelect, 0); journal_store( journal_eAction_PostPropertiesSelect, 0);
......
...@@ -4098,7 +4098,7 @@ static int graph_getobjecttext_func( ...@@ -4098,7 +4098,7 @@ static int graph_getobjecttext_func(
Graph *graph; Graph *graph;
int type; int type;
grow_tObject o; grow_tObject o;
char text[80]; char text[200];
if ( arg_count != 1) if ( arg_count != 1)
return CCM__ARGMISM; return CCM__ARGMISM;
...@@ -4111,7 +4111,7 @@ static int graph_getobjecttext_func( ...@@ -4111,7 +4111,7 @@ static int graph_getobjecttext_func(
type = grow_GetObjectType( o); type = grow_GetObjectType( o);
if ( type == glow_eObjectType_GrowText) { if ( type == glow_eObjectType_GrowText) {
grow_GetObjectText( o, text); grow_GetObjectText( o, text, sizeof(text));
strncpy( return_string, text, sizeof(text)); strncpy( return_string, text, sizeof(text));
} }
else else
......
...@@ -4728,9 +4728,9 @@ void grow_SetObjectText( grow_tObject object, char *text) ...@@ -4728,9 +4728,9 @@ void grow_SetObjectText( grow_tObject object, char *text)
((GrowText *)object)->set_text( text); ((GrowText *)object)->set_text( text);
} }
void grow_GetObjectText( grow_tObject object, char *text) void grow_GetObjectText( grow_tObject object, char *text, int size)
{ {
((GrowText *)object)->get_text( text); ((GrowText *)object)->get_text( text, size);
} }
void grow_SetSelectTextSize( grow_tCtx ctx, int size) void grow_SetSelectTextSize( grow_tCtx ctx, int size)
......
...@@ -2104,7 +2104,7 @@ extern "C" { ...@@ -2104,7 +2104,7 @@ extern "C" {
\param object A GrowText object. \param object A GrowText object.
\param text Text. \param text Text.
*/ */
void grow_GetObjectText( grow_tObject object, char *text); void grow_GetObjectText( grow_tObject object, char *text, int size);
//! Set text size on all selected objects. //! Set text size on all selected objects.
/*! /*!
......
...@@ -360,8 +360,9 @@ void GrowText::open( ifstream& fp) ...@@ -360,8 +360,9 @@ void GrowText::open( ifstream& fp)
if ( ctx->translate_on && if ( ctx->translate_on &&
ctx->event_callback[glow_eEvent_Translate]) { ctx->event_callback[glow_eEvent_Translate]) {
if ( ctx->translate_cb( this, text, &new_text)) { if ( ctx->translate_cb( this, text, &new_text)) {
strncpy( text, new_text, sizeof(text)); free( text);
text[sizeof(text)-1] = 0; text = (char *)malloc( strlen(new_text)+1);
strcpy( text, new_text);
} }
get_node_borders(); get_node_borders();
} }
...@@ -971,7 +972,9 @@ void GrowText::set_text( char *new_text) ...@@ -971,7 +972,9 @@ void GrowText::set_text( char *new_text)
erase( &ctx->mw); erase( &ctx->mw);
erase( &ctx->navw); erase( &ctx->navw);
strncpy( text, new_text, sizeof(text)-1); free( text);
text = (char *)malloc( strlen(new_text)+1);
strcpy( text, new_text);
get_node_borders(); get_node_borders();
// draw(); // draw();
......
...@@ -281,7 +281,7 @@ class GrowText : public GlowText { ...@@ -281,7 +281,7 @@ class GrowText : public GlowText {
/*! /*!
\param str buffer where the text is copied. \param str buffer where the text is copied.
*/ */
void get_text( char *str) { strcpy( str, text);}; void get_text( char *str, int size) { strncpy( str, text, size); str[size-1] = 0;};
//! Set text size //! Set text size
/*! /*!
......
...@@ -80,6 +80,7 @@ void GlowText::open( ifstream& fp) ...@@ -80,6 +80,7 @@ void GlowText::open( ifstream& fp)
int type; int type;
int end_found = 0; int end_found = 0;
char dummy[40]; char dummy[40];
char tmp_text[500];
int tmp; int tmp;
for (;;) for (;;)
...@@ -98,7 +99,10 @@ void GlowText::open( ifstream& fp) ...@@ -98,7 +99,10 @@ void GlowText::open( ifstream& fp)
case glow_eSave_Text_color_drawtype: fp >> tmp; color_drawtype = (glow_eDrawType)tmp; break; case glow_eSave_Text_color_drawtype: fp >> tmp; color_drawtype = (glow_eDrawType)tmp; break;
case glow_eSave_Text_text: case glow_eSave_Text_text:
fp.get(); fp.get();
fp.getline( text, sizeof(text)); fp.getline( tmp_text, sizeof(tmp_text));
free( text);
text = (char *)malloc(strlen(tmp_text)+1);
strcpy( text, tmp_text);
break; break;
case glow_eSave_Text_p: p.open( fp); break; case glow_eSave_Text_p: p.open( fp); break;
case glow_eSave_End: end_found = 1; break; case glow_eSave_End: end_found = 1; break;
......
...@@ -73,8 +73,13 @@ class GlowText : public GlowArrayElem { ...@@ -73,8 +73,13 @@ class GlowText : public GlowArrayElem {
glow_eDrawType color_d_type = glow_eDrawType_Line, glow_eDrawType color_d_type = glow_eDrawType_Line,
int t_size = 2, glow_mDisplayLevel display_lev = glow_mDisplayLevel_1) : int t_size = 2, glow_mDisplayLevel display_lev = glow_mDisplayLevel_1) :
ctx(glow_ctx), p(glow_ctx,x,y), draw_type(d_type), text_size(t_size), ctx(glow_ctx), p(glow_ctx,x,y), draw_type(d_type), text_size(t_size),
display_level(display_lev), color_drawtype( color_d_type) display_level(display_lev), color_drawtype( color_d_type) {
{ strncpy( text, text1, sizeof(text));}; text = (char *)malloc(strlen(text1)+1); strcpy( text, text1);
}
~GlowText() {
free( text);
}
friend ostream& operator<< ( ostream& o, const GlowText t); friend ostream& operator<< ( ostream& o, const GlowText t);
...@@ -184,7 +189,7 @@ class GlowText : public GlowArrayElem { ...@@ -184,7 +189,7 @@ class GlowText : public GlowArrayElem {
GrowCtx *ctx; //!< Glow context. GrowCtx *ctx; //!< Glow context.
GlowPoint p; //!< Position point. GlowPoint p; //!< Position point.
char text[80]; //!< The text. char *text; //!< The text.
glow_eDrawType draw_type; //!< Drawtype for the text. glow_eDrawType draw_type; //!< Drawtype for the text.
int text_size; //!< Text size. int text_size; //!< Text size.
glow_mDisplayLevel display_level; //!< Display level when the object is visible. glow_mDisplayLevel display_level; //!< Display level when the object is visible.
......
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