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
1e652532
Commit
1e652532
authored
Mar 22, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working MultipleChoiceValueEditor for checklist style
parent
783e2e31
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
17 deletions
+67
-17
src/data/action/value.cpp
src/data/action/value.cpp
+5
-4
src/data/action/value.hpp
src/data/action/value.hpp
+6
-4
src/gui/util.cpp
src/gui/util.cpp
+7
-5
src/gui/value/multiple_choice.cpp
src/gui/value/multiple_choice.cpp
+40
-1
src/gui/value/multiple_choice.hpp
src/gui/value/multiple_choice.hpp
+4
-0
src/render/value/multiple_choice.cpp
src/render/value/multiple_choice.cpp
+2
-2
src/render/value/multiple_choice.hpp
src/render/value/multiple_choice.hpp
+3
-1
No files found.
src/data/action/value.cpp
View file @
1e652532
...
@@ -52,10 +52,11 @@ class SimpleValueAction : public ValueAction {
...
@@ -52,10 +52,11 @@ class SimpleValueAction : public ValueAction {
typename
T
::
ValueType
new_value
;
typename
T
::
ValueType
new_value
;
};
};
ValueAction
*
value_action
(
const
ChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
)
{
return
new
SimpleValueAction
<
ChoiceValue
,
&
ChoiceValue
::
value
,
true
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
ChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
)
{
return
new
SimpleValueAction
<
ChoiceValue
,
&
ChoiceValue
::
value
,
true
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
)
{
return
new
SimpleValueAction
<
ColorValue
,
&
ColorValue
::
value
,
true
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
MultipleChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
)
{
return
new
SimpleValueAction
<
MultipleChoiceValue
,
&
MultipleChoiceValue
::
value
,
false
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
ImageValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
ImageValue
,
&
ImageValue
::
filename
,
false
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
)
{
return
new
SimpleValueAction
<
ColorValue
,
&
ColorValue
::
value
,
true
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
SymbolValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
SymbolValue
,
&
SymbolValue
::
filename
,
false
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
ImageValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
ImageValue
,
&
ImageValue
::
filename
,
false
>
(
value
,
new_value
);
}
ValueAction
*
value_action
(
const
SymbolValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
SymbolValue
,
&
SymbolValue
::
filename
,
false
>
(
value
,
new_value
);
}
// ----------------------------------------------------------------------------- : Text
// ----------------------------------------------------------------------------- : Text
...
...
src/data/action/value.hpp
View file @
1e652532
...
@@ -24,6 +24,7 @@ DECLARE_POINTER_TYPE(Value);
...
@@ -24,6 +24,7 @@ DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE
(
Style
);
DECLARE_POINTER_TYPE
(
Style
);
DECLARE_POINTER_TYPE
(
TextValue
);
DECLARE_POINTER_TYPE
(
TextValue
);
DECLARE_POINTER_TYPE
(
ChoiceValue
);
DECLARE_POINTER_TYPE
(
ChoiceValue
);
DECLARE_POINTER_TYPE
(
MultipleChoiceValue
);
DECLARE_POINTER_TYPE
(
ColorValue
);
DECLARE_POINTER_TYPE
(
ColorValue
);
DECLARE_POINTER_TYPE
(
ImageValue
);
DECLARE_POINTER_TYPE
(
ImageValue
);
DECLARE_POINTER_TYPE
(
SymbolValue
);
DECLARE_POINTER_TYPE
(
SymbolValue
);
...
@@ -43,10 +44,11 @@ class ValueAction : public Action {
...
@@ -43,10 +44,11 @@ class ValueAction : public Action {
// ----------------------------------------------------------------------------- : Simple
// ----------------------------------------------------------------------------- : Simple
/// Action that updates a Value to a new value
/// Action that updates a Value to a new value
ValueAction
*
value_action
(
const
ChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
);
ValueAction
*
value_action
(
const
ChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
);
ValueAction
*
value_action
(
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
);
ValueAction
*
value_action
(
const
MultipleChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
);
ValueAction
*
value_action
(
const
ImageValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
);
ValueAction
*
value_action
(
const
SymbolValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
ImageValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
SymbolValueP
&
value
,
const
FileName
&
new_value
);
// ----------------------------------------------------------------------------- : Text
// ----------------------------------------------------------------------------- : Text
...
...
src/gui/util.cpp
View file @
1e652532
...
@@ -200,12 +200,14 @@ void draw_drop_down_arrow(Window* win, DC& dc, const wxRect& rect, bool active)
...
@@ -200,12 +200,14 @@ void draw_drop_down_arrow(Window* win, DC& dc, const wxRect& rect, bool active)
}
}
void
draw_checkbox
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
,
bool
checked
)
{
void
draw_checkbox
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
,
bool
checked
)
{
// TODO: Windows version?
#if wxUSE_UXTHEME && defined(__WXMSW__)
// portable
// TODO: Windows version?
#endif
// portable version
if
(
checked
)
{
dc
.
DrawCheckMark
(
wxRect
(
rect
.
x
-
1
,
rect
.
y
-
1
,
rect
.
width
+
2
,
rect
.
height
+
2
));
}
dc
.
SetPen
(
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_WINDOWTEXT
));
dc
.
SetPen
(
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_WINDOWTEXT
));
dc
.
SetBrush
(
*
wxTRANSPARENT_BRUSH
);
dc
.
SetBrush
(
*
wxTRANSPARENT_BRUSH
);
dc
.
DrawRectangle
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
dc
.
DrawRectangle
(
rect
.
x
,
rect
.
y
,
rect
.
width
,
rect
.
height
);
if
(
checked
)
{
dc
.
DrawCheckMark
(
rect
);
}
}
}
src/gui/value/multiple_choice.cpp
View file @
1e652532
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/multiple_choice.hpp>
#include <gui/value/multiple_choice.hpp>
#include <data/action/value.hpp>
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
...
@@ -14,7 +15,45 @@ IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
...
@@ -14,7 +15,45 @@ IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
void
MultipleChoiceValueEditor
::
determineSize
(
bool
force_fit
)
{
void
MultipleChoiceValueEditor
::
determineSize
(
bool
force_fit
)
{
if
(
!
nativeLook
())
return
;
if
(
!
nativeLook
())
return
;
// item height
item_height
=
16
;
// height depends on number of items and item height
// height depends on number of items and item height
int
item_count
=
field
().
choices
->
lastId
();
int
item_count
=
field
().
choices
->
lastId
();
style
().
height
=
item_count
*
20
;
style
().
height
=
item_count
*
item_height
;
}
bool
MultipleChoiceValueEditor
::
onLeftDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
// find item under cursor
if
(
style
().
render_style
&&
RENDER_CHECKLIST
)
{
int
id
=
(
pos
.
y
-
style
().
top
)
/
item_height
;
int
end
=
field
().
choices
->
lastId
();
if
(
id
>=
0
&&
id
<
end
)
{
toggle
(
id
);
return
true
;
}
}
else
{
// TODO
}
return
false
;
}
void
MultipleChoiceValueEditor
::
toggle
(
int
id
)
{
String
new_value
;
// old selection
vector
<
String
>
selected
;
value
().
get
(
selected
);
vector
<
String
>::
iterator
select_it
=
selected
.
begin
();
// copy selected choices to new value
int
end
=
field
().
choices
->
lastId
();
for
(
int
i
=
0
;
i
<
end
;
++
i
)
{
String
choice
=
field
().
choices
->
choiceName
(
i
);
bool
active
=
select_it
!=
selected
.
end
()
&&
*
select_it
==
choice
;
if
(
active
)
select_it
++
;
if
(
active
!=
(
i
==
id
))
{
if
(
!
new_value
.
empty
())
new_value
+=
_
(
", "
);
new_value
+=
choice
;
}
}
// store value
getSet
().
actions
.
add
(
value_action
(
valueP
(),
new_value
));
}
}
src/gui/value/multiple_choice.hpp
View file @
1e652532
...
@@ -21,6 +21,10 @@ class MultipleChoiceValueEditor : public MultipleChoiceValueViewer, public Value
...
@@ -21,6 +21,10 @@ class MultipleChoiceValueEditor : public MultipleChoiceValueViewer, public Value
DECLARE_VALUE_EDITOR
(
MultipleChoice
);
DECLARE_VALUE_EDITOR
(
MultipleChoice
);
virtual
void
determineSize
(
bool
force_fit
);
virtual
void
determineSize
(
bool
force_fit
);
virtual
bool
onLeftDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
);
private:
/// Toggle a choice or on or off
void
toggle
(
int
id
);
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
src/render/value/multiple_choice.cpp
View file @
1e652532
...
@@ -41,7 +41,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
...
@@ -41,7 +41,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
}
}
void
MultipleChoiceValueViewer
::
drawChoice
(
RotatedDC
&
dc
,
RealPoint
&
pos
,
const
String
&
choice
,
bool
active
)
{
void
MultipleChoiceValueViewer
::
drawChoice
(
RotatedDC
&
dc
,
RealPoint
&
pos
,
const
String
&
choice
,
bool
active
)
{
RealSize
size
;
RealSize
size
;
size
.
height
=
item_height
;
if
(
nativeLook
()
&&
(
style
().
render_style
&
RENDER_CHECKLIST
))
{
if
(
nativeLook
()
&&
(
style
().
render_style
&
RENDER_CHECKLIST
))
{
wxRect
rect
=
dc
.
tr
(
RealRect
(
pos
+
RealSize
(
1
,
1
),
RealSize
(
12
,
12
)));
wxRect
rect
=
dc
.
tr
(
RealRect
(
pos
+
RealSize
(
1
,
1
),
RealSize
(
12
,
12
)));
draw_checkbox
(
nullptr
,
dc
.
getDC
(),
rect
,
active
);
// TODO
draw_checkbox
(
nullptr
,
dc
.
getDC
(),
rect
,
active
);
// TODO
...
@@ -60,7 +60,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
...
@@ -60,7 +60,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
}
}
if
(
style
().
render_style
&
RENDER_TEXT
)
{
if
(
style
().
render_style
&
RENDER_TEXT
)
{
// draw text
// draw text
String
text
=
tr
(
*
viewer
.
stylesheet
,
choice
,
capitalize
(
choice
));
String
text
=
tr
(
*
viewer
.
stylesheet
,
choice
,
capitalize
_sentence
(
choice
));
RealSize
text_size
=
dc
.
GetTextExtent
(
text
);
RealSize
text_size
=
dc
.
GetTextExtent
(
text
);
dc
.
DrawText
(
text
,
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
text_size
,
dc
.
DrawText
(
text
,
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
text_size
,
RealRect
(
pos
+
RealSize
(
size
.
width
+
1
,
0
),
RealSize
(
0
,
size
.
height
))));
RealRect
(
pos
+
RealSize
(
size
.
width
+
1
,
0
),
RealSize
(
0
,
size
.
height
))));
...
...
src/render/value/multiple_choice.hpp
View file @
1e652532
...
@@ -18,9 +18,11 @@
...
@@ -18,9 +18,11 @@
/// Viewer that displays a multiple choice value
/// Viewer that displays a multiple choice value
class
MultipleChoiceValueViewer
:
public
ValueViewer
{
class
MultipleChoiceValueViewer
:
public
ValueViewer
{
public:
public:
DECLARE_VALUE_VIEWER
(
MultipleChoice
)
:
ValueViewer
(
parent
,
style
)
{}
DECLARE_VALUE_VIEWER
(
MultipleChoice
)
:
ValueViewer
(
parent
,
style
)
,
item_height
(
0
)
{}
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
protected:
double
item_height
;
///< Height of a single item, or 0 if non uniform
private:
private:
void
drawChoice
(
RotatedDC
&
dc
,
RealPoint
&
pos
,
const
String
&
choice
,
bool
active
=
true
);
void
drawChoice
(
RotatedDC
&
dc
,
RealPoint
&
pos
,
const
String
&
choice
,
bool
active
=
true
);
};
};
...
...
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