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.)
pull/3/head
Daniel Richard G 2013-09-19 00:59:18 -04:00
parent 30ca4ec8ac
commit 07b128b877
3 changed files with 11 additions and 5 deletions

View File

@ -531,8 +531,8 @@ void GraphicsWindow::EnsureValidActives(void) {
// And update the checked state for various menus // And update the checked state for various menus
bool locked = LockedInWorkplane(); bool locked = LockedInWorkplane();
CheckMenuById(MNU_FREE_IN_3D, !locked); RadioMenuById(MNU_FREE_IN_3D, !locked);
CheckMenuById(MNU_SEL_WORKPLANE, locked); RadioMenuById(MNU_SEL_WORKPLANE, locked);
SS.UndoEnableMenus(); SS.UndoEnableMenus();
@ -544,8 +544,8 @@ void GraphicsWindow::EnsureValidActives(void) {
SS.viewUnits = SolveSpace::UNIT_MM; SS.viewUnits = SolveSpace::UNIT_MM;
break; break;
} }
CheckMenuById(MNU_UNITS_MM, SS.viewUnits == SolveSpace::UNIT_MM); RadioMenuById(MNU_UNITS_MM, SS.viewUnits == SolveSpace::UNIT_MM);
CheckMenuById(MNU_UNITS_INCHES, SS.viewUnits == SolveSpace::UNIT_INCHES); RadioMenuById(MNU_UNITS_INCHES, SS.viewUnits == SolveSpace::UNIT_INCHES);
ShowTextWindow(SS.GW.showTextWindow); ShowTextWindow(SS.GW.showTextWindow);
CheckMenuById(MNU_SHOW_TEXT_WND, SS.GW.showTextWindow); CheckMenuById(MNU_SHOW_TEXT_WND, SS.GW.showTextWindow);

View File

@ -128,7 +128,8 @@ void LoadAllFontFiles(void);
void OpenWebsite(const char *url); void OpenWebsite(const char *url);
void CheckMenuById(int id, BOOL checked); 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 ShowGraphicsEditControl(int x, int y, char *s);
void HideGraphicsEditControl(void); void HideGraphicsEditControl(void);

View File

@ -936,6 +936,11 @@ void CheckMenuById(int id, BOOL checked)
{ {
MenuById(id, checked, TRUE); 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) void EnableMenuById(int id, BOOL enabled)
{ {
MenuById(id, enabled, FALSE); MenuById(id, enabled, FALSE);