Commit b75b2a03 authored by claes's avatar claes

Java export of table objects

parent d252cd8a
......@@ -2011,6 +2011,90 @@ void GlowExportJBean::folder( double x1, double y1, double x2, double y2,
}
}
void GlowExportJBean::table( double x1, double y1, double x2, double y2,
glow_eDrawType fill_drawtype, int fill,
int rows, int columns, int header_row, int header_column,
int text_idx, glow_eDrawType text_drawtype,
double row_height, double *column_width, char *header_text,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp)
{
double dim_x0, dim_x1, dim_y0, dim_y1;
char var_name[40];
char class_name[] = "GeTable";
int text_size;
char bold_str[20];
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", node_cnt);
switch ( pass)
{
case glow_eExportPass_Shape:
break;
case glow_eExportPass_Declare:
{
fp <<
" " << class_name << " " << var_name << ";" << endl;
break;
}
case glow_eExportPass_Attributes:
{
switch ( text_idx)
{
case 0: text_size = 8; break;
case 1: text_size = 10; break;
case 2: text_size = 12; break;
case 3: text_size = 14; break;
case 4: text_size = 14; break;
case 5: text_size = 18; break;
case 6: text_size = 18; break;
case 7: text_size = 18; break;
default: text_size = 24;
}
if ( text_drawtype == glow_eDrawType_TextHelveticaBold)
strcpy(bold_str, "BOLD");
else
strcpy(bold_str, "PLAIN");
((GrowCtx *)ctx)->measure_javabean( &dim_x1, &dim_x0, &dim_y1, &dim_y0);
fp <<
" " << var_name << " = new " << class_name << "(session, " <<
rows << "," << columns << "," << header_row << "," << header_column << ");" << endl <<
" " << var_name << ".setRowHeight(" << int(row_height) << ");" << endl;
char *text_p = header_text;
for ( int i = 0; i < columns; i++) {
fp <<
" " << var_name << ".setHeaderText(" << i << ",\"" << text_p << "\");" << endl <<
" " << var_name << ".setColumnWidth(" << i << "," << int(column_width[i]) << ");" << endl;
text_p += 40;
}
if ( fill_drawtype != glow_eDrawType_No)
fp <<
" " << var_name << ".setFillColor(" << (int)fill_drawtype << ");" << endl;
fp <<
" " << var_name << ".setFont(new Font(\"Helvetica\", Font." << bold_str
<< ", " << text_size << "));" << endl;
fp <<
" " << var_name << ".setBounds(new Rectangle(" <<
(int)(x1 - dim_x0 /* - glow_cJBean_Offset) */) << "," <<
(int)(y1 - dim_y0 /* - glow_cJBean_Offset) */) << "," <<
(int)(x2 - x1 + 2 * glow_cJBean_Offset) << "," <<
(int)(y2 - y1 + 2 * glow_cJBean_Offset) << "));" << endl;
fp <<
" localPanel.add(" << var_name << ", null);" << endl;
break;
}
case glow_eExportPass_Draw:
break;
default:
;
}
}
void GlowExportJBean::slider( double x1, double y1, double x2, double y2,
char *class_name,
glow_eDrawType border_drawtype,
......
......@@ -131,6 +131,12 @@ class GlowExportJBean {
char *folder_file_names, char *folder_text,
int *folder_v_scrollbar, int *folder_h_scrollbar,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void table( double x1, double y1, double x2, double y2,
glow_eDrawType fill_drawtype, int fill,
int rows, int columns, int header_row, int header_column,
int text_idx, glow_eDrawType text_drawtype,
double row_height, double *column_width, char *header_text,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void slider( double x1, double y1, double x2, double y2,
char *class_name,
glow_eDrawType border_drawtype,
......
......@@ -781,6 +781,7 @@ void GrowTable::export_javabean( GlowTransform *t, void *node,
glow_eExportPass pass, int *shape_cnt, int node_cnt, int in_nc, ofstream &fp)
{
double x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
double cwidth[TABLE_MAX_COL];
if (!t)
{
......@@ -802,11 +803,15 @@ void GrowTable::export_javabean( GlowTransform *t, void *node,
ll_y = min( y1, y2);
ur_y = max( y1, y2);
// ((GrowCtx *)ctx)->export_jbean->bar( ll_x, ll_y, ur_x, ur_y,
// draw_type, fill_drawtype, bar_drawtype, bar_bordercolor, fill,
// border, min_value, max_value, bar_borderwidth,
// line_width, rotation,
// pass, shape_cnt, node_cnt, fp);
for ( int i = 0; i < columns; i++)
cwidth[i] = column_width[i] * ctx->zoom_factor_x;
((GrowCtx *)ctx)->export_jbean->table( ll_x, ll_y, ur_x, ur_y,
fill_drawtype, fill, rows, columns, header_row,
header_column, text_size, text_drawtype,
row_height * ctx->zoom_factor_y, (double *)cwidth,
(char *)header_text,
pass, shape_cnt, node_cnt, fp);
}
void GrowTable::convert( glow_eConvert version)
......
......@@ -143,7 +143,7 @@ class GrowTable : public GrowRect {
double header_row_height; //!< Height of header row.
double row_height; //!< Row hight.
double column_width[TABLE_MAX_COL]; //!< Width of each column.
char header_text[40][TABLE_MAX_COL]; //!< 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 value_size; //!< Total size of cell_value.
char *cell_value; //!< Contains the cell values.
......
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