* Sort table by column */
| 1853 | * Sort table by column |
| 1854 | */ |
| 1855 | void CsvApplication::sort(unsigned int column) { |
| 1856 | Fl_Choice *colChoice; |
| 1857 | Fl_Choice *orderChoice; |
| 1858 | Fl_Choice *typeChoice; |
| 1859 | My_Fl_Button *sortButton; |
| 1860 | int windowIndex = getTopWindow(); |
| 1861 | std::tuple<Fl_Widget *, Fl_Widget *, Fl_Widget *> widgets; |
| 1862 | int searchType = 1; |
| 1863 | if( windows[windowIndex].table->isNumericColumn(column, 1000000) ) { |
| 1864 | searchType = 0; |
| 1865 | } |
| 1866 | |
| 1867 | Fl_Window *topWin = Fl::first_window(); |
| 1868 | |
| 1869 | // sortWin = new My_Fl_Small_Window(640,180); |
| 1870 | // sortWin->set_modal(); |
| 1871 | sortWin->color(ColorThemes::getColor(app.getTheme(), "win_bg")); |
| 1872 | sortWin->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 1873 | sortWin->label("Sort By"); |
| 1874 | sortWin->callback(doSortWinCB); |
| 1875 | |
| 1876 | sortWin->begin(); |
| 1877 | colChoice = new Fl_Choice(90, 30, 120, 25, "Column: "); |
| 1878 | if( column >= windows[windowIndex].table->headerRow->size() ) |
| 1879 | column = 0; |
| 1880 | for( size_t c = 0; c < windows[windowIndex].table->headerRow->size(); ++c ) { |
| 1881 | colChoice->add(windows[windowIndex].table->getHeaderCell(c,false).c_str()); |
| 1882 | } |
| 1883 | colChoice->value(column); |
| 1884 | colChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 1885 | |
| 1886 | orderChoice = new Fl_Choice(280, 30, 120, 25, "Order: "); |
| 1887 | orderChoice->add("Ascending"); |
| 1888 | orderChoice->add("Descending"); |
| 1889 | orderChoice->value(0); |
| 1890 | orderChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 1891 | |
| 1892 | typeChoice = new Fl_Choice(470, 30, 120, 25, "Type: "); |
| 1893 | typeChoice->add("Numeric"); |
| 1894 | typeChoice->add("String"); |
| 1895 | typeChoice->add("String (ignore case)"); |
| 1896 | typeChoice->value(searchType); |
| 1897 | typeChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text")); |
| 1898 | |
| 1899 | std::get<0>(widgets) = colChoice; |
| 1900 | std::get<1>(widgets) = orderChoice; |
| 1901 | std::get<2>(widgets) = typeChoice; |
| 1902 | |
| 1903 | struct My_Fl_Button::buttonColorStruct colorsHighlightButton; |
| 1904 | colorsHighlightButton.background = ColorThemes::getColor(app.getTheme(), "hightlight_button_bg"); |
| 1905 | colorsHighlightButton.label = ColorThemes::getColor(app.getTheme(), "hightlight_button_text"); |
| 1906 | colorsHighlightButton.border = ColorThemes::getColor(app.getTheme(), "hightlight_button_border"); |
| 1907 | colorsHighlightButton.windowBg = ColorThemes::getColor(app.getTheme(), "win_bg"); |
| 1908 | colorsHighlightButton.borderWidth = ColorThemes::getColor(app.getTheme(), "highlight_button_border_width"); |
| 1909 | sortButton = new My_Fl_Button(90,100,100,24, "Sort"); |
| 1910 | sortButton->colors = colorsHighlightButton; |
| 1911 | sortButton->callback(doSortCB, &widgets); |
| 1912 |
nothing calls this directly
no test coverage detected