| 2064 | |
| 2065 | |
| 2066 | void CsvApplication::executeMacro() { |
| 2067 | if( macroWinOpened ) // only open one macro window |
| 2068 | return; |
| 2069 | macroWinOpened = true; |
| 2070 | std::tuple<Fl_Text_Buffer *, Fl_Text_Display *, Fl_Text_Display *> widgets; // tuple of widgets that are passed to callbacks |
| 2071 | std::string logContent = ""; |
| 2072 | const int winWidth = 700; // height of macro window |
| 2073 | const int winHeight = 450; // width of macro window |
| 2074 | const int listWidth = 150; // width of macro list |
| 2075 | const int gridMargin = 12; // size of margins |
| 2076 | const int logHeight = 120; // height of the log window |
| 2077 | const int buttonHeight = 24; // height of the Execute button |
| 2078 | const int editorHeight = winHeight-logHeight-4*gridMargin-buttonHeight; // height of the source editor |
| 2079 | // const int imgButtonSize = 15; // size of the image buttons to manage macro list |
| 2080 | const int imgButtonDistance = 8; // horizontal distance of image buttons to macro list |
| 2081 | std::string workDir = ""; |
| 2082 | int selectedItem = 0; |
| 2083 | |
| 2084 | My_Fl_Small_Window *macroWin = new My_Fl_Small_Window(winWidth,winHeight); |
| 2085 | Fl_Text_Buffer *sourceBuffer = new Fl_Text_Buffer(); |
| 2086 | Fl_Text_Editor *sourceEditor = new Fl_Text_Editor(listWidth+2*gridMargin, gridMargin, winWidth-listWidth-3*gridMargin, editorHeight); |
| 2087 | My_Fl_Button *executeButton = new My_Fl_Button(winWidth-gridMargin-100, editorHeight+2*gridMargin, 100, buttonHeight, "Execute"); |
| 2088 | My_Fl_Button *insertLoopButton = new My_Fl_Button(listWidth+2*gridMargin, editorHeight+gridMargin+imgButtonDistance, 80, buttonHeight-8, "Insert Loop"); |
| 2089 | Fl_Hold_Browser *macroList = new Fl_Hold_Browser(gridMargin, gridMargin, listWidth, editorHeight); |
| 2090 | Fl_Text_Buffer *logBuffer = new Fl_Text_Buffer(); |
| 2091 | Fl_Text_Display *logDisplay = new Fl_Text_Display(gridMargin, editorHeight+3*gridMargin+buttonHeight, winWidth-2*gridMargin, logHeight); |
| 2092 | |
| 2093 | |
| 2094 | // Toolbar: add, delete |
| 2095 | addDelParamType addDelParam; |
| 2096 | std::get<0>(addDelParam) = macroList; |
| 2097 | std::get<1>(addDelParam) = sourceEditor; |
| 2098 | macroWin->begin(); |
| 2099 | My_Toolbar *macroTb = new My_Toolbar(gridMargin, editorHeight+gridMargin+imgButtonDistance, listWidth, macroWinImgButtonSize); |
| 2100 | // #ifdef __APPLE__ |
| 2101 | macroTb->AddButton("Add Macro", plusPng, &addNewMacroCB, &addDelParam, macroWinImgButtonSize); |
| 2102 | macroTb->AddButton("Delete Macro", minusPng, &deleteMacroCB, &addDelParam, macroWinImgButtonSize); |
| 2103 | // #else |
| 2104 | // Workaround for Windows: doesn't show PNG icons |
| 2105 | // macroTb->AddButton("Add Macro", NULL, &addNewMacroCB, &addDelParam, macroWinImgButtonSize, "+", 20); |
| 2106 | // macroTb->AddButton("Delete Macro", NULL, &deleteMacroCB, &addDelParam, macroWinImgButtonSize, "-", 24); |
| 2107 | // #endif |
| 2108 | macroTb->end(); |
| 2109 | macroWin->end(); |
| 2110 | |
| 2111 | // struct My_Fl_Button::buttonColorStruct colorsHighlightButton; |
| 2112 | // colorsHighlightButton.background = ColorThemes::getColor(app.getTheme(), "hightlight_button_bg"); |
| 2113 | // colorsHighlightButton.label = ColorThemes::getColor(app.getTheme(), "hightlight_button_text"); |
| 2114 | // colorsHighlightButton.border = ColorThemes::getColor(app.getTheme(), "hightlight_button_border"); |
| 2115 | // colorsHighlightButton.windowBg = ColorThemes::getColor(app.getTheme(), "win_bg"); |
| 2116 | // colorsHighlightButton.borderWidth = ColorThemes::getColor(app.getTheme(), "highlight_button_border_width"); |
| 2117 | struct My_Fl_Button::buttonColorStruct colorsButton; |
| 2118 | colorsButton.background = ColorThemes::getColor(app.getTheme(), "button_bg"); |
| 2119 | colorsButton.label = ColorThemes::getColor(app.getTheme(), "button_text"); |
| 2120 | colorsButton.border = ColorThemes::getColor(app.getTheme(), "button_border"); |
| 2121 | colorsButton.windowBg = ColorThemes::getColor(app.getTheme(), "win_bg"); |
| 2122 | colorsButton.borderWidth = ColorThemes::getColor(app.getTheme(), "button_border_width"); |
| 2123 | |