Skip to content

add theming to menu bar and scrollbars #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ docs/doxygen/
CMakeSettings.json
scripts/*.exe
scripts/appimagetool-x86_64.AppImage

bin/
16 changes: 13 additions & 3 deletions src/csvapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@
*/


#include "colorthemes.hh"
#include "csvapplication.hh"
#include "csvmenu.hh"

#include "csvparser.hh"
#include "csvwindow.hh"
#include "helper.hh"
#include "icons/abouticon.xpm"
#include "macro.hh"


#include <algorithm>
#include <deque>
#include <filesystem>
#include <fstream>
#include <httplib.h>
#include <utf8.h>

/************************************************************************************
*
Expand Down Expand Up @@ -363,6 +372,7 @@ int CsvApplication::createNewWindow() {
remainOpenWin->hide();
#endif
// setMenuBar(windows[newWindowIndex].win);
windows[newWindowIndex].applyTheme();
windows[newWindowIndex].win->show();
return newWindowIndex;
}
Expand Down Expand Up @@ -872,7 +882,7 @@ std::pair<CsvDefinition, float> CsvApplication::guessDefinition(std::istream *in
float confidence;
CsvParser *parser = new CsvParser();
CsvDataStorage localStorage;

// Define definitions for probing
std::vector< std::tuple<CsvDefinition,int,int> > definitions;
definitions.push_back( std::tuple<CsvDefinition, int, int>(CsvDefinition(),0,0) );
Expand Down
14 changes: 2 additions & 12 deletions src/csvapplication.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,21 @@


#include "globals.hh"
#include "colorthemes.hh"
#include "csvdatastorage.hh"
#include "csvwindow.hh"
#include "csvtable.hh"
#include "csvgrid.hh"
#include "csvwidgets.hh"
#include "csvmenu.hh"
#include "macro.hh"



#include <vector>
#include <tuple>
#include <fstream>
#include <map>
#include <string>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <filesystem>
#include <iostream>
#include <queue>
#include <deque>

#ifdef _WIN64
#include <direct.h>
Expand All @@ -68,8 +62,6 @@
#include <FL/Fl_Text_Editor.H>
#include <FL/Fl_Tooltip.H>


#include "utf8.h"
#include "recentfiles.hh"


Expand Down Expand Up @@ -100,8 +92,6 @@ namespace ui_icons {
#undef None
#endif
#endif
#include "httplib.h"


#ifndef MY_VERSION
#define MY_VERSION 0.0.0.0
Expand Down
4 changes: 4 additions & 0 deletions src/csvdatastorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#include "csvdatastorage.hh"

#include <algorithm>
#include <iomanip> // needed for dump()
#include <iostream> // needed for dump()
#include <utf8-cpp-utils/utf8_cpp_utils.hh>

/*

Expand Down
12 changes: 4 additions & 8 deletions src/csvdatastorage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
#ifndef _CSVDATASTORAGE_HH
#define _CSVDATASTORAGE_HH

#include "globals.hh"

#include <FL/Fl.H> // called by sort() to update UI

#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
#include <iostream> // needed for dump()
#include <iomanip> // needed for dump()
#include <chrono>
#include <vector>


#include "globals.hh"
#include "utf8-cpp-utils/utf8_cpp_utils.hh"


/**
Expand Down
16 changes: 13 additions & 3 deletions src/csvgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@
*
************************************************************************************/

#include "csvwindow.hh"
#include "csvtable.hh"
#include "colorthemes.hh"
#include "csvapplication.hh"
#include "csvgrid.hh"
#include "csvtable.hh"
#include "csvwindow.hh"
#include "helper.hh"

#include <algorithm>


extern CsvWindow windows[];
extern CsvApplication app;



CsvGrid::CsvGrid(int X,int Y,int W,int H,const char* L) : Fl_Table(X,Y,W,H,L) {
DEBUG_PRINTF("#### CsvGrid::CsvGrid: %d, %d, %d, %d\n", X, Y, W, H);
text_font_size = TCRUNCHER_INITIAL_FONT_SIZE;
Expand All @@ -57,6 +60,13 @@ CsvGrid::CsvGrid(int X,int Y,int W,int H,const char* L) : Fl_Table(X,Y,W,H,L) {
redraw();
}

Fl_Scrollbar *CsvGrid::vscrollbar() {
return Fl_Table::vscrollbar;
}

Fl_Scrollbar *CsvGrid::hscrollbar() {
return Fl_Table::hscrollbar;
}

CsvGrid::~CsvGrid() {
DEBUG_PRINTF("#### CsvGrid::~CsvGrid\n");
Expand Down
10 changes: 5 additions & 5 deletions src/csvgrid.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@
#ifndef _CSVGRID_HH
#define _CSVGRID_HH

#include "globals.hh"
#include "csvtable.hh"

#include <algorithm>
#include <FL/Fl_Scrollbar.H>

#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Table.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/names.h>

#include "globals.hh"
#include "csvwindow.hh"
#include "csvtable.hh"



/**
Expand Down Expand Up @@ -67,6 +65,8 @@ public:
void selectAll(); // deletes the content of the selected cells
int handle(int);
int innerWidth(); // return the inner width of the table grid
Fl_Scrollbar *vscrollbar();
Fl_Scrollbar *hscrollbar();


protected:
Expand Down
8 changes: 5 additions & 3 deletions src/csvmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "csvmenu.hh"
#include "csvapplication.hh"

#include <FL/Enumerations.H>
#include <filesystem>

extern Fl_Preferences preferences;
extern CsvApplication app;

Expand All @@ -44,9 +47,8 @@ void CsvMenu::init() {
int flags = 0;
std::string prefTheme = app.getPreference(&preferences, TCRUNCHER_PREF_THEME, "BRIGHT");
std::string prefFont = app.getPreference(&preferences, TCRUNCHER_PREF_GRID_TEXT_FONT, TCRUNCHER_FALLBACK_FONT);

Fl::menu_linespacing(12);
// undoLabelText = TCRUNCHER_MENUTEXT_UNDO;

box(FL_NO_BOX);
down_box(FL_NO_BOX);
add("&File/&New", FL_COMMAND + 'n', MyMenuCallback, 0, FL_MENU_DIVIDER);
Expand Down Expand Up @@ -129,7 +131,7 @@ void CsvMenu::init() {
#endif

#ifndef __APPLE__
down_box(FL_NO_BOX);
down_box(FL_FLAT_BOX);
#endif
}

Expand Down
4 changes: 0 additions & 4 deletions src/csvmenu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
#ifndef _CSVMENU_HH
#define _CSVMENU_HH

#include <iostream>
#include <string>
#include <filesystem>
#include <vector>
#include <algorithm>


#include <FL/Fl_Preferences.H>

Expand Down
6 changes: 6 additions & 0 deletions src/csvparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@


#include "csvparser.hh"
#include "helper.hh"

#include <sstream>
// for reading utf16
#include <locale>
#include <codecvt>


#ifndef TCRUNCHER_PARSER_WITHOUT_UPDATE
Expand Down
22 changes: 7 additions & 15 deletions src/csvparser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@
#ifndef _CSVPARSER_HH
#define _CSVPARSER_HH


#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <istream>
#include <cstdint>
#include <inttypes.h>

// for reading utf16
#include <locale>
#include <codecvt>


#include "helper.hh"
#include "globals.hh"
#include "csvdatastorage.hh"

Expand All @@ -46,6 +31,13 @@
#include "csvwindow.hh"
#endif

#include <iostream>
#include <string>
#include <vector>
#include <istream>
#include <cstdint>
#include <inttypes.h>


#define CSVPARSER_CONST_ENCLOSED 1
#define CSVPARSER_CONST_NOT_ENCLOSED 0
Expand Down
11 changes: 11 additions & 0 deletions src/csvtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@


#include "csvtable.hh"
#include "helper.hh"
#include "macro.hh"

#include <algorithm>
#include <fstream>
#include <json/json.hpp>
#include <map>
#include <ostream>
#include <utf8-cpp-utils/utf8_cpp_utils.hh>

// Used for stringstream and std::quoted in replaceUtf8String
#include <iomanip>
#include <sstream>

extern Macro macro; // to use JS for searching

Expand Down
15 changes: 2 additions & 13 deletions src/csvtable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,19 @@
#ifndef _CSVTABLE_HH
#define _CSVTABLE_HH

#include "globals.hh"
#include "csvdatastorage.hh"

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <tuple>
#include <algorithm>
#include <iterator>
#include <set>


// #include <FL/Fl.H>
// #include <FL/fl_ask.H>

#include "json/json.hpp"

#include "helper.hh"
#include "globals.hh"
#include "csvdatastorage.hh"

// Used for stringstream and std::quoted in replaceUtf8String
#include <iomanip>
#include <sstream>



/**
Expand Down
7 changes: 4 additions & 3 deletions src/csvwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "csvwidgets.hh"
#include "csvwindow.hh"
#include "csvapplication.hh"
#include "colorthemes.hh"


extern CsvApplication app;
Expand Down Expand Up @@ -58,7 +59,7 @@ My_Toolbar::My_Toolbar(int X,int Y,int W,int H) : Fl_Pack(X,Y,W,H) {
@param shortName If given, it is used as the button text (if no image is present)
@return Newly created button.
*/
Fl_Button *My_Toolbar::AddButton(const char *name, Fl_RGB_Image *img, Fl_Callback *cb, void *data, int width, std::string shortName, int fontSize) {
Fl_Button *My_Toolbar::AddButton(const char *name, Fl_RGB_Image *img, Fl_Callback *cb, void *data, int width, const char *shortName, int fontSize) {
begin();
if( !width ) {
width = 40;
Expand All @@ -74,8 +75,8 @@ Fl_Button *My_Toolbar::AddButton(const char *name, Fl_RGB_Image *img, Fl_Callbac
b->labelcolor(ColorThemes::getColor(app.getTheme(), "toolbar_text"));
if( fontSize > 0 )
b->labelsize(fontSize);
if( shortName != "" ) {
b->copy_label(shortName.c_str());
if( strcmp(shortName, "") ) {
b->copy_label(shortName);
} else {
b->copy_label(name);
}
Expand Down
6 changes: 2 additions & 4 deletions src/csvwidgets.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <FL/Fl_Light_Button.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Pixmap.H>


#include "globals.hh"
#include <cstdint>

/** \file csvwidgets.hh
* \brief Contains several classes that override FLTK widgets
Expand All @@ -46,7 +44,7 @@
class My_Toolbar : public Fl_Pack {
public:
My_Toolbar(int X,int Y,int W,int H);
Fl_Button *AddButton(const char *name, Fl_RGB_Image *img=0, Fl_Callback *cb=0, void *data=0, int width=0, std::string shortName="", int fontSize = 0);
Fl_Button *AddButton(const char *name, Fl_RGB_Image *img=0, Fl_Callback *cb=0, void *data=0, int width=0, const char *shortName="", int fontSize = 0);
Fl_Light_Button *AddCheckButton(const char *name, Fl_Callback *cb=0, void *data=0, int width=0);
};

Expand Down
Loading