diff --git a/graphicswin.cpp b/graphicswin.cpp index 18fb422..8a3805a 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -70,11 +70,18 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 1, "Show Snap &Grid", MNU_SHOW_GRID, '>', mView }, { 1, "Use &Perspective Projection", MNU_PERSPECTIVE_PROJ,'`', mView }, { 1, NULL, 0, 0, NULL }, -{ 1, "Show Text &Window", MNU_SHOW_TEXT_WND, '\t', mView }, +#ifdef HAVE_FLTK +{ 1, "Show Menu &Bar", MNU_SHOW_MENU_BAR, F(12), mView }, +#endif { 1, "Show &Toolbar", MNU_SHOW_TOOLBAR, 0, mView }, +{ 1, "Show Text &Window", MNU_SHOW_TEXT_WND, '\t', mView }, { 1, NULL, 0, 0, NULL }, { 1, "Dimensions in &Inches", MNU_UNITS_INCHES, 0, mView }, { 1, "Dimensions in &Millimeters", MNU_UNITS_MM, 0, mView }, +#ifdef HAVE_FLTK_FULLSCREEN +{ 1, NULL, 0, 0, NULL }, +{ 1, "&Full Screen", MNU_FULL_SCREEN, F(11), mView }, +#endif { 0, "&New Group", 0, 0, NULL }, { 1, "Sketch In &3d", MNU_GROUP_3D, S|'3', mGrp }, @@ -504,9 +511,10 @@ void GraphicsWindow::MenuView(int id) { } break; - case MNU_SHOW_TEXT_WND: - SS.GW.showTextWindow = !SS.GW.showTextWindow; + case MNU_SHOW_MENU_BAR: + ToggleMenuBar(); SS.GW.EnsureValidActives(); + InvalidateGraphics(); break; case MNU_SHOW_TOOLBAR: @@ -515,9 +523,8 @@ void GraphicsWindow::MenuView(int id) { InvalidateGraphics(); break; - case MNU_UNITS_MM: - SS.viewUnits = SolveSpace::UNIT_MM; - SS.later.showTW = true; + case MNU_SHOW_TEXT_WND: + SS.GW.showTextWindow = !SS.GW.showTextWindow; SS.GW.EnsureValidActives(); break; @@ -527,6 +534,17 @@ void GraphicsWindow::MenuView(int id) { SS.GW.EnsureValidActives(); break; + case MNU_UNITS_MM: + SS.viewUnits = SolveSpace::UNIT_MM; + SS.later.showTW = true; + SS.GW.EnsureValidActives(); + break; + + case MNU_FULL_SCREEN: + ToggleFullScreen(); + SS.GW.EnsureValidActives(); + break; + default: oops(); } InvalidateGraphics(); @@ -596,9 +614,15 @@ void GraphicsWindow::EnsureValidActives(void) { ShowTextWindow(SS.GW.showTextWindow); CheckMenuById(MNU_SHOW_TEXT_WND, SS.GW.showTextWindow); +#ifdef HAVE_FLTK + CheckMenuById(MNU_SHOW_MENU_BAR, MenuBarIsVisible()); +#endif CheckMenuById(MNU_SHOW_TOOLBAR, SS.showToolbar); CheckMenuById(MNU_PERSPECTIVE_PROJ, SS.usePerspectiveProj); CheckMenuById(MNU_SHOW_GRID, SS.GW.showSnapGrid); +#ifdef HAVE_FLTK_FULLSCREEN + CheckMenuById(MNU_FULL_SCREEN, FullScreenIsActive()); +#endif if(change) SS.later.showTW = true; } diff --git a/solvespace.h b/solvespace.h index 37cd048..308eee1 100644 --- a/solvespace.h +++ b/solvespace.h @@ -7,6 +7,25 @@ #ifndef __SOLVESPACE_H #define __SOLVESPACE_H +#ifdef HAVE_CONFIG_H +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef WIN32 +# include // required by GL headers +#endif +#include +#include + // The few floating-point equality comparisons in SolveSpace have been // carefully considered, so we disable the -Wfloat-equal warning for them #ifdef __clang__ @@ -22,6 +41,7 @@ // Debugging functions #define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \ if(0) *(char *)0 = 1; exit(-1); } while(0) + #ifndef min # define min(x, y) ((x) < (y) ? (x) : (y)) #endif @@ -65,18 +85,6 @@ inline double ffabs(double v) { return (v > 0) ? v : (-v); } #define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#') -#include -#include -#include -#include -#include -#include -#ifdef WIN32 -# include // required by GL headers -#endif -#include -#include - #ifdef WIN32 // Define some useful C99 integer types. typedef UINT64 uint64_t; @@ -112,38 +120,58 @@ void RefreshRecentMenus(void); #define SAVE_CANCEL (0) int SaveFileYesNoCancel(void); +#ifdef HAVE_FLTK + // Selection pattern format for FLTK's file chooser classes: + // "PNG File\t*.png\n" + // "JPEG File\t*.{jpg,jpeg}\n" + // "All Files\t*" +# define PAT1(desc,e1) desc "\t*." e1 "\n" +# define PAT2(desc,e1,e2) desc "\t*.{" e1 "," e2 "}\n" +# define ENDPAT "All Files\t*" +#else + // Selection pattern format for Win32's OPENFILENAME.lpstrFilter: + // "PNG File (*.png)\0*.png\0" + // "JPEG File (*.jpg;*.jpeg)\0*.jpg;*.jpeg\0" + // "All Files (*)\0*\0\0" +# define PAT1(desc,e1) desc " (*." e1 ")\0*." e1 "\0" +# define PAT2(desc,e1,e2) desc " (*." e1 ";*." e2 ")\0*." e1 ";*." e2 "\0" +# define ENDPAT "All Files (*)\0*\0\0" +#endif + // SolveSpace native file format -#define SLVS_PATTERN "SolveSpace Models (*.slvs)\0*.slvs\0All Files (*)\0*\0\0" +#define SLVS_PATTERN PAT1("SolveSpace Models", "slvs") ENDPAT #define SLVS_EXT "slvs" // PNG format bitmap -#define PNG_PATTERN "PNG (*.png)\0*.png\0All Files (*)\0*\0\0" +#define PNG_PATTERN PAT1("PNG", "png") ENDPAT #define PNG_EXT "png" // Triangle mesh -#define MESH_PATTERN "STL Mesh (*.stl)\0*.stl\0" \ - "Wavefront OBJ Mesh (*.obj)\0*.obj\0" \ - "All Files (*)\0*\0\0" +#define MESH_PATTERN \ + PAT1("STL Mesh", "stl") \ + PAT1("Wavefront OBJ Mesh", "obj") \ + ENDPAT #define MESH_EXT "stl" // NURBS surfaces -#define SRF_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \ - "All Files(*)\0*\0\0" +#define SRF_PATTERN PAT2("STEP File", "step", "stp") ENDPAT #define SRF_EXT "step" // 2d vector (lines and curves) format -#define VEC_PATTERN "PDF File (*.pdf)\0*.pdf\0" \ - "Encapsulated PostScript (*.eps;*.ps)\0*.eps;*.ps\0" \ - "Scalable Vector Graphics (*.svg)\0*.svg\0" \ - "STEP File (*.step;*.stp)\0*.step;*.stp\0" \ - "DXF File (*.dxf)\0*.dxf\0" \ - "HPGL File (*.plt;*.hpgl)\0*.plt;*.hpgl\0" \ - "G Code (*.txt)\0*.txt\0" \ - "All Files (*)\0*\0\0" +#define VEC_PATTERN \ + PAT1("PDF File", "pdf") \ + PAT2("Encapsulated PostScript", "eps", "ps") \ + PAT1("Scalable Vector Graphics", "svg") \ + PAT2("STEP File", "step", "stp") \ + PAT1("DXF File", "dxf") \ + PAT2("HPGL File", "plt", "hpgl") \ + PAT1("G Code", "txt") \ + ENDPAT #define VEC_EXT "pdf" // 3d vector (wireframe lines and curves) format -#define V3D_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \ - "DXF File (*.dxf)\0*.dxf\0" \ - "All Files (*)\0*\0\0" +#define V3D_PATTERN \ + PAT2("STEP File", "step", "stp") \ + PAT1("DXF File", "dxf") \ + ENDPAT #define V3D_EXT "step" // Comma-separated value, like a spreadsheet would use -#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0" +#define CSV_PATTERN PAT1("CSV File", "csv") ENDPAT #define CSV_EXT "csv" bool GetSaveFile(char *file, const char *defExtension, const char *selPattern); bool GetOpenFile(char *file, const char *defExtension, const char *selPattern); @@ -170,10 +198,14 @@ void AddContextMenuItem(const char *legend, int id); void CreateContextSubmenu(void); int ShowContextMenu(void); +void ToggleMenuBar(void); +bool MenuBarIsVisible(void); void ShowTextWindow(bool visible); void InvalidateText(void); void InvalidateGraphics(void); void PaintGraphics(void); +void ToggleFullScreen(void); +bool FullScreenIsActive(void); void GetGraphicsWindowSize(int *w, int *h); void GetTextWindowSize(int *w, int *h); int32_t GetMilliseconds(void); @@ -232,8 +264,12 @@ void ssglVertex3v(Vector u); void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone = true); void ssglAxisAlignedLineLoop(double l, double r, double t, double b); #define DEFAULT_TEXT_HEIGHT (11.5) -#define SSGL_CALLBACK __stdcall -typedef void SSGL_CALLBACK ssglCallbackFptr(void); +#ifdef WIN32 +# define SSGL_CALLBACK __stdcall +#else +# define SSGL_CALLBACK +#endif +extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(void); } void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p); void ssglFillPolygon(SPolygon *p); void ssglFillMesh(RgbColor color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2); diff --git a/ui.h b/ui.h index 502108b..c3a1d32 100644 --- a/ui.h +++ b/ui.h @@ -344,10 +344,12 @@ public: MNU_NEAREST_ORTHO, MNU_NEAREST_ISO, MNU_CENTER_VIEW, - MNU_SHOW_TEXT_WND, + MNU_SHOW_MENU_BAR, MNU_SHOW_TOOLBAR, + MNU_SHOW_TEXT_WND, MNU_UNITS_INCHES, MNU_UNITS_MM, + MNU_FULL_SCREEN, // Edit MNU_UNDO, MNU_REDO, diff --git a/win32/w32main.cpp b/win32/w32main.cpp index acb0aa7..0d103b1 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -597,6 +597,16 @@ static bool ProcessKeyDown(WPARAM wParam) return false; } +void ToggleMenuBar(void) +{ + // Implement me +} +bool MenuBarIsVisible(void) +{ + // Implement me + return true; +} + void ShowTextWindow(bool visible) { ShowWindow(TextWnd, visible ? SW_SHOWNOACTIVATE : SW_HIDE); @@ -640,6 +650,16 @@ void InvalidateGraphics(void) InvalidateRect(GraphicsWnd, NULL, false); } +void ToggleFullScreen(void) +{ + // Implement me +} +bool FullScreenIsActive(void) +{ + // Implement me + return false; +} + int32_t GetMilliseconds(void) { LARGE_INTEGER t, f;