GRAPHICS: MACGUI: introduce checkBoxAccess to determines what happens when user clicks the checkbox or radio button

This commit is contained in:
ysj1173886760 2021-07-28 17:41:16 +08:00
parent 601696ab1e
commit 36abd91264
2 changed files with 19 additions and 1 deletions

View File

@ -43,6 +43,7 @@ MacButton::MacButton(MacButtonType buttonType, TextAlign textAlignment, MacWidge
void MacButton::init() {
_invertInner = false;
_checkBoxType = 0;
_checkBoxAccess = 0;
switch (_buttonType) {
case kCheckBox:
@ -193,7 +194,22 @@ bool MacButton::processEvent(Common::Event &event) {
break;
case Common::EVENT_LBUTTONUP:
setActive(false);
_invertInner = !_invertInner;
switch (_checkBoxAccess) {
case 0:
_invertInner = !_invertInner;
break;
case 1:
_invertInner = true;
break;
case 2:
// no op, type 2 will prevent user from setting checkboxes
break;
default:
warning("MacButton::processEvent can not handle checkBoxAccess with type %d", _checkBoxAccess);
break;
}
_wm->_hilitingWidget = false;
break;
default:

View File

@ -56,6 +56,7 @@ public:
void setHilite(bool hilite);
void setCheckBoxType(int type);
void setCheckBoxAccess(int type) { _checkBoxAccess = type; }
virtual bool draw(ManagedSurface *g, bool forceRedraw = false) override;
virtual bool draw(bool forceRedraw = false) override;
@ -70,6 +71,7 @@ private:
MacPlotData _pd;
bool _invertInner;
int _checkBoxType;
int _checkBoxAccess;
};
} // End of namespace Graphics