Commit 54f84c2b authored by claes's avatar claes

Font can be set on node level for annot and text

parent d62ed5cd
/* /*
* Proview $Id: glow_draw_gtk.cpp,v 1.17 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_draw_gtk.cpp,v 1.18 2008-12-01 16:32:40 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
...@@ -41,8 +41,6 @@ using namespace std; ...@@ -41,8 +41,6 @@ using namespace std;
#include "glow_msg.h" #include "glow_msg.h"
static int pango = 1;
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle)) #define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle)) #define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
...@@ -1559,7 +1557,7 @@ int GlowDrawGtk::text( GlowWind *wind, int x, int y, char *text, int len, ...@@ -1559,7 +1557,7 @@ int GlowDrawGtk::text( GlowWind *wind, int x, int y, char *text, int len,
if ( ctx->nodraw) return 1; if ( ctx->nodraw) return 1;
DrawWindGtk *w = (DrawWindGtk *) wind->window; DrawWindGtk *w = (DrawWindGtk *) wind->window;
if ( pango) if ( !((GrowCtx *)ctx)->bitmap_fonts)
return text_pango( wind, x, y, text, len, gc_type, color, idx, highlight, line, font_idx, size); return text_pango( wind, x, y, text, len, gc_type, color, idx, highlight, line, font_idx, size);
if ( font_idx > glow_eFont_Courier) if ( font_idx > glow_eFont_Courier)
...@@ -1654,7 +1652,7 @@ int GlowDrawGtk::text_erase( GlowWind *wind, int x, int y, char *text, int len, ...@@ -1654,7 +1652,7 @@ int GlowDrawGtk::text_erase( GlowWind *wind, int x, int y, char *text, int len,
if ( ctx->nodraw) return 1; if ( ctx->nodraw) return 1;
DrawWindGtk *w = (DrawWindGtk *) wind->window; DrawWindGtk *w = (DrawWindGtk *) wind->window;
if ( pango) if ( !((GrowCtx *)ctx)->bitmap_fonts)
return text_erase_pango( wind, x, y, text, len, gc_type, idx, line, font_idx, size); return text_erase_pango( wind, x, y, text, len, gc_type, idx, line, font_idx, size);
if ( font_idx > glow_eFont_Courier) if ( font_idx > glow_eFont_Courier)
...@@ -1916,7 +1914,7 @@ int GlowDrawGtk::get_text_extent( const char *text, int len, ...@@ -1916,7 +1914,7 @@ int GlowDrawGtk::get_text_extent( const char *text, int len,
{ {
int text_width, text_ascent, text_descent, text_lbearing, text_rbearing; int text_width, text_ascent, text_descent, text_lbearing, text_rbearing;
if ( pango) if ( !((GrowCtx *)ctx)->bitmap_fonts)
return get_text_extent_pango( text, len, gc_type, idx, font_idx, width, height, descent, size); return get_text_extent_pango( text, len, gc_type, idx, font_idx, width, height, descent, size);
if ( font_idx > glow_eFont_Courier) if ( font_idx > glow_eFont_Courier)
...@@ -2550,7 +2548,7 @@ int GlowDrawGtk::print( char *filename, double x0, double x1, int end) ...@@ -2550,7 +2548,7 @@ int GlowDrawGtk::print( char *filename, double x0, double x1, int end)
if ( new_file) { if ( new_file) {
ps->fp << ps->fp <<
"%!PS-Adobe-2.0 EPSF-1.2" << endl << "%!PS-Adobe-2.0 EPSF-1.2" << endl <<
"%%Creator: Proview $Id: glow_draw_gtk.cpp,v 1.17 2008-11-28 17:13:45 claes Exp $ Glow" << endl << "%%Creator: Proview $Id: glow_draw_gtk.cpp,v 1.18 2008-12-01 16:32:40 claes Exp $ Glow" << endl <<
"%%EndComments" << endl << endl; "%%EndComments" << endl << endl;
} }
else else
...@@ -3358,6 +3356,7 @@ int GlowDrawGtk::gradient_fill_polyline( GlowWind *wind, glow_sPointX *points, i ...@@ -3358,6 +3356,7 @@ int GlowDrawGtk::gradient_fill_polyline( GlowWind *wind, glow_sPointX *points, i
#define FONTSTR "Lucida Sans" #define FONTSTR "Lucida Sans"
#define FONT_SCALE 0.7 #define FONT_SCALE 0.7
#define FONT_DESCENT 0.2
static char *font_string( int font_idx, int font_type, double size) static char *font_string( int font_idx, int font_type, double size)
{ {
...@@ -3440,7 +3439,8 @@ int GlowDrawGtk::text_pango( GlowWind *wind, int x, int y, char *text, int len, ...@@ -3440,7 +3439,8 @@ int GlowDrawGtk::text_pango( GlowWind *wind, int x, int y, char *text, int len,
int width, height; int width, height;
pango_layout_get_size( layout, &width, &height); pango_layout_get_size( layout, &width, &height);
pango_renderer_draw_layout( pr, layout, PANGO_SCALE * x, PANGO_SCALE * y - height * 0.8); height *= 0.9;
pango_renderer_draw_layout( pr, layout, PANGO_SCALE * x, PANGO_SCALE * y - 0.85*height);
g_object_unref( layout); g_object_unref( layout);
g_object_unref( pctx); g_object_unref( pctx);
...@@ -3499,15 +3499,17 @@ int GlowDrawGtk::text_erase_pango( GlowWind *wind, int x, int y, char *text, int ...@@ -3499,15 +3499,17 @@ int GlowDrawGtk::text_erase_pango( GlowWind *wind, int x, int y, char *text, int
int width, height; int width, height;
pango_layout_get_size( layout, &width, &height); pango_layout_get_size( layout, &width, &height);
height *= 0.9;
if ( !w->draw_buffer_only) if ( !w->draw_buffer_only)
gdk_draw_rectangle( w->window, gdk_draw_rectangle( w->window,
get_gc( this, gc_type, idx), 1, get_gc( this, gc_type, idx), 1,
x, y - 0.8 / PANGO_SCALE * height, width / PANGO_SCALE, height / PANGO_SCALE); x, y - (1.0 - FONT_DESCENT) * height / PANGO_SCALE,
width / PANGO_SCALE, height / PANGO_SCALE);
if ( w->double_buffer_on) if ( w->double_buffer_on)
gdk_draw_rectangle( w->buffer, gdk_draw_rectangle( w->buffer,
get_gc( this, gc_type, idx), 1, get_gc( this, gc_type, idx), 1,
x, y - 0.8 / PANGO_SCALE * height, width / PANGO_SCALE, height / PANGO_SCALE); x, y - (1.0 - FONT_DESCENT) * height / PANGO_SCALE,
width / PANGO_SCALE, height / PANGO_SCALE);
g_object_unref( layout); g_object_unref( layout);
g_object_unref( pctx); g_object_unref( pctx);
...@@ -3542,7 +3544,7 @@ int GlowDrawGtk::get_text_extent_pango( const char *text, int len, ...@@ -3542,7 +3544,7 @@ int GlowDrawGtk::get_text_extent_pango( const char *text, int len,
PangoContext *pctx = gdk_pango_context_get_for_screen( screen); PangoContext *pctx = gdk_pango_context_get_for_screen( screen);
PangoLayout *layout = pango_layout_new( pctx); PangoLayout *layout = pango_layout_new( pctx);
char *textutf8 = g_convert( text, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL); char *textutf8 = g_convert( text, len, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
pango_layout_set_text( layout, textutf8, -1); pango_layout_set_text( layout, textutf8, -1);
g_free( textutf8); g_free( textutf8);
PangoFontDescription *desc = pango_font_description_from_string( font_string( font_idx, font_type, size)); PangoFontDescription *desc = pango_font_description_from_string( font_string( font_idx, font_type, size));
...@@ -3551,10 +3553,11 @@ int GlowDrawGtk::get_text_extent_pango( const char *text, int len, ...@@ -3551,10 +3553,11 @@ int GlowDrawGtk::get_text_extent_pango( const char *text, int len,
int lwidth, lheight; int lwidth, lheight;
pango_layout_get_size( layout, &lwidth, &lheight); pango_layout_get_size( layout, &lwidth, &lheight);
lheight *= 0.9;
*width = lwidth / PANGO_SCALE; *width = lwidth / PANGO_SCALE;
*height = lheight / PANGO_SCALE; *height = lheight / PANGO_SCALE;
*descent = *height * 0.2; *descent = FONT_DESCENT * lheight / PANGO_SCALE;
g_object_unref( layout); g_object_unref( layout);
g_object_unref( pctx); g_object_unref( pctx);
......
/* /*
* Proview $Id: glow.h,v 1.30 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow.h,v 1.31 2008-12-01 16:32:40 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
...@@ -986,6 +986,12 @@ typedef enum { ...@@ -986,6 +986,12 @@ typedef enum {
glow_eSaveMode_ReadConfigOnly //!< Read only configuration data. glow_eSaveMode_ReadConfigOnly //!< Read only configuration data.
} glow_eSaveMode; } glow_eSaveMode;
//! Environment.
typedef enum {
glow_eEnv_Development, //!< Editing mode.
glow_eEnv_Runtime //!< Runtime mode.
} glow_eEnv;
//! Tags used when writing objects to a .pwg fil. //! Tags used when writing objects to a .pwg fil.
/*! Every data written is preceeded by a tag to identify the data. /*! Every data written is preceeded by a tag to identify the data.
All tags for all classes are defined here. All tags for all classes are defined here.
...@@ -1307,6 +1313,7 @@ typedef enum { ...@@ -1307,6 +1313,7 @@ typedef enum {
glow_eSave_GrowCtx_dyn_attr4 = 2242, glow_eSave_GrowCtx_dyn_attr4 = 2242,
glow_eSave_GrowCtx_input_focus_mark = 2243, glow_eSave_GrowCtx_input_focus_mark = 2243,
glow_eSave_GrowCtx_userdata_cb = 2244, glow_eSave_GrowCtx_userdata_cb = 2244,
glow_eSave_GrowCtx_bitmap_fonts = 2245,
glow_eSave_GrowSubAnnot_x_right = 2300, glow_eSave_GrowSubAnnot_x_right = 2300,
glow_eSave_GrowSubAnnot_x_left = 2301, glow_eSave_GrowSubAnnot_x_left = 2301,
glow_eSave_GrowSubAnnot_y_high = 2302, glow_eSave_GrowSubAnnot_y_high = 2302,
......
/* /*
* Proview $Id: glow_growannot.cpp,v 1.13 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_growannot.cpp,v 1.14 2008-12-01 16:32:40 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
...@@ -104,8 +104,8 @@ void GrowAnnot::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi ...@@ -104,8 +104,8 @@ void GrowAnnot::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
glow_eDrawType ldraw_type; glow_eDrawType ldraw_type;
if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) { if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) {
lfont = ((GrowNode *)colornode)->text_font; lfont = ((GrowNode *)node)->text_font;
ldraw_type = ((GrowNode *)colornode)->text_type; ldraw_type = ((GrowNode *)node)->text_type;
} }
else { else {
lfont = font; lfont = font;
...@@ -246,6 +246,18 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -246,6 +246,18 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
return; return;
idx = min( idx, DRAW_TYPE_SIZE-1); idx = min( idx, DRAW_TYPE_SIZE-1);
glow_eFont lfont;
glow_eDrawType ldraw_type;
if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) {
lfont = ((GrowNode *)node)->text_font;
ldraw_type = ((GrowNode *)node)->text_type;
}
else {
lfont = font;
ldraw_type = draw_type;
}
if (!t) { if (!t) {
x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x) - w->offset_x; x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x) - w->offset_x;
y1 = int( trf.y( p.x, p.y) * w->zoom_factor_y) - w->offset_y; y1 = int( trf.y( p.x, p.y) * w->zoom_factor_y) - w->offset_y;
...@@ -270,7 +282,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -270,7 +282,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
adjustment == glow_eAdjustment_Center) adjustment == glow_eAdjustment_Center)
ctx->gdraw->get_text_extent( ((GlowNode *) node)->annotv[number], ctx->gdraw->get_text_extent( ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]), strlen(((GlowNode *) node)->annotv[number]),
draw_type, idx, font, ldraw_type, idx, lfont,
&width, &height, &descent, tsize); &width, &height, &descent, tsize);
switch ( adjustment) { switch ( adjustment) {
...@@ -304,7 +316,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -304,7 +316,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
ctx->gdraw->text_erase( w, x1, y1, ctx->gdraw->text_erase( w, x1, y1,
((GlowNode *) node)->annotv[number], ((GlowNode *) node)->annotv[number],
strlen(((GlowNode *) node)->annotv[number]), draw_type, idx, 0, font, strlen(((GlowNode *) node)->annotv[number]), ldraw_type, idx, 0, lfont,
tsize); tsize);
break; break;
} }
...@@ -315,14 +327,14 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -315,14 +327,14 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
int line_cnt = 0; int line_cnt = 0;
char *line = ((GlowNode *) node)->annotv[number]; char *line = ((GlowNode *) node)->annotv[number];
char *s; char *s;
ctx->gdraw->get_text_extent( "", 0, draw_type, idx, font, &z_width, &z_height, ctx->gdraw->get_text_extent( "", 0, ldraw_type, idx, lfont, &z_width, &z_height,
&z_descent, tsize); &z_descent, tsize);
for ( s = ((GlowNode *) node)->annotv[number]; *s; s++) { for ( s = ((GlowNode *) node)->annotv[number]; *s; s++) {
if ( *s == 10) { if ( *s == 10) {
if ( len) { if ( len) {
*s = 0; *s = 0;
ctx->gdraw->text_erase( w, x1, y1 + line_cnt * z_height, line, ctx->gdraw->text_erase( w, x1, y1 + line_cnt * z_height, line,
len, draw_type, idx, 0, font, tsize); len, ldraw_type, idx, 0, lfont, tsize);
*s = 10; *s = 10;
} }
len = 0; len = 0;
...@@ -334,7 +346,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -334,7 +346,7 @@ void GrowAnnot::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
} }
if ( len) if ( len)
ctx->gdraw->text_erase( w, x1, y1 + line_cnt * z_height, line, ctx->gdraw->text_erase( w, x1, y1 + line_cnt * z_height, line,
len, draw_type, idx, 0, font, tsize); len, ldraw_type, idx, 0, lfont, tsize);
break; break;
} }
} }
...@@ -527,10 +539,17 @@ void GrowAnnot::convert( glow_eConvert version) ...@@ -527,10 +539,17 @@ void GrowAnnot::convert( glow_eConvert version)
} }
void GrowAnnot::get_annotation_info( void *node, int *t_size, glow_eDrawType *t_drawtype, void GrowAnnot::get_annotation_info( void *node, int *t_size, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color) glow_eDrawType *t_color, glow_eFont *t_font)
{ {
*t_color = ((GrowCtx *)ctx)->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight, *t_color = ((GrowCtx *)ctx)->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight,
0, (GrowNode *)node, 2); 0, (GrowNode *)node, 2);
*t_size = text_size; *t_size = text_size;
*t_drawtype = draw_type; if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) {
*t_font = ((GrowNode *)node)->text_font;
*t_drawtype = ((GrowNode *)node)->text_type;
}
else {
*t_drawtype = draw_type;
*t_font = font;
}
} }
/* /*
* Proview $Id: glow_growannot.h,v 1.5 2007-01-04 07:57:38 claes Exp $ * Proview $Id: glow_growannot.h,v 1.6 2008-12-01 16:32:40 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
...@@ -173,7 +173,7 @@ class GrowAnnot : public GlowAnnot { ...@@ -173,7 +173,7 @@ class GrowAnnot : public GlowAnnot {
\param t_color Annotation text color. \param t_color Annotation text color.
*/ */
void get_annotation_info( void *node, int *t_size, glow_eDrawType *t_drawtype, void get_annotation_info( void *node, int *t_size, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color); glow_eDrawType *t_color, glow_eFont *font);
}; };
/*@}*/ /*@}*/
......
/* /*
* Proview $Id: glow_growapi.cpp,v 1.41 2008-11-20 10:30:44 claes Exp $ * Proview $Id: glow_growapi.cpp,v 1.42 2008-12-01 16:32:40 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
...@@ -693,6 +693,8 @@ void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr, ...@@ -693,6 +693,8 @@ void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
} }
if ( mask & grow_eAttr_initial_position) if ( mask & grow_eAttr_initial_position)
ctx->initial_position = attr->initial_position; ctx->initial_position = attr->initial_position;
if ( mask & grow_eAttr_environment)
ctx->environment = attr->environment;
} }
void grow_GetAttributes( grow_tCtx ctx, grow_sAttributes *attr, void grow_GetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
...@@ -1104,13 +1106,14 @@ void grow_CreateGrowMenu( grow_tCtx ctx, const char *name, glow_sMenuInfo *info, ...@@ -1104,13 +1106,14 @@ void grow_CreateGrowMenu( grow_tCtx ctx, const char *name, glow_sMenuInfo *info,
glow_eDrawType draw_type, int line_width, glow_eDrawType draw_type, int line_width,
int fill_rect, int border, glow_eDrawType fill_draw_type, int fill_rect, int border, glow_eDrawType fill_draw_type,
int text_size, glow_eDrawType text_drawtype, int text_size, glow_eDrawType text_drawtype,
glow_eDrawType text_color, glow_eDrawType disabled_text_color, glow_eDrawType text_color,
glow_eDrawType disabled_text_color, glow_eFont text_font,
grow_tObject parent, grow_tObject *menu) grow_tObject parent, grow_tObject *menu)
{ {
GrowMenu *r1; GrowMenu *r1;
r1 = new GrowMenu( ctx, name, info, x, y, min_width, draw_type, line_width, r1 = new GrowMenu( ctx, name, info, x, y, min_width, draw_type, line_width,
fill_rect, border, fill_draw_type, text_size, text_drawtype, fill_rect, border, fill_draw_type, text_size, text_drawtype,
text_color, disabled_text_color, (GlowArrayElem *)parent); text_color, disabled_text_color, text_font, (GlowArrayElem *)parent);
ctx->insert( r1); ctx->insert( r1);
*menu = (grow_tObject) r1; *menu = (grow_tObject) r1;
} }
...@@ -2795,6 +2798,11 @@ int grow_GetGraphAttrInfo( grow_tCtx ctx, grow_sAttrInfo **info, ...@@ -2795,6 +2798,11 @@ int grow_GetGraphAttrInfo( grow_tCtx ctx, grow_sAttrInfo **info,
attrinfo[i].type = glow_eType_Boolean; attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( ctx->translate_on); attrinfo[i++].size = sizeof( ctx->translate_on);
strcpy( attrinfo[i].name, "BitmapFonts");
attrinfo[i].value_p = &ctx->bitmap_fonts;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( ctx->bitmap_fonts);
attrinfo[i].info_type = grow_eInfoType_End; attrinfo[i].info_type = grow_eInfoType_End;
*attr_cnt = i; *attr_cnt = i;
*info = attrinfo; *info = attrinfo;
...@@ -4479,16 +4487,19 @@ void grow_SetXYCurveData( grow_tObject object, double *y_data, double *x_data, i ...@@ -4479,16 +4487,19 @@ void grow_SetXYCurveData( grow_tObject object, double *y_data, double *x_data, i
} }
int grow_GetObjectAnnotInfo( grow_tObject object, int num, int *text_size, glow_eDrawType *text_drawtype, int grow_GetObjectAnnotInfo( grow_tObject object, int num, int *text_size, glow_eDrawType *text_drawtype,
glow_eDrawType *text_color, glow_eDrawType *bg_color, double *scale) glow_eDrawType *text_color, glow_eDrawType *bg_color, double *scale,
glow_eFont *font)
{ {
return ((GrowNode *)object)->get_annotation_info( num, text_size, text_drawtype, text_color, bg_color, return ((GrowNode *)object)->get_annotation_info( num, text_size, text_drawtype, text_color, bg_color,
scale); scale, font);
} }
void grow_GetMenuChar( grow_tObject menu, int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype, void grow_GetMenuChar( grow_tObject menu, int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color, glow_eDrawType *t_color_disabled) glow_eDrawType *t_color, glow_eDrawType *t_color_disabled,
glow_eFont *t_font)
{ {
((GrowMenu *)menu)->get_menu_char( t_size, fill_color, t_drawtype, t_color, t_color_disabled); ((GrowMenu *)menu)->get_menu_char( t_size, fill_color, t_drawtype, t_color, t_color_disabled,
t_font);
} }
void grow_MenuShiftCurrentItem( grow_tObject menu, int shift) void grow_MenuShiftCurrentItem( grow_tObject menu, int shift)
......
/* /*
* Proview $Id: glow_growapi.h,v 1.35 2008-11-20 10:30:44 claes Exp $ * Proview $Id: glow_growapi.h,v 1.36 2008-12-01 16:32:40 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
...@@ -100,6 +100,7 @@ extern "C" { ...@@ -100,6 +100,7 @@ extern "C" {
int double_buffer_on; int double_buffer_on;
glow_eHotMode hot_mode; glow_eHotMode hot_mode;
glow_eDirection initial_position; glow_eDirection initial_position;
glow_eEnv environment;
} grow_sAttributes; } grow_sAttributes;
typedef enum { typedef enum {
...@@ -123,7 +124,8 @@ extern "C" { ...@@ -123,7 +124,8 @@ extern "C" {
grow_eAttr_enable_bg_pixmap = 1 << 17, grow_eAttr_enable_bg_pixmap = 1 << 17,
grow_eAttr_double_buffer_on = 1 << 18, grow_eAttr_double_buffer_on = 1 << 18,
grow_eAttr_hot_mode = 1 << 19, grow_eAttr_hot_mode = 1 << 19,
grow_eAttr_initial_position = 1 << 20 grow_eAttr_initial_position = 1 << 20,
grow_eAttr_environment = 1 << 21
} grow_eAttribute; } grow_eAttribute;
...@@ -1228,7 +1230,7 @@ extern "C" { ...@@ -1228,7 +1230,7 @@ extern "C" {
int fill_rect, int border, glow_eDrawType fill_draw_type, int fill_rect, int border, glow_eDrawType fill_draw_type,
int text_size, glow_eDrawType text_drawtype, int text_size, glow_eDrawType text_drawtype,
glow_eDrawType text_color, glow_eDrawType disabled_text_color, glow_eDrawType text_color, glow_eDrawType disabled_text_color,
grow_tObject parent, grow_tObject *menu); glow_eFont text_font, grow_tObject parent, grow_tObject *menu);
//! Save subgraph to file. //! Save subgraph to file.
/*! /*!
...@@ -2920,7 +2922,8 @@ extern "C" { ...@@ -2920,7 +2922,8 @@ extern "C" {
\return 0 if annotation doesn't exist, else 1. \return 0 if annotation doesn't exist, else 1.
*/ */
int grow_GetObjectAnnotInfo( grow_tObject object, int num, int *text_size, glow_eDrawType *text_drawtype, int grow_GetObjectAnnotInfo( grow_tObject object, int num, int *text_size, glow_eDrawType *text_drawtype,
glow_eDrawType *text_color, glow_eDrawType *bg_color, double *scale); glow_eDrawType *text_color, glow_eDrawType *bg_color, double *scale,
glow_eFont *text_font);
//! Get color, textsize and text colors for a menu. //! Get color, textsize and text colors for a menu.
/*! /*!
...@@ -2932,7 +2935,8 @@ extern "C" { ...@@ -2932,7 +2935,8 @@ extern "C" {
\param t_color_disabled Text color for disabled button. \param t_color_disabled Text color for disabled button.
*/ */
void grow_GetMenuChar( grow_tObject menu, int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype, void grow_GetMenuChar( grow_tObject menu, int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color, glow_eDrawType *t_color_disabled); glow_eDrawType *t_color, glow_eDrawType *t_color_disabled,
glow_eFont *t_font);
void grow_MenuShiftCurrentItem( grow_tObject menu, int shift); void grow_MenuShiftCurrentItem( grow_tObject menu, int shift);
......
/* /*
* Proview $Id: glow_growctx.cpp,v 1.35 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_growctx.cpp,v 1.36 2008-12-01 16:32:40 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
...@@ -1915,6 +1915,7 @@ void GrowCtx::save_grow( ofstream& fp, glow_eSaveMode mode) ...@@ -1915,6 +1915,7 @@ 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_mb3_action) << FSPACE << int(mb3_action) << endl;
fp << int(glow_eSave_GrowCtx_translate_on) << FSPACE << translate_on << 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; fp << int(glow_eSave_GrowCtx_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
fp << int(glow_eSave_GrowCtx_bitmap_fonts) << FSPACE << bitmap_fonts << endl;
if ( user_data && userdata_save_callback) { if ( user_data && userdata_save_callback) {
fp << int(glow_eSave_GrowCtx_userdata_cb) << endl; fp << int(glow_eSave_GrowCtx_userdata_cb) << endl;
(userdata_save_callback)(&fp, this, glow_eUserdataCbType_Ctx); (userdata_save_callback)(&fp, this, glow_eUserdataCbType_Ctx);
...@@ -2059,6 +2060,7 @@ void GrowCtx::open_grow( ifstream& fp) ...@@ -2059,6 +2060,7 @@ void GrowCtx::open_grow( ifstream& fp)
if ( userdata_open_callback) if ( userdata_open_callback)
(userdata_open_callback)(&fp, this, glow_eUserdataCbType_Ctx); (userdata_open_callback)(&fp, this, glow_eUserdataCbType_Ctx);
break; break;
case glow_eSave_GrowCtx_bitmap_fonts: fp >> bitmap_fonts; break;
default: default:
cout << "GrowCtx:open syntax error" << endl; cout << "GrowCtx:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy)); fp.getline( dummy, sizeof(dummy));
...@@ -2071,7 +2073,8 @@ void GrowCtx::open_grow( ifstream& fp) ...@@ -2071,7 +2073,8 @@ void GrowCtx::open_grow( ifstream& fp)
mw.set_double_buffer_on(1); mw.set_double_buffer_on(1);
gdraw->create_buffer( &mw); gdraw->create_buffer( &mw);
} }
else if ( !double_buffered && mw.window && mw.double_buffer_on()) { else if ( !double_buffered && mw.window && mw.double_buffer_on() &&
environment != glow_eEnv_Development) {
mw.set_double_buffer_on(0); mw.set_double_buffer_on(0);
gdraw->delete_buffer( &mw); gdraw->delete_buffer( &mw);
} }
...@@ -2927,6 +2930,8 @@ void GrowCtx::set_select_textfont( glow_eFont font) ...@@ -2927,6 +2930,8 @@ void GrowCtx::set_select_textfont( glow_eFont font)
((GrowTable *)a_sel[i])->set_textfont( font); ((GrowTable *)a_sel[i])->set_textfont( font);
else if ( a_sel[i]->type() == glow_eObjectType_GrowNode) else if ( a_sel[i]->type() == glow_eObjectType_GrowNode)
((GrowNode *)a_sel[i])->set_textfont( font); ((GrowNode *)a_sel[i])->set_textfont( font);
else if ( a_sel[i]->type() == glow_eObjectType_GrowGroup)
((GrowGroup *)a_sel[i])->set_textfont( font);
} }
} }
......
/* /*
* Proview $Id: glow_growctx.h,v 1.20 2008-11-20 10:30:44 claes Exp $ * Proview $Id: glow_growctx.h,v 1.21 2008-12-01 16:32:40 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
...@@ -81,7 +81,8 @@ class GrowCtx : public GlowCtx { ...@@ -81,7 +81,8 @@ class GrowCtx : public GlowCtx {
is_javaapplication(0), cycle(glow_eCycle_Slow), is_javaapplication(0), cycle(glow_eCycle_Slow),
mb3_action(glow_eMB3Action_Close), scale_equal(0), translate_on(0), mb3_action(glow_eMB3Action_Close), scale_equal(0), translate_on(0),
input_focus_mark(glow_eInputFocusMark_Relief), background_disabled(0), input_focus_mark(glow_eInputFocusMark_Relief), background_disabled(0),
redraw_callback(0), redraw_data(0), has_subwindows(-1) redraw_callback(0), redraw_data(0), has_subwindows(-1), bitmap_fonts(0),
environment(glow_eEnv_Runtime)
{ ctx_type = glow_eCtxType_Grow; { ctx_type = glow_eCtxType_Grow;
strcpy( name, ""); strcpy( name, "");
strcpy( java_name, ""); strcpy( java_name, "");
...@@ -907,6 +908,8 @@ class GrowCtx : public GlowCtx { ...@@ -907,6 +908,8 @@ class GrowCtx : public GlowCtx {
void *redraw_data; //!< Data for redraw callback. void *redraw_data; //!< Data for redraw callback.
int has_subwindows; //!< Graph contains subwindow objects (GrowWindow or GrowFolder) int has_subwindows; //!< Graph contains subwindow objects (GrowWindow or GrowFolder)
char owner[256]; //!< Owner, used by application char owner[256]; //!< Owner, used by application
int bitmap_fonts; //!< Use bitmap fonts
glow_eEnv environment; //!< Environment Development or Runtime.
}; };
void grow_auto_scrolling( GrowCtx *ctx); void grow_auto_scrolling( GrowCtx *ctx);
......
/* /*
* Proview $Id: glow_growmenu.cpp,v 1.16 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_growmenu.cpp,v 1.17 2008-12-01 16:32:40 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
...@@ -35,16 +35,18 @@ GrowMenu::GrowMenu( GrowCtx *glow_ctx, const char *name, glow_sMenuInfo *menu_in ...@@ -35,16 +35,18 @@ GrowMenu::GrowMenu( GrowCtx *glow_ctx, const char *name, glow_sMenuInfo *menu_in
int fill_rect, int display_border, int fill_rect, int display_border,
glow_eDrawType fill_d_type, int t_size, glow_eDrawType fill_d_type, int t_size,
glow_eDrawType t_drawtype, glow_eDrawType t_color, glow_eDrawType t_drawtype, glow_eDrawType t_color,
glow_eDrawType t_color_disabled, GlowArrayElem *parent, int nodraw) : glow_eDrawType t_color_disabled, glow_eFont t_font,
GlowArrayElem *parent, int nodraw) :
GrowRect(glow_ctx,name,x,y,10,10,border_d_type,line_w,0, GrowRect(glow_ctx,name,x,y,10,10,border_d_type,line_w,0,
glow_mDisplayLevel_1,fill_rect,display_border,0,fill_d_type,1), glow_mDisplayLevel_1,fill_rect,display_border,0,fill_d_type,1),
info(*menu_info), text_size(t_size), text_drawtype(t_drawtype), info(*menu_info), text_size(t_size), text_drawtype(t_drawtype),
text_color(t_color), text_color_disabled(t_color_disabled), item_cnt(0), text_color(t_color), text_color_disabled(t_color_disabled),
item_height(0), current_item(-1), new_item(0), old_item(-1), parent_menu(parent), item_cnt(0), item_height(0), current_item(-1), new_item(0), old_item(-1),
min_width(min_w), input_focus(0) parent_menu(parent), min_width(min_w), input_focus(0), font(t_font)
{ {
if ( !nodraw) if ( !nodraw)
draw( &ctx->mw, (GlowTransform *)NULL, highlight, hot, NULL, NULL); draw( &ctx->mw, (GlowTransform *)NULL, highlight, hot, NULL, NULL);
} }
GrowMenu::~GrowMenu() GrowMenu::~GrowMenu()
...@@ -163,11 +165,11 @@ void GrowMenu::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void ...@@ -163,11 +165,11 @@ void GrowMenu::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void
for ( i = 0; i < (int) (sizeof(info.item)/sizeof(info.item[0])); i++) { for ( i = 0; i < (int) (sizeof(info.item)/sizeof(info.item[0])); i++) {
if ( info.item[i].occupied) { if ( info.item[i].occupied) {
ctx->gdraw->get_text_extent( info.item[i].text, strlen(info.item[i].text), text_drawtype, ctx->gdraw->get_text_extent( info.item[i].text, strlen(info.item[i].text), text_drawtype,
max( 0, text_idx), glow_eFont_Helvetica, &z_width, &z_height, max( 0, text_idx), font, &z_width, &z_height,
&z_descent, tsize); &z_descent, tsize);
if ( z_width > max_z_width) if ( z_width > max_z_width)
max_z_width = z_width; max_z_width = z_width;
tot_z_height += int( 1.3 * z_height); tot_z_height += int( 1.6 * z_height);
if ( info.item[i].type == glow_eMenuItem_PulldownMenu) if ( info.item[i].type == glow_eMenuItem_PulldownMenu)
pulldown_found = 1; pulldown_found = 1;
item_cnt++; item_cnt++;
...@@ -218,10 +220,10 @@ void GrowMenu::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void ...@@ -218,10 +220,10 @@ void GrowMenu::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void
} }
if ( info.item[i].type == glow_eMenuItem_ButtonDisabled) if ( info.item[i].type == glow_eMenuItem_ButtonDisabled)
ctx->gdraw->text( w, x_text, y_text, info.item[i].text, strlen(info.item[i].text), text_drawtype, ctx->gdraw->text( w, x_text, y_text, info.item[i].text, strlen(info.item[i].text), text_drawtype,
text_color_disabled, text_idx, highlight, 0, glow_eFont_Helvetica, tsize); text_color_disabled, text_idx, highlight, 0, font, tsize);
else else
ctx->gdraw->text( w, x_text, y_text, info.item[i].text, strlen(info.item[i].text), text_drawtype, ctx->gdraw->text( w, x_text, y_text, info.item[i].text, strlen(info.item[i].text), text_drawtype,
text_color, text_idx, highlight, 0, glow_eFont_Helvetica, tsize); text_color, text_idx, highlight, 0, font, tsize);
if ( info.item[i].type == glow_eMenuItem_PulldownMenu) { if ( info.item[i].type == glow_eMenuItem_PulldownMenu) {
// Draw arrow // Draw arrow
glow_sPointX p[4]; glow_sPointX p[4];
...@@ -469,13 +471,15 @@ void GrowMenu::delete_menu_child( GlowArrayElem *parent) { ...@@ -469,13 +471,15 @@ void GrowMenu::delete_menu_child( GlowArrayElem *parent) {
} }
void GrowMenu::get_menu_char( int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype, void GrowMenu::get_menu_char( int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color, glow_eDrawType *t_color_disabled) glow_eDrawType *t_color, glow_eDrawType *t_color_disabled,
glow_eFont *t_font)
{ {
*t_size = text_size; *t_size = text_size;
*fill_color = fill_drawtype; *fill_color = fill_drawtype;
*t_drawtype = text_drawtype; *t_drawtype = text_drawtype;
*t_color = text_color; *t_color = text_color;
*t_color_disabled = text_color_disabled; *t_color_disabled = text_color_disabled;
*t_font = font;
} }
void GrowMenu::shift_current_item( int shift) void GrowMenu::shift_current_item( int shift)
......
/* /*
* Proview $Id: glow_growmenu.h,v 1.5 2008-10-31 12:51:35 claes Exp $ * Proview $Id: glow_growmenu.h,v 1.6 2008-12-01 16:32:40 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 @@ class GrowMenu : public GrowRect { ...@@ -54,6 +54,7 @@ class GrowMenu : public GrowRect {
\param t_drawtype Drawtype for text. \param t_drawtype Drawtype for text.
\param t_color Text color. \param t_color Text color.
\param t_color_disabled Text color for disabled item. \param t_color_disabled Text color for disabled item.
\param t_font Text font.
\param parent Parent menu. \param parent Parent menu.
\param nodraw Don't draw the object now. \param nodraw Don't draw the object now.
*/ */
...@@ -66,6 +67,7 @@ class GrowMenu : public GrowRect { ...@@ -66,6 +67,7 @@ class GrowMenu : public GrowRect {
glow_eDrawType t_drawtype = glow_eDrawType_TextHelvetica, glow_eDrawType t_drawtype = glow_eDrawType_TextHelvetica,
glow_eDrawType t_color = glow_eDrawType_Line, glow_eDrawType t_color = glow_eDrawType_Line,
glow_eDrawType t_color_disabled = glow_eDrawType_Line, glow_eDrawType t_color_disabled = glow_eDrawType_Line,
glow_eFont t_font = glow_eFont_Helvetica,
GlowArrayElem *parent = 0, int nodraw = 0); GlowArrayElem *parent = 0, int nodraw = 0);
//! Destructor //! Destructor
...@@ -119,6 +121,7 @@ class GrowMenu : public GrowRect { ...@@ -119,6 +121,7 @@ class GrowMenu : public GrowRect {
GlowArrayElem *parent_menu; //!< Parent menu. GlowArrayElem *parent_menu; //!< Parent menu.
double min_width; //!< Minimum width of menu. double min_width; //!< Minimum width of menu.
int input_focus; //!< This menu has input focus. int input_focus; //!< This menu has input focus.
glow_eFont font; //!< Text font.
//! Draw the object. //! Draw the object.
/*! /*!
...@@ -164,7 +167,8 @@ class GrowMenu : public GrowRect { ...@@ -164,7 +167,8 @@ class GrowMenu : public GrowRect {
\param t_color_disabled Text color for disabled button. \param t_color_disabled Text color for disabled button.
*/ */
void get_menu_char( int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype, void get_menu_char( int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color, glow_eDrawType *t_color_disabled); glow_eDrawType *t_color, glow_eDrawType *t_color_disabled,
glow_eFont *t_font);
void shift_current_item( int shift); void shift_current_item( int shift);
int get_current_item( int *item); int get_current_item( int *item);
......
/* /*
* Proview $Id: glow_grownode.cpp,v 1.18 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_grownode.cpp,v 1.19 2008-12-01 16:32:40 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
...@@ -2037,7 +2037,7 @@ void GrowNode::annot_input_event( glow_eEvent event, int keycode) ...@@ -2037,7 +2037,7 @@ void GrowNode::annot_input_event( glow_eEvent event, int keycode)
} }
int GrowNode::get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawtype, glow_eDrawType *t_color, int GrowNode::get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawtype, glow_eDrawType *t_color,
glow_eDrawType *bg_color, double *scale) glow_eDrawType *bg_color, double *scale, glow_eFont *t_font)
{ {
int sts; int sts;
...@@ -2045,7 +2045,7 @@ int GrowNode::get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawt ...@@ -2045,7 +2045,7 @@ int GrowNode::get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawt
if ( EVEN(sts)) if ( EVEN(sts))
*bg_color = glow_eDrawType_No; *bg_color = glow_eDrawType_No;
sts = nc->get_annotation_info( (void*)this, num, t_size, t_drawtype, t_color); sts = nc->get_annotation_info( (void*)this, num, t_size, t_drawtype, t_color, t_font);
*scale = trf.vertical_scale(0); *scale = trf.vertical_scale(0);
return sts; return sts;
} }
......
/* /*
* Proview $Id: glow_grownode.h,v 1.15 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_grownode.h,v 1.16 2008-12-01 16:32:40 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
...@@ -903,10 +903,11 @@ class GrowNode : public GlowNode { ...@@ -903,10 +903,11 @@ class GrowNode : public GlowNode {
\param t_color Annotation text color. \param t_color Annotation text color.
\param bg_color Annotation background color. \param bg_color Annotation background color.
\param scale Annotation scale. \param scale Annotation scale.
\param font Annotation font.
\return 0 if annotation doesn't exist, else 1. \return 0 if annotation doesn't exist, else 1.
*/ */
int get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawtype, glow_eDrawType *t_color, int get_annotation_info( int num, int *t_size, glow_eDrawType *t_drawtype, glow_eDrawType *t_color,
glow_eDrawType *bg_color, double *scale); glow_eDrawType *bg_color, double *scale, glow_eFont *font);
int get_java_name( char *name) { return nc->get_java_name( name);} int get_java_name( char *name) { return nc->get_java_name( name);}
void set_textbold( int bold); void set_textbold( int bold);
void set_textfont( glow_eFont textfont); void set_textfont( glow_eFont textfont);
......
/* /*
* Proview $Id: glow_growtext.cpp,v 1.11 2008-11-28 17:13:45 claes Exp $ * Proview $Id: glow_growtext.cpp,v 1.12 2008-12-01 16:32:40 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
...@@ -651,6 +651,18 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi ...@@ -651,6 +651,18 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
highl = 0; highl = 0;
} }
glow_eFont lfont;
glow_eDrawType ldraw_type;
if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) {
lfont = ((GrowNode *)node)->text_font;
ldraw_type = ((GrowNode *)node)->text_type;
}
else {
lfont = font;
ldraw_type = draw_type;
}
if (!t) { if (!t) {
x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x + 0.5) - w->offset_x; x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x + 0.5) - w->offset_x;
y1 = int( trf.y( p.x, p.y) * w->zoom_factor_y + 0.5) - w->offset_y; y1 = int( trf.y( p.x, p.y) * w->zoom_factor_y + 0.5) - w->offset_y;
...@@ -662,13 +674,13 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi ...@@ -662,13 +674,13 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( strcmp( text, "")) { if ( strcmp( text, "")) {
if ( highl) { if ( highl) {
ctx->gdraw->get_text_extent( text, strlen(text), draw_type, max( 0, idx), font, ctx->gdraw->get_text_extent( text, strlen(text), ldraw_type, max( 0, idx), lfont,
&z_width, &z_height, &z_descent, tsize); &z_width, &z_height, &z_descent, tsize);
ctx->gdraw->rect( w, x1, y1 - (z_height-z_descent), z_width, z_height, ctx->gdraw->rect( w, x1, y1 - (z_height-z_descent), z_width, z_height,
glow_eDrawType_FillHighlight, max( 1, min( idx + hot, 2)), 0); glow_eDrawType_FillHighlight, max( 1, min( idx + hot, 2)), 0);
} }
else if ( hot && !node) { else if ( hot && !node) {
ctx->gdraw->get_text_extent( text, strlen(text), draw_type, max( 0, idx), font, ctx->gdraw->get_text_extent( text, strlen(text), ldraw_type, max( 0, idx), lfont,
&z_width, &z_height, &z_descent, tsize); &z_width, &z_height, &z_descent, tsize);
ctx->gdraw->rect( w, x1, y1 - (z_height-z_descent), z_width, z_height, ctx->gdraw->rect( w, x1, y1 - (z_height-z_descent), z_width, z_height,
glow_eDrawType_LineGray, max( min(idx,2), 1), 0); glow_eDrawType_LineGray, max( min(idx,2), 1), 0);
...@@ -676,8 +688,8 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi ...@@ -676,8 +688,8 @@ void GrowText::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( idx >= 0) { if ( idx >= 0) {
glow_eDrawType color = ctx->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight, glow_eDrawType color = ctx->get_drawtype( color_drawtype, glow_eDrawType_LineHighlight,
highlight, (GrowNode *)colornode, 2); highlight, (GrowNode *)colornode, 2);
ctx->gdraw->text( w, x1, y1, text, strlen(text), draw_type, color, idx, highlight, ctx->gdraw->text( w, x1, y1, text, strlen(text), ldraw_type, color, idx, highlight,
0, font, tsize); 0, lfont, tsize);
} }
} }
else { else {
...@@ -707,6 +719,18 @@ void GrowText::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -707,6 +719,18 @@ void GrowText::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
if ( node) if ( node)
highl = ((GrowNode *)node)->highlight; highl = ((GrowNode *)node)->highlight;
glow_eFont lfont;
glow_eDrawType ldraw_type;
if ( node && ((GrowNode *)node)->text_font != glow_eFont_No) {
lfont = ((GrowNode *)node)->text_font;
ldraw_type = ((GrowNode *)node)->text_type;
}
else {
lfont = font;
ldraw_type = draw_type;
}
if (!t) if (!t)
{ {
x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x + 0.5) - w->offset_x; x1 = int( trf.x( p.x, p.y) * w->zoom_factor_x + 0.5) - w->offset_x;
...@@ -721,19 +745,19 @@ void GrowText::erase( GlowWind *w, GlowTransform *t, int hot, void *node) ...@@ -721,19 +745,19 @@ void GrowText::erase( GlowWind *w, GlowTransform *t, int hot, void *node)
// w->set_draw_buffer_only(); // w->set_draw_buffer_only();
if ( strcmp( text, "")) { if ( strcmp( text, "")) {
if ( highl) { if ( highl) {
ctx->gdraw->get_text_extent( text, strlen(text), draw_type, max( 0, idx), ctx->gdraw->get_text_extent( text, strlen(text), ldraw_type, max( 0, idx),
font, &z_width, &z_height, &z_descent, tsize); lfont, &z_width, &z_height, &z_descent, tsize);
ctx->gdraw->rect_erase( w, x1, y1 - (z_height-z_descent), z_width, z_height, ctx->gdraw->rect_erase( w, x1, y1 - (z_height-z_descent), z_width, z_height,
max( 1, min( idx + hot, 2))); max( 1, min( idx + hot, 2)));
} }
else if ( hot && !node) { else if ( hot && !node) {
ctx->gdraw->get_text_extent( text, strlen(text), draw_type, max( 0, idx), ctx->gdraw->get_text_extent( text, strlen(text), ldraw_type, max( 0, idx),
font, &z_width, &z_height, &z_descent, tsize); lfont, &z_width, &z_height, &z_descent, tsize);
ctx->gdraw->rect_erase( w, x1, y1 - (z_height-z_descent), z_width, z_height, ctx->gdraw->rect_erase( w, x1, y1 - (z_height-z_descent), z_width, z_height,
max (1, min(idx,2))); max (1, min(idx,2)));
} }
if ( idx >= 0) if ( idx >= 0)
ctx->gdraw->text_erase( w, x1, y1, text, strlen(text), draw_type, idx, 0, font, tsize); ctx->gdraw->text_erase( w, x1, y1, text, strlen(text), ldraw_type, idx, 0, lfont, tsize);
} }
else else
{ {
......
/* /*
* Proview $Id: glow_nodeclass.cpp,v 1.8 2008-10-31 12:51:36 claes Exp $ * Proview $Id: glow_nodeclass.cpp,v 1.9 2008-12-01 16:32:40 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
...@@ -719,14 +719,14 @@ int GlowNodeClass::find_nc( GlowArrayElem *nodeclass) ...@@ -719,14 +719,14 @@ int GlowNodeClass::find_nc( GlowArrayElem *nodeclass)
} }
int GlowNodeClass::get_annotation_info( void *node, int num, int *t_size, glow_eDrawType *t_drawtype, int GlowNodeClass::get_annotation_info( void *node, int num, int *t_size, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color) glow_eDrawType *t_color, glow_eFont *t_font)
{ {
int i; int i;
for ( i = 0; i < a.a_size; i++) { for ( i = 0; i < a.a_size; i++) {
if ( a.a[i]->type() == glow_eObjectType_GrowAnnot && if ( a.a[i]->type() == glow_eObjectType_GrowAnnot &&
((GrowAnnot *)a.a[i])->number == num) { ((GrowAnnot *)a.a[i])->number == num) {
((GrowAnnot *)a.a[i])->get_annotation_info( node, t_size, t_drawtype, t_color); ((GrowAnnot *)a.a[i])->get_annotation_info( node, t_size, t_drawtype, t_color, t_font);
return 1; return 1;
} }
} }
......
/* /*
* Proview $Id: glow_nodeclass.h,v 1.7 2008-10-31 12:51:36 claes Exp $ * Proview $Id: glow_nodeclass.h,v 1.8 2008-12-01 16:32:40 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
...@@ -349,7 +349,7 @@ class GlowNodeClass : public GlowArrayElem { ...@@ -349,7 +349,7 @@ class GlowNodeClass : public GlowArrayElem {
\return 0 if annotation doesn't exist, else 1. \return 0 if annotation doesn't exist, else 1.
*/ */
int get_annotation_info( void *node, int num, int *t_size, glow_eDrawType *t_drawtype, int get_annotation_info( void *node, int num, int *t_size, glow_eDrawType *t_drawtype,
glow_eDrawType *t_color); glow_eDrawType *t_color, glow_eFont *t_font);
//! Set user data. //! Set 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