From 07b128b8770e4819c9ad3ff8f66c6ad5ac955171 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Thu, 19 Sep 2013 00:59:18 -0400 Subject: [PATCH] Define some menu-bar menu items as radio buttons Some menu items in the menu-bar are toggles (each representing an option that can be turned on or off independently), and some are 1-of-N selections (e.g. mm or inches), like tuner buttons on a car radio. Windows can draw an optional check-mark besides a menu item, and SolveSpace has been using this feature to implement both kinds of menu items, with the backend logic making them behave as a toggle or radio button as appropriate. Other GUI platforms can draw proper radio-button menu items that are distinct from toggles, however. To allow the platform-specific logic to tell the two kinds of menu items apart, this change adds the RadioMenuById() routine, and replaces the appropriate calls to CheckMenuById() with it. (Note that nothing is changed in the Windows GUI code; radio-menu items are still drawn with check-marks.) --- graphicswin.cpp | 8 ++++---- solvespace.h | 3 ++- win32/w32main.cpp | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/graphicswin.cpp b/graphicswin.cpp index f8279fd..0b1131c 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -531,8 +531,8 @@ void GraphicsWindow::EnsureValidActives(void) { // And update the checked state for various menus bool locked = LockedInWorkplane(); - CheckMenuById(MNU_FREE_IN_3D, !locked); - CheckMenuById(MNU_SEL_WORKPLANE, locked); + RadioMenuById(MNU_FREE_IN_3D, !locked); + RadioMenuById(MNU_SEL_WORKPLANE, locked); SS.UndoEnableMenus(); @@ -544,8 +544,8 @@ void GraphicsWindow::EnsureValidActives(void) { SS.viewUnits = SolveSpace::UNIT_MM; break; } - CheckMenuById(MNU_UNITS_MM, SS.viewUnits == SolveSpace::UNIT_MM); - CheckMenuById(MNU_UNITS_INCHES, SS.viewUnits == SolveSpace::UNIT_INCHES); + RadioMenuById(MNU_UNITS_MM, SS.viewUnits == SolveSpace::UNIT_MM); + RadioMenuById(MNU_UNITS_INCHES, SS.viewUnits == SolveSpace::UNIT_INCHES); ShowTextWindow(SS.GW.showTextWindow); CheckMenuById(MNU_SHOW_TEXT_WND, SS.GW.showTextWindow); diff --git a/solvespace.h b/solvespace.h index a5437fe..9a5c463 100644 --- a/solvespace.h +++ b/solvespace.h @@ -128,7 +128,8 @@ void LoadAllFontFiles(void); void OpenWebsite(const char *url); void CheckMenuById(int id, BOOL checked); -void EnableMenuById(int id, BOOL checked); +void RadioMenuById(int id, BOOL selected); +void EnableMenuById(int id, BOOL enabled); void ShowGraphicsEditControl(int x, int y, char *s); void HideGraphicsEditControl(void); diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 471b120..0729344 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -936,6 +936,11 @@ void CheckMenuById(int id, BOOL checked) { MenuById(id, checked, TRUE); } +void RadioMenuById(int id, BOOL selected) +{ + // Windows does not natively support radio-button menu items + MenuById(id, selected, TRUE); +} void EnableMenuById(int id, BOOL enabled) { MenuById(id, enabled, FALSE);