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
d4914fae
Commit
d4914fae
authored
Mar 22, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(partially working) keyword list
parent
dae1f4f1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
193 additions
and
40 deletions
+193
-40
src/gui/control/card_list.cpp
src/gui/control/card_list.cpp
+2
-7
src/gui/control/item_list.cpp
src/gui/control/item_list.cpp
+5
-2
src/gui/control/item_list.hpp
src/gui/control/item_list.hpp
+1
-1
src/gui/control/keyword_list.cpp
src/gui/control/keyword_list.cpp
+95
-0
src/gui/control/keyword_list.hpp
src/gui/control/keyword_list.hpp
+77
-0
src/gui/set/keywords_panel.cpp
src/gui/set/keywords_panel.cpp
+10
-30
src/gui/set/keywords_panel.hpp
src/gui/set/keywords_panel.hpp
+3
-0
No files found.
src/gui/control/card_list.cpp
View file @
d4914fae
...
@@ -167,13 +167,8 @@ bool CardListBase::compareItems(void* a, void* b) const {
...
@@ -167,13 +167,8 @@ bool CardListBase::compareItems(void* a, void* b) const {
FieldP
sort_field
=
column_fields
[
sort_by_column
];
FieldP
sort_field
=
column_fields
[
sort_by_column
];
ValueP
va
=
reinterpret_cast
<
Card
*>
(
a
)
->
data
[
sort_field
];
ValueP
va
=
reinterpret_cast
<
Card
*>
(
a
)
->
data
[
sort_field
];
ValueP
vb
=
reinterpret_cast
<
Card
*>
(
b
)
->
data
[
sort_field
];
ValueP
vb
=
reinterpret_cast
<
Card
*>
(
b
)
->
data
[
sort_field
];
if
(
sort_ascending
)
{
if
(
!
va
||
!
vb
)
return
va
<
vb
;
// got to do something, compare pointers
if
(
!
va
||
!
vb
)
return
va
<
vb
;
// got to do something, compare pointers
return
smart_less
(
va
->
toString
()
,
vb
->
toString
()
);
return
smart_less
(
va
->
toString
()
,
vb
->
toString
()
);
}
else
{
if
(
!
va
||
!
vb
)
return
vb
<
va
;
return
smart_less
(
vb
->
toString
()
,
va
->
toString
()
);
}
}
}
void
CardListBase
::
rebuild
()
{
void
CardListBase
::
rebuild
()
{
...
...
src/gui/control/item_list.cpp
View file @
d4914fae
...
@@ -93,7 +93,11 @@ struct ItemList::ItemComparer {
...
@@ -93,7 +93,11 @@ struct ItemList::ItemComparer {
ItemList
&
list
;
// 'this' pointer
ItemList
&
list
;
// 'this' pointer
// Compare two items using the current criterium and order
// Compare two items using the current criterium and order
bool
operator
()
(
const
VoidP
&
a
,
const
VoidP
&
b
)
{
bool
operator
()
(
const
VoidP
&
a
,
const
VoidP
&
b
)
{
return
list
.
compareItems
(
a
.
get
(),
b
.
get
());
if
(
list
.
sort_ascending
)
{
return
list
.
compareItems
(
a
.
get
(),
b
.
get
());
}
else
{
return
list
.
compareItems
(
b
.
get
(),
a
.
get
());
}
}
}
};
};
...
@@ -124,7 +128,6 @@ void ItemList::sortBy(long column, bool ascending) {
...
@@ -124,7 +128,6 @@ void ItemList::sortBy(long column, bool ascending) {
}
else
if
(
i
==
sort_by_column
)
{
}
else
if
(
i
==
sort_by_column
)
{
ClearColumnImage
(
i
);
ClearColumnImage
(
i
);
}
}
++
i
;
}
}
// sort list
// sort list
sort_by_column
=
column
;
sort_by_column
=
column
;
...
...
src/gui/control/item_list.hpp
View file @
d4914fae
...
@@ -45,7 +45,7 @@ class ItemList : public wxListView {
...
@@ -45,7 +45,7 @@ class ItemList : public wxListView {
/// Is sorting required?
/// Is sorting required?
virtual
bool
mustSort
()
const
{
return
false
;
}
virtual
bool
mustSort
()
const
{
return
false
;
}
/// Compare two items for <
/// Compare two items for <
based on sort_by_column (not on sort_ascending)
virtual
bool
compareItems
(
void
*
a
,
void
*
b
)
const
=
0
;
virtual
bool
compareItems
(
void
*
a
,
void
*
b
)
const
=
0
;
// --------------------------------------------------- : Protected interface
// --------------------------------------------------- : Protected interface
...
...
src/gui/control/keyword_list.cpp
0 → 100644
View file @
d4914fae
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/control/keyword_list.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
#include <data/keyword.hpp>
DECLARE_TYPEOF_COLLECTION
(
KeywordP
);
// ----------------------------------------------------------------------------- : Events
DEFINE_EVENT_TYPE
(
EVENT_KEYWORD_SELECT
);
// ----------------------------------------------------------------------------- : KeywordList
KeywordList
::
KeywordList
(
Window
*
parent
,
int
id
,
long
additional_style
)
:
ItemList
(
parent
,
id
,
additional_style
)
{
// Add columns
InsertColumn
(
0
,
_LABEL_
(
"keyword"
),
wxLIST_FORMAT_LEFT
,
100
);
InsertColumn
(
1
,
_LABEL_
(
"match"
),
wxLIST_FORMAT_LEFT
,
200
);
InsertColumn
(
2
,
_LABEL_
(
"mode"
),
wxLIST_FORMAT_LEFT
,
100
);
InsertColumn
(
3
,
_LABEL_
(
"uses"
),
wxLIST_FORMAT_RIGHT
,
80
);
InsertColumn
(
4
,
_LABEL_
(
"reminder"
),
wxLIST_FORMAT_LEFT
,
300
);
}
KeywordList
::~
KeywordList
()
{
storeColumns
();
}
void
KeywordList
::
storeColumns
()
{
// TODO
}
void
KeywordList
::
onBeforeChangeSet
()
{
storeColumns
();
}
void
KeywordList
::
onChangeSet
()
{
refreshList
();
}
void
KeywordList
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
//TYPE_CASE(action, AddKeywordAction) {
//}
}
// ----------------------------------------------------------------------------- : KeywordListBase : for ItemList
void
KeywordList
::
getItems
(
vector
<
VoidP
>&
out
)
const
{
FOR_EACH
(
k
,
set
->
keywords
)
{
out
.
push_back
(
k
);
}
FOR_EACH
(
k
,
set
->
game
->
keywords
)
{
out
.
push_back
(
k
);
}
}
void
KeywordList
::
sendEvent
()
{
KeywordSelectEvent
ev
(
getKeyword
());
ProcessEvent
(
ev
);
}
bool
KeywordList
::
compareItems
(
void
*
a
,
void
*
b
)
const
{
const
Keyword
&
ka
=
*
(
Keyword
*
)
a
;
const
Keyword
&
kb
=
*
(
Keyword
*
)
b
;
switch
(
sort_by_column
)
{
case
0
:
return
ka
.
keyword
<
kb
.
keyword
;
case
1
:
return
ka
.
match
<
kb
.
match
;
case
2
:
return
ka
.
mode
<
kb
.
mode
;
//case 3:
//case 4:
default:
// TODO: 3 and 4
return
ka
.
keyword
<
kb
.
keyword
;
}
}
// ----------------------------------------------------------------------------- : KeywordListBase : Item text
String
KeywordList
::
OnGetItemText
(
long
pos
,
long
col
)
const
{
const
Keyword
&
kw
=
*
getKeyword
(
pos
);
switch
(
col
)
{
case
0
:
return
kw
.
keyword
;
case
1
:
return
kw
.
match
;
case
2
:
return
kw
.
mode
;
case
3
:
return
_
(
"TODO"
);
case
4
:
return
_
(
"TODO"
);
default:
return
wxEmptyString
;
}
}
int
KeywordList
::
OnGetItemImage
(
long
pos
)
const
{
return
-
1
;
}
src/gui/control/keyword_list.hpp
0 → 100644
View file @
d4914fae
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_CONTROL_KEYWORD_LIST
#define HEADER_GUI_CONTROL_KEYWORD_LIST
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/control/item_list.hpp>
#include <data/keyword.hpp>
#include <data/set.hpp>
// ----------------------------------------------------------------------------- : Events
DECLARE_EVENT_TYPE
(
EVENT_KEYWORD_SELECT
,
<
not
used
>
)
/// Handle KeywordSelectEvents
#define EVT_KEYWORD_SELECT(id, handler) \
DECLARE_EVENT_TABLE_ENTRY
(
EVENT_KEYWORD_SELECT
,
id
,
-
1
,
\
(
wxObjectEventFunction
)
(
wxEventFunction
)
(
wxCommandEventFunction
)
\
(
void
(
wxEvtHandler
::*
)(
KeywordSelectEvent
&
))
(
&
handler
),
(
wxObject
*
)
NULL
),
/// The event of selecting a keyword
struct
KeywordSelectEvent
:
public
wxCommandEvent
{
KeywordP
keyword
;
///< The selected keyword
inline
KeywordSelectEvent
(
const
KeywordP
&
keyword
)
:
wxCommandEvent
(
EVENT_KEYWORD_SELECT
),
keyword
(
keyword
)
{}
};
// ----------------------------------------------------------------------------- : KeywordList
/// A control that lists the keywords in a set and its game
class
KeywordList
:
public
ItemList
,
public
SetView
{
public:
KeywordList
(
Window
*
parent
,
int
id
,
long
additional_style
=
0
);
~
KeywordList
();
// --------------------------------------------------- : Set stuff
virtual
void
onBeforeChangeSet
();
virtual
void
onChangeSet
();
virtual
void
onAction
(
const
Action
&
,
bool
);
// --------------------------------------------------- : Selection
inline
KeywordP
getKeyword
()
const
{
return
static_pointer_cast
<
Keyword
>
(
selected_item
);
}
inline
void
setKeyword
(
const
KeywordP
&
kw
)
{
selectItem
(
kw
,
true
,
false
);
}
// --------------------------------------------------- : The keywords
protected:
/// Get a list of all keywords
virtual
void
getItems
(
vector
<
VoidP
>&
out
)
const
;
/// Return the keyword at the given position in the sorted keyword list
inline
KeywordP
getKeyword
(
long
pos
)
const
{
return
static_pointer_cast
<
Keyword
>
(
getItem
(
pos
));
}
/// Send an 'item selected' event for the currently selected item (selected_item)
virtual
void
sendEvent
();
/// Compare cards
virtual
bool
compareItems
(
void
*
a
,
void
*
b
)
const
;
/// Get the text of an item in a specific column
/** Overrides a function from wxListCtrl */
virtual
String
OnGetItemText
(
long
pos
,
long
col
)
const
;
/// Get the image of an item, by default no image is used
/** Overrides a function from wxListCtrl */
virtual
int
OnGetItemImage
(
long
pos
)
const
;
private:
void
storeColumns
();
};
// ----------------------------------------------------------------------------- : EOF
#endif
src/gui/set/keywords_panel.cpp
View file @
d4914fae
...
@@ -7,48 +7,28 @@
...
@@ -7,48 +7,28 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <gui/set/keywords_panel.hpp>
#include <gui/set/keywords_panel.hpp>
#include <gui/control/keyword_list.hpp>
#include <data/keyword.hpp>
#include <data/keyword.hpp>
#include <wx/listctrl.h>
#include <wx/listctrl.h>
// ----------------------------------------------------------------------------- : KeywordsList
/// A control that lists the keywords in a set or game
class
KeywordList
:
public
wxListView
{
public:
KeywordList
(
Window
*
parent
,
int
id
);
/// Set the list of keywords to show
void
setData
(
vector
<
KeywordP
>&
dat
);
// --------------------------------------------------- : Selection
inline
KeywordP
getKeyword
()
const
{
return
selected_keyword
;
}
inline
void
setKeyword
(
const
KeywordP
&
kw
)
{
/* TODO */
}
bool
canSelectPrevious
()
const
;
bool
canSelectNext
()
const
;
void
selectPrevious
();
void
selectNext
();
protected:
/// Get the text of an item in a specific column
/** Overrides a function from wxListCtrl */
virtual
String
OnGetItemText
(
long
pos
,
long
col
)
const
;
private:
KeywordP
selected_keyword
;
long
selected_keyword_pos
;
};
// ----------------------------------------------------------------------------- : KeywordsPanel
// ----------------------------------------------------------------------------- : KeywordsPanel
KeywordsPanel
::
KeywordsPanel
(
Window
*
parent
,
int
id
)
KeywordsPanel
::
KeywordsPanel
(
Window
*
parent
,
int
id
)
:
SetWindowPanel
(
parent
,
id
)
:
SetWindowPanel
(
parent
,
id
)
{
{
// init controls
list
=
new
KeywordList
(
this
,
wxID_ANY
);
// init sizer
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
s
->
Add
(
new
wxStaticText
(
this
,
wxID_ANY
,
_
(
"Sorry, no keywords for now"
),
wxDefaultPosition
,
wxDefaultSize
,
wxALIGN_CENTER
),
1
,
wxALIGN_CENTER
);
// TODO: Remove
s
->
Add
(
list
,
1
,
wxEXPAND
);
//s->Add(new wxStaticText(this, wxID_ANY, _("Sorry, no keywords for now"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTER), 1, wxALIGN_CENTER); // TODO: Remove
/* wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
/* wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
s2->Add(list_active, 1, wxEXPAND);
s2->Add(list_active, 1, wxEXPAND);
s2->Add(list_inactive, 1, wxEXPAND);*/
s2->Add(list_inactive, 1, wxEXPAND);*/
s
->
SetSizeHints
(
this
);
s
->
SetSizeHints
(
this
);
SetSizer
(
s
);
SetSizer
(
s
);
}
}
void
KeywordsPanel
::
onChangeSet
()
{
list
->
setSet
(
set
);
}
\ No newline at end of file
src/gui/set/keywords_panel.hpp
View file @
d4914fae
...
@@ -20,6 +20,9 @@ class KeywordList;
...
@@ -20,6 +20,9 @@ class KeywordList;
class
KeywordsPanel
:
public
SetWindowPanel
{
class
KeywordsPanel
:
public
SetWindowPanel
{
public:
public:
KeywordsPanel
(
Window
*
parent
,
int
id
);
KeywordsPanel
(
Window
*
parent
,
int
id
);
virtual
void
onChangeSet
();
private:
private:
KeywordList
*
list
;
KeywordList
*
list
;
};
};
...
...
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