Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
d2b3e24f
Commit
d2b3e24f
authored
Jul 02, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multiple choice choices can be drawn as radio buttons instead of check boxes
parent
fa29cfb3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
3 deletions
+46
-3
src/data/field/choice.cpp
src/data/field/choice.cpp
+8
-2
src/data/field/choice.hpp
src/data/field/choice.hpp
+7
-0
src/gui/util.cpp
src/gui/util.cpp
+21
-0
src/gui/util.hpp
src/gui/util.hpp
+3
-0
src/gui/value/multiple_choice.cpp
src/gui/value/multiple_choice.cpp
+7
-1
No files found.
src/data/field/choice.cpp
View file @
d2b3e24f
...
...
@@ -49,11 +49,11 @@ IMPLEMENT_REFLECTION(ChoiceField) {
ChoiceField
::
Choice
::
Choice
()
:
first_id
(
0
)
,
line_below
(
false
),
enabled
(
true
)
,
line_below
(
false
),
enabled
(
true
)
,
type
(
CHOICE_TYPE_CHECK
)
{}
ChoiceField
::
Choice
::
Choice
(
const
String
&
name
)
:
name
(
name
),
first_id
(
0
)
,
line_below
(
false
),
enabled
(
true
)
,
line_below
(
false
),
enabled
(
true
)
,
type
(
CHOICE_TYPE_CHECK
)
{}
...
...
@@ -139,6 +139,11 @@ String ChoiceField::Choice::choiceNameNice(int id) const {
}
IMPLEMENT_REFLECTION_ENUM
(
ChoiceChoiceType
)
{
VALUE_N
(
"check"
,
CHOICE_TYPE_CHECK
);
VALUE_N
(
"radio"
,
CHOICE_TYPE_RADIO
);
}
IMPLEMENT_REFLECTION_NO_GET_MEMBER
(
ChoiceField
::
Choice
)
{
if
(
isGroup
()
||
line_below
||
enabled
.
isScripted
()
||
(
tag
.
reading
()
&&
tag
.
isComplex
()))
{
// complex values are groups
...
...
@@ -147,6 +152,7 @@ IMPLEMENT_REFLECTION_NO_GET_MEMBER(ChoiceField::Choice) {
REFLECT
(
choices
);
REFLECT
(
line_below
);
REFLECT
(
enabled
);
REFLECT
(
type
);
}
else
{
REFLECT_NAMELESS
(
name
);
}
...
...
src/data/field/choice.hpp
View file @
d2b3e24f
...
...
@@ -46,6 +46,12 @@ class ChoiceField : public Field {
DECLARE_REFLECTION
();
};
enum
ChoiceChoiceType
{
CHOICE_TYPE_CHECK
,
CHOICE_TYPE_RADIO
};
/// An item that can be chosen for this field
class
ChoiceField
::
Choice
:
public
IntrusivePtrBase
<
ChoiceField
::
Choice
>
{
public:
...
...
@@ -57,6 +63,7 @@ class ChoiceField::Choice : public IntrusivePtrBase<ChoiceField::Choice> {
vector
<
ChoiceP
>
choices
;
///< Choices and sub groups in this group
bool
line_below
;
///< Show a line after this item?
Scriptable
<
bool
>
enabled
;
///< Is this item enabled?
ChoiceChoiceType
type
;
///< How should this item be shown, only for multiple choice fields
/// First item-id in this group (can be the default item)
/** Item-ids are consecutive integers, a group uses all ids [first_id..lastId()).
* The top level group has first_id 0.
...
...
src/gui/util.cpp
View file @
d2b3e24f
...
...
@@ -214,3 +214,24 @@ void draw_checkbox(Window* win, DC& dc, const wxRect& rect, bool checked, bool e
dc
.
SetBrush
(
*
wxTRANSPARENT_BRUSH
);
dc
.
DrawRectangle
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
}
void
draw_radiobox
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
,
bool
checked
,
bool
enabled
)
{
#if wxUSE_UXTHEME && defined(__WXMSW__)
// TODO: Windows version?
#endif
// portable version
#if 1
// circle drawing on windows looks absolutely horrible
// so use rounded rectangles instead
dc
.
SetPen
(
wxSystemSettings
::
GetColour
(
enabled
?
wxSYS_COLOUR_WINDOWTEXT
:
wxSYS_COLOUR_GRAYTEXT
));
dc
.
SetBrush
(
*
wxTRANSPARENT_BRUSH
);
//dc.DrawEllipse(rect.x, rect.y, rect.width, rect.height);
dc
.
DrawRoundedRectangle
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
,
rect
.
width
*
0.5
-
1
);
if
(
checked
)
{
dc
.
SetBrush
(
wxSystemSettings
::
GetColour
(
enabled
?
wxSYS_COLOUR_WINDOWTEXT
:
wxSYS_COLOUR_GRAYTEXT
));
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
//dc.DrawEllipse(rect.x+2,rect.y+2,rect.width-4,rect.height-4);
dc
.
DrawRoundedRectangle
(
rect
.
x
+
3
,
rect
.
y
+
3
,
rect
.
width
-
6
,
rect
.
height
-
6
,
rect
.
width
*
0.5
-
4
);
}
#endif
}
src/gui/util.hpp
View file @
d2b3e24f
...
...
@@ -63,5 +63,8 @@ void draw_drop_down_arrow(Window* win, DC& dc, const wxRect& rect, bool active);
/// Draws a check box
void
draw_checkbox
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
,
bool
checked
,
bool
enabled
=
true
);
/// Draws a radio button
void
draw_radiobox
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
,
bool
checked
,
bool
enabled
=
true
);
// ----------------------------------------------------------------------------- : EOF
#endif
src/gui/value/multiple_choice.cpp
View file @
d2b3e24f
...
...
@@ -45,9 +45,11 @@ void DropDownMultipleChoiceList::select(size_t item) {
void
DropDownMultipleChoiceList
::
drawIcon
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
)
const
{
// is this item active/checked?
bool
active
=
false
;
bool
radio
=
false
;
if
(
!
isFieldDefault
(
item
))
{
ChoiceField
::
ChoiceP
choice
=
getChoice
(
item
);
active
=
dynamic_cast
<
MultipleChoiceValueEditor
&>
(
cve
).
active
[
choice
->
first_id
];
radio
=
choice
->
type
==
CHOICE_TYPE_RADIO
;
}
else
{
active
=
dynamic_cast
<
MultipleChoiceValueEditor
&>
(
cve
).
value
().
value
.
isDefault
();
}
...
...
@@ -56,7 +58,11 @@ void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, boo
dc
.
SetBrush
(
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_WINDOW
));
dc
.
DrawRectangle
(
x
,
y
,
16
,
16
);
wxRect
rect
=
RealRect
(
x
+
2
,
y
+
2
,
12
,
12
);
draw_checkbox
(
nullptr
,
dc
,
rect
,
active
,
itemEnabled
(
item
));
if
(
radio
)
{
draw_radiobox
(
nullptr
,
dc
,
rect
,
active
,
itemEnabled
(
item
));
}
else
{
draw_checkbox
(
nullptr
,
dc
,
rect
,
active
,
itemEnabled
(
item
));
}
// draw icon
DropDownChoiceListBase
::
drawIcon
(
dc
,
x
+
16
,
y
,
item
,
selected
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment