* Creates the GUI for this window. Called after the constructor has been called. */
| 175 | * Creates the GUI for this window. Called after the constructor has been called. |
| 176 | */ |
| 177 | void CsvWindow::create(int createdWindowCount) { |
| 178 | int gridHeight; |
| 179 | int iconSize = TCRUNCHER_TOOLBAR_ICONSIZE; |
| 180 | int iconPadding = TCRUNCHER_TOOLBAR_ICONPADDING; |
| 181 | std::string name = "Empty "+std::to_string(createdWindowCount); |
| 182 | this->createdWindowCount = createdWindowCount; |
| 183 | std::string workDir = ""; |
| 184 | |
| 185 | #ifdef DEBUG |
| 186 | printf("CsvWindow::create\n"); fflush(stdout); |
| 187 | #endif |
| 188 | |
| 189 | // set slot as used ... |
| 190 | setWindowSlotUsed(true); |
| 191 | // ... but set window as not changed |
| 192 | changed = false; // calling setChanged() without a window leads to a segfault |
| 193 | changedWhileUndoDisabled = false; |
| 194 | |
| 195 | // Position window in the center. Addtional windows are positioned 40 pixels to the southeast |
| 196 | int moveWinSouthEast = app.getCreatedWindowCount() > 4 ? 4 : app.getCreatedWindowCount(); |
| 197 | int posX = std::ceil((Fl::w() - width) / 2) + (moveWinSouthEast - 1)* 40; |
| 198 | int posY = std::ceil((Fl::h() - height) / 2) + (moveWinSouthEast - 1) * 40; |
| 199 | |
| 200 | // Load images for toolbar |
| 201 | static Fl_RGB_Image *addColBeforePng = app.xpmResizer(ui_icons::icon_add_col_left, iconSize); |
| 202 | static Fl_RGB_Image *addColPng = app.xpmResizer(ui_icons::icon_add_col_right, iconSize); |
| 203 | static Fl_RGB_Image *addRowAbovePng = app.xpmResizer(ui_icons::icon_add_row_above, iconSize); |
| 204 | static Fl_RGB_Image *addRowPng = app.xpmResizer(ui_icons::icon_add_row_below, iconSize); |
| 205 | static Fl_RGB_Image *delColPng = app.xpmResizer(ui_icons::icon_del_col, iconSize); |
| 206 | static Fl_RGB_Image *delRowPng = app.xpmResizer(ui_icons::icon_del_row, iconSize); |
| 207 | static Fl_RGB_Image *infoPng = app.xpmResizer(ui_icons::icon_info, iconSize); |
| 208 | static Fl_RGB_Image *openPng = app.xpmResizer(ui_icons::icon_open, iconSize); |
| 209 | static Fl_RGB_Image *saveAsPng = app.xpmResizer(ui_icons::icon_save_as, iconSize); |
| 210 | static Fl_RGB_Image *savePng = app.xpmResizer(ui_icons::icon_save, iconSize); |
| 211 | static Fl_RGB_Image *separatorPng = app.xpmResizer(ui_icons::icon_separator, iconSize); |
| 212 | |
| 213 | // Create table |
| 214 | table = new CsvTable(TCRUNCHER_STARTUP_ROWS,TCRUNCHER_STARTUP_COLS); |
| 215 | |
| 216 | // Create window, grid and toolbar |
| 217 | win = new My_Fl_Double_Window(posX, posY, width, height, TCRUNCHER_APP_NAME); |
| 218 | win->color(ColorThemes::getColor(app.getTheme(), "win_bg")); |
| 219 | setName(name); |
| 220 | |
| 221 | win->begin(); |
| 222 | gridHeight = height - TCRUNCHER_TOPOFFSET - TCRUNCHER_ICON_BAR_HEIGHT - TCRUNCHER_STATUS_BAR_HEIGHT; |
| 223 | grid = new CsvGrid(10, TCRUNCHER_TOPOFFSET + TCRUNCHER_ICON_BAR_HEIGHT, width-20, gridHeight); |
| 224 | grid->begin(); |
| 225 | grid->setDataTable(table); |
| 226 | grid->box(FL_NO_BOX); // FL_NO_BOX FL_FLAT_BOX |
| 227 | grid->color(ColorThemes::getColor(app.getTheme(), "table_bg")); |
| 228 | grid->redraw(); |
| 229 | // Table rows |
| 230 | grid->row_header(1); |
| 231 | grid->row_header_width(80); |
| 232 | grid->row_resize(1); |
| 233 | grid->rows(TCRUNCHER_STARTUP_ROWS); |
| 234 | // grid->row_height_all(TCRUNCHER_STARTUP_CELL_HEIGHT); |
no test coverage detected