Commit 89a378de authored by claes's avatar claes

Adjustment of annotations texts and GrowTable

parent 698d3c51
/* /*
* Proview $Id: glow.h,v 1.14 2006-05-24 08:01:51 claes Exp $ * Proview $Id: glow.h,v 1.15 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -72,7 +72,8 @@ typedef enum { ...@@ -72,7 +72,8 @@ typedef enum {
glow_eType_MB3Action, //!< Type is glow_eMB3Action glow_eType_MB3Action, //!< Type is glow_eMB3Action
glow_eType_Relief, //!< Type is glow_eRelief glow_eType_Relief, //!< Type is glow_eRelief
glow_eType_InputFocusMark, //!< Type is glow_eInputFocusMark glow_eType_InputFocusMark, //!< Type is glow_eInputFocusMark
glow_eType_TextSize //!< Type is a text size, glow_eTextSize glow_eType_TextSize, //!< Type is a text size, glow_eTextSize
glow_eType_Adjustment //!< Type is glow_eAdjustment
} glow_eType; } glow_eType;
//! Type of Ctx class //! Type of Ctx class
...@@ -194,6 +195,13 @@ typedef enum { ...@@ -194,6 +195,13 @@ typedef enum {
glow_eDirection_Down //!< Direction down glow_eDirection_Down //!< Direction down
} glow_eDirection; } glow_eDirection;
//! Adjustment of annotations
typedef enum {
glow_eAdjustment_Center, //!< Adjustment center
glow_eAdjustment_Right, //!< Adjustment right
glow_eAdjustment_Left //!< Adjustment left
} glow_eAdjustment;
//! Type of mirror //! Type of mirror
typedef enum { typedef enum {
glow_eFlipDirection_Vertical, //!< Mirroring through a vertical line glow_eFlipDirection_Vertical, //!< Mirroring through a vertical line
...@@ -1242,6 +1250,7 @@ typedef enum { ...@@ -1242,6 +1250,7 @@ typedef enum {
glow_eSave_GrowSubAnnot_rect = 2306, glow_eSave_GrowSubAnnot_rect = 2306,
glow_eSave_GrowSubAnnot_annot_part = 2307, glow_eSave_GrowSubAnnot_annot_part = 2307,
glow_eSave_GrowSubAnnot_trf = 2308, glow_eSave_GrowSubAnnot_trf = 2308,
glow_eSave_GrowSubAnnot_adjustment = 2309,
glow_eSave_GrowArc_x_right = 2400, glow_eSave_GrowArc_x_right = 2400,
glow_eSave_GrowArc_x_left = 2401, glow_eSave_GrowArc_x_left = 2401,
glow_eSave_GrowArc_y_high = 2402, glow_eSave_GrowArc_y_high = 2402,
...@@ -1318,6 +1327,7 @@ typedef enum { ...@@ -1318,6 +1327,7 @@ typedef enum {
glow_eSave_Transform_a22 = 2804, glow_eSave_Transform_a22 = 2804,
glow_eSave_Transform_a23 = 2805, glow_eSave_Transform_a23 = 2805,
glow_eSave_Transform_rotation = 2806, glow_eSave_Transform_rotation = 2806,
glow_eSave_GrowAnnot_adjustment = 2901,
glow_eSave_GrowAnnot_annot_part = 2907, glow_eSave_GrowAnnot_annot_part = 2907,
glow_eSave_GrowAnnot_trf = 2908, glow_eSave_GrowAnnot_trf = 2908,
glow_eSave_GrowText_x_right = 3000, glow_eSave_GrowText_x_right = 3000,
...@@ -1581,7 +1591,19 @@ typedef enum { ...@@ -1581,7 +1591,19 @@ typedef enum {
glow_eSave_GrowTable_header_text11 = 4261, glow_eSave_GrowTable_header_text11 = 4261,
glow_eSave_GrowTable_column_width12 = 4262, glow_eSave_GrowTable_column_width12 = 4262,
glow_eSave_GrowTable_header_text12 = 4263, glow_eSave_GrowTable_header_text12 = 4263,
glow_eSave_GrowTable_select_drawtype = 4264 glow_eSave_GrowTable_select_drawtype = 4264,
glow_eSave_GrowTable_column_adjustment1 = 4265,
glow_eSave_GrowTable_column_adjustment2 = 4266,
glow_eSave_GrowTable_column_adjustment3 = 4267,
glow_eSave_GrowTable_column_adjustment4 = 4268,
glow_eSave_GrowTable_column_adjustment5 = 4269,
glow_eSave_GrowTable_column_adjustment6 = 4270,
glow_eSave_GrowTable_column_adjustment7 = 4271,
glow_eSave_GrowTable_column_adjustment8 = 4272,
glow_eSave_GrowTable_column_adjustment9 = 4273,
glow_eSave_GrowTable_column_adjustment10 = 4274,
glow_eSave_GrowTable_column_adjustment11 = 4275,
glow_eSave_GrowTable_column_adjustment12 = 4276
} glow_eSave; } glow_eSave;
//! Relative or absolute position for an annotation //! Relative or absolute position for an annotation
......
/* /*
* Proview $Id: glow_growannot.cpp,v 1.6 2005-09-01 14:57:53 claes Exp $ * Proview $Id: glow_growannot.cpp,v 1.7 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -43,6 +43,7 @@ void GrowAnnot::save( ofstream& fp, glow_eSaveMode mode) ...@@ -43,6 +43,7 @@ void GrowAnnot::save( ofstream& fp, glow_eSaveMode mode)
GlowAnnot::save( fp, mode); GlowAnnot::save( fp, mode);
fp << int(glow_eSave_GrowAnnot_trf) << endl; fp << int(glow_eSave_GrowAnnot_trf) << endl;
trf.save( fp, mode); trf.save( fp, mode);
fp << int(glow_eSave_GrowAnnot_adjustment) << FSPACE << int(adjustment) << endl;
fp << int(glow_eSave_End) << endl; fp << int(glow_eSave_End) << endl;
} }
} }
...@@ -52,6 +53,7 @@ void GrowAnnot::open( ifstream& fp) ...@@ -52,6 +53,7 @@ void GrowAnnot::open( ifstream& fp)
int type; int type;
int end_found = 0; int end_found = 0;
char dummy[40]; char dummy[40];
int tmp;
for (;;) for (;;)
{ {
...@@ -62,6 +64,7 @@ void GrowAnnot::open( ifstream& fp) ...@@ -62,6 +64,7 @@ void GrowAnnot::open( ifstream& fp)
GlowAnnot::open( fp); GlowAnnot::open( fp);
break; break;
case glow_eSave_GrowAnnot_trf: trf.open( fp); break; case glow_eSave_GrowAnnot_trf: trf.open( fp); break;
case glow_eSave_GrowAnnot_adjustment: fp >> tmp; adjustment = (glow_eAdjustment)tmp; break;
case glow_eSave_End: end_found = 1; break; case glow_eSave_End: end_found = 1; break;
default: default:
cout << "GrowAnnot:open syntax error" << endl; cout << "GrowAnnot:open syntax error" << endl;
...@@ -112,25 +115,39 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node, ...@@ -112,25 +115,39 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node,
color = ((GrowCtx *)ctx)->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight, color = ((GrowCtx *)ctx)->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight,
highlight, (GrowNode *)colornode, 2); highlight, (GrowNode *)colornode, 2);
if ( ((rot < 45 || rot >= 315) &&
( ((GlowNode *) node)->annotv_inputmode[number] &&
((GrowNode *) node)->input_selected)) ||
( !(rot < 45 || rot >= 315)) ||
adjustment == glow_eAdjustment_Right ||
adjustment == glow_eAdjustment_Center)
draw_get_text_extent( ctx, ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]),
draw_type, idx,
&width, &height, &descent);
switch ( adjustment) {
case glow_eAdjustment_Left:
break;
case glow_eAdjustment_Right:
x1 -= width;
break;
case glow_eAdjustment_Center:
x1 -= width /2;
break;
}
if ( rot < 45 || rot >= 315) { if ( rot < 45 || rot >= 315) {
if ( ((GlowNode *) node)->annotv_inputmode[number] && if ( ((GlowNode *) node)->annotv_inputmode[number] &&
((GrowNode *) node)->input_selected) { ((GrowNode *) node)->input_selected) {
draw_get_text_extent( ctx, ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]),
draw_type, idx,
&width, &height, &descent);
glow_draw_fill_rect( ctx, x1, y1 - height + descent, width, height, glow_draw_fill_rect( ctx, x1, y1 - height + descent, width, height,
glow_eDrawType_MediumGray); glow_eDrawType_MediumGray);
} }
} }
else { else {
// Text is rotated, adjust the coordinates // Text is rotated, adjust the coordinates
draw_get_text_extent( ctx, ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]),
draw_type, idx,
&width, &height, &descent);
if ( 45 <= rot && rot < 135) { if ( 45 <= rot && rot < 135) {
y1 += height - descent; y1 += height - descent;
} }
...@@ -142,6 +159,7 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node, ...@@ -142,6 +159,7 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node,
x1 -= width; x1 -= width;
} }
} }
glow_draw_text( ctx, x1, y1, glow_draw_text( ctx, x1, y1,
((GlowNode *) node)->annotv[number], ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]), draw_type, color, idx, strlen(((GlowNode *) node)->annotv[number]), draw_type, color, idx,
...@@ -180,7 +198,7 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node, ...@@ -180,7 +198,7 @@ void GrowAnnot::draw( GlowTransform *t, int highlight, int hot, void *node,
line = s+1; line = s+1;
line_cnt++; line_cnt++;
} }
else else
len++; len++;
} }
if ( len) if ( len)
...@@ -219,13 +237,29 @@ void GrowAnnot::erase( GlowTransform *t, int hot, void *node) ...@@ -219,13 +237,29 @@ void GrowAnnot::erase( GlowTransform *t, int hot, void *node)
switch ( annot_type) { switch ( annot_type) {
case glow_eAnnotType_OneLine: case glow_eAnnotType_OneLine:
{ {
if ( ((GlowNode *) node)->annotv_inputmode[number] && int width, height, descent;
((GrowNode *) node)->input_selected) {
int width, height, descent; if ( ( ((GlowNode *) node)->annotv_inputmode[number] &&
((GrowNode *) node)->input_selected) ||
adjustment == glow_eAdjustment_Right ||
adjustment == glow_eAdjustment_Center)
draw_get_text_extent( ctx, ((GlowNode *) node)->annotv[number], draw_get_text_extent( ctx, ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]), strlen(((GlowNode *) node)->annotv[number]),
draw_type, idx, draw_type, idx,
&width, &height, &descent); &width, &height, &descent);
switch ( adjustment) {
case glow_eAdjustment_Left:
break;
case glow_eAdjustment_Right:
x1 -= width;
break;
case glow_eAdjustment_Center:
x1 -= width /2;
break;
}
if ( ((GlowNode *) node)->annotv_inputmode[number] &&
((GrowNode *) node)->input_selected) {
glow_draw_fill_rect( ctx, x1, y1 - height + descent, width, height, glow_eDrawType_LineErase); glow_draw_fill_rect( ctx, x1, y1 - height + descent, width, height, glow_eDrawType_LineErase);
} }
glow_draw_text_erase( ctx, x1, y1, glow_draw_text_erase( ctx, x1, y1,
......
/* /*
* Proview $Id: glow_growannot.h,v 1.3 2005-09-01 14:57:53 claes Exp $ * Proview $Id: glow_growannot.h,v 1.4 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB. * Copyright (C) 2005 SSAB Oxelösund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -60,7 +60,7 @@ class GrowAnnot : public GlowAnnot { ...@@ -60,7 +60,7 @@ class GrowAnnot : public GlowAnnot {
int rel_pos = 0, glow_mDisplayLevel display_lev = glow_mDisplayLevel_1, int rel_pos = 0, glow_mDisplayLevel display_lev = glow_mDisplayLevel_1,
int nodraw =0): int nodraw =0):
GlowAnnot(glow_ctx,x,y,annot_num,d_type,color_d_type,t_size,a_type, GlowAnnot(glow_ctx,x,y,annot_num,d_type,color_d_type,t_size,a_type,
rel_pos,display_lev), temporary_scale(0) {}; rel_pos,display_lev), temporary_scale(0), adjustment(glow_eAdjustment_Left) {};
//! Save the content of the object to file. //! Save the content of the object to file.
/*! /*!
...@@ -86,6 +86,7 @@ class GrowAnnot : public GlowAnnot { ...@@ -86,6 +86,7 @@ class GrowAnnot : public GlowAnnot {
GlowTransform trf; //!< Transformation matrix of object. GlowTransform trf; //!< Transformation matrix of object.
int temporary_scale; //!< Not used. int temporary_scale; //!< Not used.
glow_eAdjustment adjustment; //!< Text adjustment.
//! Draw the object. //! Draw the object.
/*! /*!
......
/* /*
* Proview $Id: glow_growapi.cpp,v 1.23 2006-06-14 05:04:10 claes Exp $ * Proview $Id: glow_growapi.cpp,v 1.24 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -1516,6 +1516,11 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1516,6 +1516,11 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Int; attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof( op->number); attrinfo[i++].size = sizeof( op->number);
strcpy( attrinfo[i].name, "Adjustment");
attrinfo[i].value_p = &op->adjustment;
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->adjustment);
break; break;
} }
case glow_eObjectType_GrowText: case glow_eObjectType_GrowText:
...@@ -1938,6 +1943,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1938,6 +1943,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment1"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[0];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText1"))) { if ( (name = growapi_translate( transtab, "HeaderText1"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[0]; attrinfo[i].value_p = op->header_text[0];
...@@ -1950,6 +1961,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1950,6 +1961,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment2"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[1];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText2"))) { if ( (name = growapi_translate( transtab, "HeaderText2"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[1]; attrinfo[i].value_p = op->header_text[1];
...@@ -1962,6 +1979,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1962,6 +1979,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment3"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[2];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText3"))) { if ( (name = growapi_translate( transtab, "HeaderText3"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[2]; attrinfo[i].value_p = op->header_text[2];
...@@ -1974,6 +1997,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1974,6 +1997,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment4"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[3];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText4"))) { if ( (name = growapi_translate( transtab, "HeaderText4"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[3]; attrinfo[i].value_p = op->header_text[3];
...@@ -1986,6 +2015,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1986,6 +2015,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment5"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[4];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText5"))) { if ( (name = growapi_translate( transtab, "HeaderText5"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[4]; attrinfo[i].value_p = op->header_text[4];
...@@ -1998,6 +2033,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -1998,6 +2033,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment6"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[5];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText6"))) { if ( (name = growapi_translate( transtab, "HeaderText6"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[5]; attrinfo[i].value_p = op->header_text[5];
...@@ -2010,6 +2051,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2010,6 +2051,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment7"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[6];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText7"))) { if ( (name = growapi_translate( transtab, "HeaderText7"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[6]; attrinfo[i].value_p = op->header_text[6];
...@@ -2022,6 +2069,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2022,6 +2069,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment8"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[7];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText8"))) { if ( (name = growapi_translate( transtab, "HeaderText8"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[7]; attrinfo[i].value_p = op->header_text[7];
...@@ -2034,6 +2087,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2034,6 +2087,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment9"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[8];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText9"))) { if ( (name = growapi_translate( transtab, "HeaderText9"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[8]; attrinfo[i].value_p = op->header_text[8];
...@@ -2046,6 +2105,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2046,6 +2105,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment10"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[9];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText10"))) { if ( (name = growapi_translate( transtab, "HeaderText10"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[9]; attrinfo[i].value_p = op->header_text[9];
...@@ -2058,6 +2123,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2058,6 +2123,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment11"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[10];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText11"))) { if ( (name = growapi_translate( transtab, "HeaderText11"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[10]; attrinfo[i].value_p = op->header_text[10];
...@@ -2070,6 +2141,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab, ...@@ -2070,6 +2141,12 @@ int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
attrinfo[i].type = glow_eType_Double; attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof( op->column_width[0]); attrinfo[i++].size = sizeof( op->column_width[0]);
} }
if ( (name = growapi_translate( transtab, "ColumnAdjustment12"))) {
strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = &op->column_adjustment[11];
attrinfo[i].type = glow_eType_Adjustment;
attrinfo[i++].size = sizeof( op->column_adjustment[0]);
}
if ( (name = growapi_translate( transtab, "HeaderText12"))) { if ( (name = growapi_translate( transtab, "HeaderText12"))) {
strcpy( attrinfo[i].name, name); strcpy( attrinfo[i].name, name);
attrinfo[i].value_p = op->header_text[11]; attrinfo[i].value_p = op->header_text[11];
......
/* /*
* Proview $Id: glow_growsubannot.cpp,v 1.3 2005-09-01 14:57:54 claes Exp $ * Proview $Id: glow_growsubannot.cpp,v 1.4 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -39,7 +39,7 @@ GrowSubAnnot::GrowSubAnnot( GlowCtx *glow_ctx, char *name, double x, double y, ...@@ -39,7 +39,7 @@ GrowSubAnnot::GrowSubAnnot( GlowCtx *glow_ctx, char *name, double x, double y,
text( ctx, "", x, y, d_type, color_d_type, t_size), text( ctx, "", x, y, d_type, color_d_type, t_size),
rect( ctx, x, y - ctx->draw_delta, ctx->draw_delta, ctx->draw_delta, rect( ctx, x, y - ctx->draw_delta, ctx->draw_delta, ctx->draw_delta,
glow_eDrawType_LineGray), glow_eDrawType_LineGray),
user_data(NULL) user_data(NULL), adjustment(glow_eAdjustment_Left)
{ {
strcpy( n_name, name); strcpy( n_name, name);
pzero.nav_zoom(); pzero.nav_zoom();
...@@ -251,6 +251,7 @@ void GrowSubAnnot::save( ofstream& fp, glow_eSaveMode mode) ...@@ -251,6 +251,7 @@ void GrowSubAnnot::save( ofstream& fp, glow_eSaveMode mode)
GlowAnnot::save( fp, mode); GlowAnnot::save( fp, mode);
fp << int(glow_eSave_GrowAnnot_trf) << endl; fp << int(glow_eSave_GrowAnnot_trf) << endl;
trf.save( fp, mode); trf.save( fp, mode);
fp << int(glow_eSave_GrowAnnot_adjustment) << FSPACE << int(adjustment) << endl;
fp << int(glow_eSave_End) << endl; fp << int(glow_eSave_End) << endl;
} }
else else
...@@ -269,6 +270,7 @@ void GrowSubAnnot::save( ofstream& fp, glow_eSaveMode mode) ...@@ -269,6 +270,7 @@ void GrowSubAnnot::save( ofstream& fp, glow_eSaveMode mode)
GlowAnnot::save( fp, mode); GlowAnnot::save( fp, mode);
fp << int(glow_eSave_GrowSubAnnot_trf) << endl; fp << int(glow_eSave_GrowSubAnnot_trf) << endl;
trf.save( fp, mode); trf.save( fp, mode);
fp << int(glow_eSave_GrowSubAnnot_adjustment) << FSPACE << int(adjustment) << endl;
fp << int(glow_eSave_End) << endl; fp << int(glow_eSave_End) << endl;
} }
} }
...@@ -278,6 +280,7 @@ void GrowSubAnnot::open( ifstream& fp) ...@@ -278,6 +280,7 @@ void GrowSubAnnot::open( ifstream& fp)
int type; int type;
int end_found = 0; int end_found = 0;
char dummy[40]; char dummy[40];
int tmp;
for (;;) for (;;)
{ {
...@@ -298,6 +301,7 @@ void GrowSubAnnot::open( ifstream& fp) ...@@ -298,6 +301,7 @@ void GrowSubAnnot::open( ifstream& fp)
GlowAnnot::open( fp); GlowAnnot::open( fp);
break; break;
case glow_eSave_GrowSubAnnot_trf: trf.open( fp); break; case glow_eSave_GrowSubAnnot_trf: trf.open( fp); break;
case glow_eSave_GrowSubAnnot_adjustment: fp >> tmp; adjustment = (glow_eAdjustment)tmp; break;
case glow_eSave_End: end_found = 1; break; case glow_eSave_End: end_found = 1; break;
default: default:
cout << "GrowSubAnnot:open syntax error" << endl; cout << "GrowSubAnnot:open syntax error" << endl;
......
/* /*
* Proview $Id: glow_growsubannot.h,v 1.3 2005-09-01 14:57:54 claes Exp $ * Proview $Id: glow_growsubannot.h,v 1.4 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -85,6 +85,7 @@ class GrowSubAnnot : public GlowAnnot { ...@@ -85,6 +85,7 @@ class GrowSubAnnot : public GlowAnnot {
GlowRect rect; GlowRect rect;
void *user_data; void *user_data;
GlowTransform trf; GlowTransform trf;
glow_eAdjustment adjustment;
void set_user_data( void *data) { user_data = data;}; void set_user_data( void *data) { user_data = data;};
void get_user_data( void **data) { *data = user_data;}; void get_user_data( void **data) { *data = user_data;};
void *get_ctx() { return this->ctx;}; void *get_ctx() { return this->ctx;};
......
/* /*
* Proview $Id: glow_growtable.cpp,v 1.10 2006-05-24 08:01:51 claes Exp $ * Proview $Id: glow_growtable.cpp,v 1.11 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -54,6 +54,7 @@ GrowTable::GrowTable( GlowCtx *glow_ctx, char *name, double x, double y, ...@@ -54,6 +54,7 @@ GrowTable::GrowTable( GlowCtx *glow_ctx, char *name, double x, double y,
strcpy( header_text[i], ""); strcpy( header_text[i], "");
column_width[i] = 4; column_width[i] = 4;
column_size[i] = 12; column_size[i] = 12;
column_adjustment[i] = glow_eAdjustment_Left;
} }
configure(); configure();
...@@ -105,6 +106,7 @@ void GrowTable::save( ofstream& fp, glow_eSaveMode mode) ...@@ -105,6 +106,7 @@ void GrowTable::save( ofstream& fp, glow_eSaveMode mode)
for ( int i = 0; i < TABLE_MAX_COL; i++) { for ( int i = 0; i < TABLE_MAX_COL; i++) {
fp << int(glow_eSave_GrowTable_column_width1)+2*i << FSPACE << column_width[i] << endl; fp << int(glow_eSave_GrowTable_column_width1)+2*i << FSPACE << column_width[i] << endl;
fp << int(glow_eSave_GrowTable_header_text1)+2*i << FSPACE << header_text[i] << endl; fp << int(glow_eSave_GrowTable_header_text1)+2*i << FSPACE << header_text[i] << endl;
fp << int(glow_eSave_GrowTable_column_adjustment1)+i << FSPACE << int(column_adjustment[i]) << endl;
} }
fp << int(glow_eSave_GrowTable_rect_part) << endl; fp << int(glow_eSave_GrowTable_rect_part) << endl;
GrowRect::save( fp, mode); GrowRect::save( fp, mode);
...@@ -173,6 +175,18 @@ void GrowTable::open( ifstream& fp) ...@@ -173,6 +175,18 @@ void GrowTable::open( ifstream& fp)
case glow_eSave_GrowTable_header_text11: fp.get(); fp.getline( header_text[10], sizeof(header_text[0])); break; case glow_eSave_GrowTable_header_text11: fp.get(); fp.getline( header_text[10], sizeof(header_text[0])); break;
case glow_eSave_GrowTable_column_width12: fp >> column_width[11]; break; case glow_eSave_GrowTable_column_width12: fp >> column_width[11]; break;
case glow_eSave_GrowTable_header_text12: fp.get(); fp.getline( header_text[11], sizeof(header_text[0])); break; case glow_eSave_GrowTable_header_text12: fp.get(); fp.getline( header_text[11], sizeof(header_text[0])); break;
case glow_eSave_GrowTable_column_adjustment1: fp >> tmp; column_adjustment[0] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment2: fp >> tmp; column_adjustment[1] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment3: fp >> tmp; column_adjustment[2] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment4: fp >> tmp; column_adjustment[3] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment5: fp >> tmp; column_adjustment[4] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment6: fp >> tmp; column_adjustment[5] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment7: fp >> tmp; column_adjustment[6] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment8: fp >> tmp; column_adjustment[7] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment9: fp >> tmp; column_adjustment[8] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment10: fp >> tmp; column_adjustment[9] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment11: fp >> tmp; column_adjustment[10] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_column_adjustment12: fp >> tmp; column_adjustment[11] = (glow_eAdjustment)tmp; break;
case glow_eSave_GrowTable_rect_part: case glow_eSave_GrowTable_rect_part:
GrowRect::open( fp); GrowRect::open( fp);
break; break;
...@@ -417,10 +431,11 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void ...@@ -417,10 +431,11 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void
y = ll_y; y = ll_y;
for ( int i = header_column; i < columns; i++) { for ( int i = header_column; i < columns; i++) {
if ( header_text_idx >= 0 && strcmp( header_text[i], "") != 0) if ( header_text_idx >= 0 && strcmp( header_text[i], "") != 0) {
glow_draw_text( ctx, int(x + text_offs), int(y + header_h - 4), glow_draw_text( ctx, int(x + text_offs), int(y + header_h - 4),
header_text[i], strlen(header_text[i]), header_text_drawtype, header_text_color, header_text[i], strlen(header_text[i]), header_text_drawtype, header_text_color,
header_text_idx, highlight, 0); header_text_idx, highlight, 0);
}
x += column_width[i] * ctx->zoom_factor_x; x += column_width[i] * ctx->zoom_factor_x;
if ( x > ur_x) if ( x > ur_x)
break; break;
...@@ -491,10 +506,31 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void ...@@ -491,10 +506,31 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void
glow_draw_line( ctx, ll_x, int(y), ll_x + header_w, int(y), drawtype, idx, 0); glow_draw_line( ctx, ll_x, int(y), ll_x + header_w, int(y), drawtype, idx, 0);
offs = column_size[0] * i; offs = column_size[0] * i;
if ( text_idx >= 0 && strcmp( cell_value + offs, "") != 0) if ( text_idx >= 0 && strcmp( cell_value + offs, "") != 0) {
glow_draw_text( ctx, int(x + text_offs), int(y - 2), int text_x = int(x) + text_offs;
if ( column_adjustment[0] == glow_eAdjustment_Right ||
column_adjustment[0] == glow_eAdjustment_Center) {
int width, height, descent;
draw_get_text_extent( ctx, cell_value + offs, strlen(cell_value + offs),
text_drawtype, text_idx,
&width, &height, &descent);
switch ( column_adjustment[0]) {
case glow_eAdjustment_Left:
break;
case glow_eAdjustment_Right:
text_x = int(x) + header_w - text_offs - width;
break;
case glow_eAdjustment_Center:
text_x = int(x + (header_w - width)/2);
break;
}
}
glow_draw_text( ctx, text_x, int(y - 2),
cell_value + offs, strlen(cell_value + offs), text_drawtype, text_color_drawtype, cell_value + offs, strlen(cell_value + offs), text_drawtype, text_color_drawtype,
text_idx, highlight, 0); text_idx, highlight, 0);
}
} }
} }
glow_draw_reset_clip_rectangle( ctx); glow_draw_reset_clip_rectangle( ctx);
...@@ -596,10 +632,32 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void ...@@ -596,10 +632,32 @@ void GrowTable::draw( GlowTransform *t, int highlight, int hot, void *node, void
if ( y > ll_y) { if ( y > ll_y) {
offs = column_offs + column_size[i] * j; offs = column_offs + column_size[i] * j;
if ( text_idx >= 0 && strcmp( cell_value + offs, "") != 0) if ( text_idx >= 0 && strcmp( cell_value + offs, "") != 0) {
glow_draw_text( ctx, int(x + text_offs), int(y - 2), int text_x = int(x) + text_offs;
if ( column_adjustment[i] == glow_eAdjustment_Right ||
column_adjustment[i] == glow_eAdjustment_Center) {
int width, height, descent;
draw_get_text_extent( ctx, cell_value + offs, strlen(cell_value + offs),
text_drawtype, text_idx,
&width, &height, &descent);
switch ( column_adjustment[i]) {
case glow_eAdjustment_Left:
break;
case glow_eAdjustment_Right:
text_x = int(x + column_width[i] * ctx->zoom_factor_x) - text_offs - width;
break;
case glow_eAdjustment_Center:
text_x = int(x + (column_width[i] * ctx->zoom_factor_x - width)/2);
break;
}
}
glow_draw_text( ctx, text_x, int(y - 2),
cell_value + offs, strlen(cell_value + offs), text_drawtype, text_color_drawtype, cell_value + offs, strlen(cell_value + offs), text_drawtype, text_color_drawtype,
text_idx, highlight, 0); text_idx, highlight, 0);
}
} }
} }
} }
......
/* /*
* Proview $Id: glow_growtable.h,v 1.6 2006-05-24 08:01:51 claes Exp $ * Proview $Id: glow_growtable.h,v 1.7 2006-06-29 10:51:17 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -165,6 +165,7 @@ class GrowTable : public GrowRect { ...@@ -165,6 +165,7 @@ class GrowTable : public GrowRect {
double column_width[TABLE_MAX_COL]; //!< Width of each column. double column_width[TABLE_MAX_COL]; //!< Width of each column.
char header_text[TABLE_MAX_COL][40]; //!< Header text for each column. char header_text[TABLE_MAX_COL][40]; //!< Header text for each column.
int column_size[TABLE_MAX_COL]; //!< Max length of text in column. int column_size[TABLE_MAX_COL]; //!< Max length of text in column.
glow_eAdjustment column_adjustment[TABLE_MAX_COL]; //!< Text adjustment in column.
int value_size; //!< Total size of cell_value. int value_size; //!< Total size of cell_value.
char *cell_value; //!< Contains the cell values. char *cell_value; //!< Contains the cell values.
int selected_cell_row; //!< Row of the currently selected cell. -1 of no row is selected. int selected_cell_row; //!< Row of the currently selected cell. -1 of no row is selected.
......
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