mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
Change tabs to two spaces.
This commit is contained in:
@@ -17,97 +17,97 @@ DECLARE_TYPEOF_COLLECTION(PackagedP);
|
||||
// ----------------------------------------------------------------------------- : PackageList
|
||||
|
||||
PackageList::PackageList(Window* parent, int id, int direction, bool always_focused)
|
||||
: GalleryList(parent, id, direction, always_focused)
|
||||
: GalleryList(parent, id, direction, always_focused)
|
||||
{
|
||||
item_size = subcolumns[0].size = wxSize(125, 150);
|
||||
SetThemeEnabled(true);
|
||||
item_size = subcolumns[0].size = wxSize(125, 150);
|
||||
SetThemeEnabled(true);
|
||||
}
|
||||
|
||||
size_t PackageList::itemCount() const {
|
||||
return packages.size();
|
||||
return packages.size();
|
||||
}
|
||||
|
||||
void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
|
||||
dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
|
||||
PackageData& d = packages.at(item);
|
||||
RealRect rect(RealPoint(x,y),item_size);
|
||||
RealPoint pos;
|
||||
int w, h;
|
||||
// draw image
|
||||
if (d.image.Ok()) {
|
||||
dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true);
|
||||
}
|
||||
// draw short name
|
||||
dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial")));
|
||||
dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
|
||||
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||
dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
|
||||
// draw name
|
||||
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
dc.GetTextExtent(d.package->full_name, &w, &h);
|
||||
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||
dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
|
||||
dc.DestroyClippingRegion();
|
||||
dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
|
||||
PackageData& d = packages.at(item);
|
||||
RealRect rect(RealPoint(x,y),item_size);
|
||||
RealPoint pos;
|
||||
int w, h;
|
||||
// draw image
|
||||
if (d.image.Ok()) {
|
||||
dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true);
|
||||
}
|
||||
// draw short name
|
||||
dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial")));
|
||||
dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
|
||||
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||
dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
|
||||
// draw name
|
||||
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
dc.GetTextExtent(d.package->full_name, &w, &h);
|
||||
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||
dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
|
||||
struct PackageList::ComparePackagePosHint {
|
||||
bool operator () (const PackageData& a, const PackageData& b) {
|
||||
// use position_hints to determine order
|
||||
if (a.package->position_hint < b.package->position_hint) return true;
|
||||
if (a.package->position_hint > b.package->position_hint) return false;
|
||||
// ensure a deterministic order: use the names
|
||||
return a.package->name() < b.package->name();
|
||||
}
|
||||
bool operator () (const PackageData& a, const PackageData& b) {
|
||||
// use position_hints to determine order
|
||||
if (a.package->position_hint < b.package->position_hint) return true;
|
||||
if (a.package->position_hint > b.package->position_hint) return false;
|
||||
// ensure a deterministic order: use the names
|
||||
return a.package->name() < b.package->name();
|
||||
}
|
||||
};
|
||||
|
||||
void PackageList::showData(const String& pattern) {
|
||||
// clear
|
||||
packages.clear();
|
||||
// find matching packages
|
||||
vector<PackagedP> matching;
|
||||
{
|
||||
PROFILER(_("find matching packages"));
|
||||
package_manager.findMatching(pattern, matching);
|
||||
}
|
||||
FOR_EACH(p, matching) {
|
||||
// open image
|
||||
PROFILER(_("load package image"));
|
||||
InputStreamP stream = p->openIconFile();
|
||||
Image img;
|
||||
Bitmap bmp;
|
||||
if (stream && img.LoadFile(*stream)) {
|
||||
bmp = Bitmap(img);
|
||||
}
|
||||
// add to list
|
||||
packages.push_back(PackageData(p, bmp));
|
||||
}
|
||||
// sort list
|
||||
sort(packages.begin(), packages.end(), ComparePackagePosHint());
|
||||
// update list
|
||||
update();
|
||||
// clear
|
||||
packages.clear();
|
||||
// find matching packages
|
||||
vector<PackagedP> matching;
|
||||
{
|
||||
PROFILER(_("find matching packages"));
|
||||
package_manager.findMatching(pattern, matching);
|
||||
}
|
||||
FOR_EACH(p, matching) {
|
||||
// open image
|
||||
PROFILER(_("load package image"));
|
||||
InputStreamP stream = p->openIconFile();
|
||||
Image img;
|
||||
Bitmap bmp;
|
||||
if (stream && img.LoadFile(*stream)) {
|
||||
bmp = Bitmap(img);
|
||||
}
|
||||
// add to list
|
||||
packages.push_back(PackageData(p, bmp));
|
||||
}
|
||||
// sort list
|
||||
sort(packages.begin(), packages.end(), ComparePackagePosHint());
|
||||
// update list
|
||||
update();
|
||||
}
|
||||
|
||||
void PackageList::clear() {
|
||||
packages.clear();
|
||||
update();
|
||||
packages.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void PackageList::select(const String& name, bool send_event) {
|
||||
for (vector<PackageData>::const_iterator it = packages.begin() ; it != packages.end() ; ++it) {
|
||||
if (it->package->name() == name) {
|
||||
subcolumns[0].selection = it - packages.begin();
|
||||
update();
|
||||
if (send_event) {
|
||||
sendEvent(EVENT_GALLERY_SELECT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
subcolumns[0].selection = NO_SELECTION;
|
||||
update();
|
||||
return;
|
||||
for (vector<PackageData>::const_iterator it = packages.begin() ; it != packages.end() ; ++it) {
|
||||
if (it->package->name() == name) {
|
||||
subcolumns[0].selection = it - packages.begin();
|
||||
update();
|
||||
if (send_event) {
|
||||
sendEvent(EVENT_GALLERY_SELECT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
subcolumns[0].selection = NO_SELECTION;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
int PackageList::requiredWidth() const {
|
||||
return (item_size.x + SPACING) * (int)itemCount();
|
||||
return (item_size.x + SPACING) * (int)itemCount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user