back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/menu_callbacks.cpp
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-11-12 01:23:17 +0300
committerscratko <m@scratko.xyz>2024-11-12 01:27:49 +0300
commit060fe2ebc6f5ed26c445f95b3cd6c9ee5bc24e28 (patch)
tree6a042263a2e26cbb535118a43f4a84ff47fbde25 /menu_callbacks.cpp
parent9023f43291b894f7670df2ffe513808ef6360954 (diff)
downloadpicture-puzzle-060fe2ebc6f5ed26c445f95b3cd6c9ee5bc24e28.tar.gz
picture-puzzle-060fe2ebc6f5ed26c445f95b3cd6c9ee5bc24e28.tar.bz2
picture-puzzle-060fe2ebc6f5ed26c445f95b3cd6c9ee5bc24e28.zip
Added menu-bar and file chooser
Diffstat (limited to 'menu_callbacks.cpp')
-rw-r--r--menu_callbacks.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/menu_callbacks.cpp b/menu_callbacks.cpp
new file mode 100644
index 0000000..df70514
--- /dev/null
+++ b/menu_callbacks.cpp
@@ -0,0 +1,34 @@
+#include <FL/Fl_Native_File_Chooser.H>
+#include <stdio.h>
+#include <string>
+
+#include "menu_callbacks.hpp"
+
+void load_file_callback(Fl_Widget *sender, void *window)
+{
+ auto dialog = Fl_Native_File_Chooser{};
+ dialog.type(Fl_Native_File_Chooser::BROWSE_FILE);
+ dialog.filter("JPEG Files (*.jpg)\tPNG Files (*.png)");
+#if defined(_WIN32)
+ dialog.directory((string {getenv("HOMEPATH")} + "\\Desktop").c_str());
+#else
+ dialog.directory((std::string {getenv("HOME")} + "/Desktop").c_str());
+#endif
+ dialog.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM |
+ Fl_Native_File_Chooser::NEW_FOLDER);
+ if (dialog.show() == 0)
+ printf("%s\n", dialog.filename());
+}
+
+void exit_callback(Fl_Widget *w, void *params)
+{
+ w->parent()->hide();
+}
+
+void solve_problem_callback(Fl_Widget *w, void *params)
+{
+}
+
+void about_callback(Fl_Widget *w, void *params)
+{
+}