| 2629 | |
| 2630 | |
| 2631 | void CsvApplication::mergeCols() { |
| 2632 | Fl_Choice *colChoice; |
| 2633 | int windowIndex = getTopWindow(); |
| 2634 | std::vector<int> sel = windows[windowIndex].grid->getSelection(); |
| 2635 | int column = sel[1]; |
| 2636 | int callbackDataExchange = 0; |
| 2637 | |
| 2638 | My_Fl_Small_Window * mergeColWin = new My_Fl_Small_Window(600, 175); |
| 2639 | mergeColWin->color(ColorThemes::getColor(app.getTheme(), "win_bg")); |
| 2640 | mergeColWin->label("Merge Columns"); |
| 2641 | |
| 2642 | colChoice = new Fl_Choice(100, 50, 120, 25, "Columns: "); |
| 2643 | if( column == (table_index_t) windows[windowIndex].table->headerRow->size() - 1 && column > 0 ) { |
| 2644 | --column; |
| 2645 | } |
| 2646 | if( column < 0 || column >= (table_index_t) windows[windowIndex].table->headerRow->size() ) |
| 2647 | column = 0; |
| 2648 | for( size_t c = 0; c < windows[windowIndex].table->headerRow->size() - 1; ++c ) { |
| 2649 | std::string colChoiceItem = windows[windowIndex].table->getHeaderCell(c,false) + " - " + windows[windowIndex].table->getHeaderCell(c+1,false); |
| 2650 | colChoice->add(colChoiceItem.c_str()); |
| 2651 | } |
| 2652 | colChoice->value(column); |
| 2653 | colChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 2654 | |
| 2655 | Fl_Input *mergeStringBox = new Fl_Input(330,50,220,20, "Glue string:"); |
| 2656 | mergeStringBox->box(FL_BORDER_BOX); |
| 2657 | mergeStringBox->value(app.lastGlueString.c_str()); |
| 2658 | mergeStringBox->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 2659 | mergeStringBox->take_focus(); |
| 2660 | |
| 2661 | My_Fl_Button *mergeColumnButton = new My_Fl_Button(450,125,100,24, "Merge"); |
| 2662 | mergeColumnButton->colors = CsvApplication::createButtonColor(My_Fl_Button::HIGHLIGHT); |
| 2663 | mergeColumnButton->callback(splitColumn_CB, &callbackDataExchange); |
| 2664 | |
| 2665 | My_Fl_Button *cancelButton = new My_Fl_Button(330,125,100,24, "Cancel"); |
| 2666 | cancelButton->colors = CsvApplication::createButtonColor(My_Fl_Button::DEFAULT); |
| 2667 | cancelButton->callback(splitColumn_Cancel_CB, &callbackDataExchange); |
| 2668 | |
| 2669 | mergeColWin->set_modal(); |
| 2670 | mergeColWin->show(); |
| 2671 | while( mergeColWin->shown() ) { |
| 2672 | Fl::wait(); |
| 2673 | } |
| 2674 | if( |
| 2675 | callbackDataExchange == TCRUNCHER_MYFLCHOICE_MAGICAL || |
| 2676 | (Fl::event() == FL_KEYDOWN && Fl::event_key() == FL_Enter) |
| 2677 | ) { |
| 2678 | windows[windowIndex].setChanged(true); |
| 2679 | windows[windowIndex].setUsed(true); |
| 2680 | showImWorkingWindow("Merging ..."); |
| 2681 | windows[windowIndex].addUndoStateTable("Merge Column"); |
| 2682 | app.lastGlueString = mergeStringBox->value(); |
| 2683 | windows[windowIndex].table->mergeColumns(colChoice->value(), app.lastGlueString); |
| 2684 | hideImWorkingWindow(); |
| 2685 | windows[windowIndex].grid->cols( windows[windowIndex].table->getNumberCols() ); |
| 2686 | windows[windowIndex].grid->redraw(); |
| 2687 | Fl::check(); |
| 2688 | } |
no test coverage detected