mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
convert to CRLF line endings
This commit is contained in:
+143
-143
@@ -30,11 +30,11 @@
|
||||
#include <data/action/value.hpp>
|
||||
#include <script/functions/json.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <unordered_set>
|
||||
#include <fstream>
|
||||
#include <fstream>
|
||||
|
||||
DECLARE_POINTER_TYPE(ChoiceValue);
|
||||
|
||||
@@ -59,8 +59,8 @@ CardListBase* CardSelectEvent::getTheCardList() const {
|
||||
|
||||
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
||||
: ItemList(parent, id, additional_style, true)
|
||||
{
|
||||
drop_target = new CardListDropTarget(this);
|
||||
{
|
||||
drop_target = new CardListDropTarget(this);
|
||||
}
|
||||
|
||||
CardListBase::~CardListBase() {
|
||||
@@ -168,7 +168,7 @@ bool CardListBase::doCopy() {
|
||||
bool ok = wxTheClipboard->SetData(new CardsOnClipboard(set, _(""), cards_to_copy)); // ignore result
|
||||
wxTheClipboard->Close();
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::doCopyCardAndLinkedCards() {
|
||||
if (!canCopy()) return false;
|
||||
@@ -194,16 +194,16 @@ bool CardListBase::doCopyCardAndLinkedCards() {
|
||||
bool ok = wxTheClipboard->SetData(new CardsOnClipboard(set, _(""), cards_to_copy)); // ignore result
|
||||
wxTheClipboard->Close();
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::doPaste() {
|
||||
if (!canPaste()) return false;
|
||||
if (!wxTheClipboard->Open()) return false;
|
||||
bool ok = wxTheClipboard->GetData(*drop_target->data_object);
|
||||
wxTheClipboard->Close();
|
||||
if (ok) return parseData(false);
|
||||
wxTheClipboard->Close();
|
||||
if (ok) return parseData(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::doDelete() {
|
||||
// cards to delete
|
||||
@@ -213,7 +213,7 @@ bool CardListBase::doDelete() {
|
||||
// delete cards
|
||||
set->actions.addAction(make_unique<AddCardAction>(REMOVE, *set, cards_to_delete));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::doAddCSV() {
|
||||
AddCSVWindow wnd(this, set, true);
|
||||
@@ -231,7 +231,7 @@ bool CardListBase::doAddJSON() {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::doBulkModification() {
|
||||
BulkModificationWindow wnd(this, set, true);
|
||||
@@ -240,133 +240,133 @@ bool CardListBase::doBulkModification() {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CardListBase::parseUrl(String& url, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
size_t pos = url.find("URL=");
|
||||
if (pos != std::string::npos) {
|
||||
url = url.substr(pos+4);
|
||||
}
|
||||
if (!url.StartsWith(_("http"))) return false;
|
||||
|
||||
WebRequestWindow wnd(url);
|
||||
if (wnd.ShowModal() == wxID_OK) {
|
||||
const String& content_type = wnd.out.GetContentType();
|
||||
if (content_type.StartsWith(_("image"))) {
|
||||
Image img(*wnd.out.GetStream());
|
||||
if (img.IsOk()) {
|
||||
parseImage(img, out);
|
||||
}
|
||||
else {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("web request corrupted"));
|
||||
}
|
||||
}
|
||||
else if (content_type.StartsWith(_("text"))) {
|
||||
String text = wnd.out.AsString();
|
||||
parseText(text, out);
|
||||
}
|
||||
else {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("web request unsupported format"));
|
||||
}
|
||||
}
|
||||
return j < out.size();
|
||||
}
|
||||
}
|
||||
|
||||
bool CardListBase::parseFiles(wxArrayString& filenames, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
bool CardListBase::parseUrl(String& url, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
size_t pos = url.find("URL=");
|
||||
if (pos != std::string::npos) {
|
||||
url = url.substr(pos+4);
|
||||
}
|
||||
if (!url.StartsWith(_("http"))) return false;
|
||||
|
||||
WebRequestWindow wnd(url);
|
||||
if (wnd.ShowModal() == wxID_OK) {
|
||||
const String& content_type = wnd.out.GetContentType();
|
||||
if (content_type.StartsWith(_("image"))) {
|
||||
Image img(*wnd.out.GetStream());
|
||||
if (img.IsOk()) {
|
||||
parseImage(img, out);
|
||||
}
|
||||
else {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("web request corrupted"));
|
||||
}
|
||||
}
|
||||
else if (content_type.StartsWith(_("text"))) {
|
||||
String text = wnd.out.AsString();
|
||||
parseText(text, out);
|
||||
}
|
||||
else {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("web request unsupported format"));
|
||||
}
|
||||
}
|
||||
return j < out.size();
|
||||
}
|
||||
|
||||
bool CardListBase::parseFiles(wxArrayString& filenames, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
for (size_t i = 0; i < filenames.size(); i++) {
|
||||
// if it's an image file, try to get meta_data
|
||||
Image image_file;
|
||||
image_file.SetLoadFlags(image_file.GetLoadFlags() & ~wxImage::Load_Verbose);
|
||||
if (image_file.LoadFile(filenames[i])) {
|
||||
Image image_file;
|
||||
image_file.SetLoadFlags(image_file.GetLoadFlags() & ~wxImage::Load_Verbose);
|
||||
if (image_file.LoadFile(filenames[i])) {
|
||||
parseImage(image_file, out);
|
||||
} else {
|
||||
} else {
|
||||
// if it's an url, request the data
|
||||
std::ifstream ifs(filenames[i].ToStdString());
|
||||
std::ifstream ifs(filenames[i].ToStdString());
|
||||
if (ifs.bad() || ifs.fail() || !ifs.good() || !ifs.is_open()) continue;
|
||||
std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
wxString text(content);
|
||||
if (!parseUrl(text, out)) parseText(text, out);
|
||||
std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
wxString text(content);
|
||||
if (!parseUrl(text, out)) parseText(text, out);
|
||||
}
|
||||
}
|
||||
return j < out.size();
|
||||
}
|
||||
return j < out.size();
|
||||
}
|
||||
|
||||
bool CardListBase::parseImage(Image& image, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
if (image.HasOption(wxIMAGE_OPTION_PNG_DESCRIPTION)) {
|
||||
auto text = image.GetOption(wxIMAGE_OPTION_PNG_DESCRIPTION);
|
||||
parseText(text, out);
|
||||
// crop image rects to populate image fields
|
||||
|
||||
bool CardListBase::parseImage(Image& image, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
if (image.HasOption(wxIMAGE_OPTION_PNG_DESCRIPTION)) {
|
||||
auto text = image.GetOption(wxIMAGE_OPTION_PNG_DESCRIPTION);
|
||||
parseText(text, out);
|
||||
// crop image rects to populate image fields
|
||||
for (; j < out.size(); j++) {
|
||||
CardP& card = out[j];
|
||||
CardP& card = out[j];
|
||||
for (IndexMap<FieldP, ValueP>::iterator it = card->data.begin(); it != card->data.end(); it++) {
|
||||
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
|
||||
if (value && !value->filename.empty()) {
|
||||
wxRect rect = wxRect(0,0,0,0);
|
||||
int degrees = 0;
|
||||
value->filename.getExternalRect(rect, degrees);
|
||||
if (rect.width > 0 && rect.height > 0) {
|
||||
Image img = image.GetSubImage(rect);
|
||||
img = rotate_image(img, deg_to_rad(360-degrees));
|
||||
if (value && !value->filename.empty()) {
|
||||
wxRect rect = wxRect(0,0,0,0);
|
||||
int degrees = 0;
|
||||
value->filename.getExternalRect(rect, degrees);
|
||||
if (rect.width > 0 && rect.height > 0) {
|
||||
Image img = image.GetSubImage(rect);
|
||||
img = rotate_image(img, deg_to_rad(360-degrees));
|
||||
LocalFileName filename = set->newFileName("cropped_image", _(".png")); // a new unique name in the package
|
||||
img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG);
|
||||
value->filename = filename;
|
||||
}
|
||||
img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG);
|
||||
value->filename = filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return j < out.size();
|
||||
}
|
||||
|
||||
bool CardListBase::parseText(String& text, vector<CardP>& out) {
|
||||
}
|
||||
|
||||
bool CardListBase::parseText(String& text, vector<CardP>& out) {
|
||||
size_t j = out.size();
|
||||
if (size_t pos = text.find("<mse-card-data>") != wxString::npos) {
|
||||
text = text.substr(pos + 14, text.find("</mse-card-data>") - pos - 14);
|
||||
}
|
||||
try {
|
||||
ScriptValueP sv = json_to_mse(text, set.get());
|
||||
if (size_t pos = text.find("<mse-card-data>") != wxString::npos) {
|
||||
text = text.substr(pos + 14, text.find("</mse-card-data>") - pos - 14);
|
||||
}
|
||||
try {
|
||||
ScriptValueP sv = json_to_mse(text, set.get());
|
||||
if (sv->type() == SCRIPT_COLLECTION) {
|
||||
if (ScriptCustomCollection* custom = dynamic_cast<ScriptCustomCollection*>(sv.get())) {
|
||||
if (ScriptCustomCollection* custom = dynamic_cast<ScriptCustomCollection*>(sv.get())) {
|
||||
for (size_t i = 0; i < custom->value.size(); i++) {
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(custom->value[i].get())) {
|
||||
out.push_back(make_intrusive<Card>(*c->getValue()));
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(custom->value[i].get())) {
|
||||
out.push_back(make_intrusive<Card>(*c->getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(sv.get())) {
|
||||
out.push_back(make_intrusive<Card>(*c->getValue()));
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
// recreate images to populate image fields
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
// recreate images to populate image fields
|
||||
for (int k = j; k < out.size(); k++) {
|
||||
CardP& card = out[k];
|
||||
CardP& card = out[k];
|
||||
for (IndexMap<FieldP, ValueP>::iterator it = card->data.begin(); it != card->data.end(); it++) {
|
||||
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
|
||||
if (value) {
|
||||
Image img = value->filename.getExternalImage();
|
||||
if (img.IsOk()) {
|
||||
if (value) {
|
||||
Image img = value->filename.getExternalImage();
|
||||
if (img.IsOk()) {
|
||||
LocalFileName filename = set->newFileName(_("decoded_image"), _(".png")); // a new unique name in the package
|
||||
img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG);
|
||||
value->filename = filename;
|
||||
}
|
||||
img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG);
|
||||
value->filename = filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return j < out.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CardListBase::parseData(bool ignore_cards_from_own_card_list) {
|
||||
wxBusyCursor wait;
|
||||
wxDataFormat format = drop_target->data_object->GetReceivedFormat();
|
||||
wxDataObject *data = drop_target->data_object->GetObject(format);
|
||||
wxDataObject *data = drop_target->data_object->GetObject(format);
|
||||
vector<CardP> new_cards;
|
||||
|
||||
if (CardsDataObject* card_data = dynamic_cast<CardsDataObject*>(data)) {
|
||||
|
||||
if (CardsDataObject* card_data = dynamic_cast<CardsDataObject*>(data)) {
|
||||
String id = ignore_cards_from_own_card_list ? drop_target->ignored_id : _("");
|
||||
card_data->getCards(set, id, new_cards);
|
||||
}
|
||||
@@ -374,25 +374,25 @@ bool CardListBase::parseData(bool ignore_cards_from_own_card_list) {
|
||||
{
|
||||
case wxDF_FILENAME:
|
||||
{
|
||||
wxFileDataObject* file_data = static_cast<wxFileDataObject*>(data);
|
||||
wxArrayString filenames = file_data->GetFilenames();
|
||||
wxFileDataObject* file_data = static_cast<wxFileDataObject*>(data);
|
||||
wxArrayString filenames = file_data->GetFilenames();
|
||||
parseFiles(filenames, new_cards);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case wxDF_PNG:
|
||||
{
|
||||
wxImageDataObject* image_data = static_cast<wxImageDataObject*>(data);
|
||||
Image image = image_data->GetImage();
|
||||
wxImageDataObject* image_data = static_cast<wxImageDataObject*>(data);
|
||||
Image image = image_data->GetImage();
|
||||
parseImage(image, new_cards);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case wxDF_BITMAP:
|
||||
{
|
||||
{
|
||||
wxBitmapDataObject* bitmap_data = static_cast<wxBitmapDataObject*>(data);
|
||||
wxBitmap bitmap = bitmap_data->GetBitmap();
|
||||
Image image = bitmap.ConvertToImage();
|
||||
wxBitmap bitmap = bitmap_data->GetBitmap();
|
||||
Image image = bitmap.ConvertToImage();
|
||||
parseImage(image, new_cards);
|
||||
}
|
||||
break;
|
||||
@@ -401,24 +401,24 @@ bool CardListBase::parseData(bool ignore_cards_from_own_card_list) {
|
||||
case wxDF_TEXT:
|
||||
case wxDF_HTML:
|
||||
{
|
||||
wxTextDataObject* text_data = static_cast<wxTextDataObject*>(data);
|
||||
String text = text_data->GetText();
|
||||
wxTextDataObject* text_data = static_cast<wxTextDataObject*>(data);
|
||||
String text = text_data->GetText();
|
||||
if (!parseUrl(text, new_cards)) parseText(text, new_cards);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
{
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("unknown data format"));
|
||||
}
|
||||
}
|
||||
|
||||
if (new_cards.size() > 0) {
|
||||
set->actions.addAction(make_unique<AddCardAction>(ADD, *set, new_cards));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (new_cards.size() > 0) {
|
||||
set->actions.addAction(make_unique<AddCardAction>(ADD, *set, new_cards));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------- : CardListBase : Card linking
|
||||
|
||||
@@ -624,18 +624,18 @@ void CardListBase::onChar(wxKeyEvent& ev) {
|
||||
} else {
|
||||
ev.Skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardListBase::onBeginDrag(wxListEvent&) {
|
||||
vector<CardP> cards;
|
||||
getSelection(cards);
|
||||
String transaction_id = generate_uid();
|
||||
CardsOnClipboard* card_data = new CardsOnClipboard(set, transaction_id, cards);
|
||||
drop_target->ignored_id = transaction_id;
|
||||
void CardListBase::onBeginDrag(wxListEvent&) {
|
||||
vector<CardP> cards;
|
||||
getSelection(cards);
|
||||
String transaction_id = generate_uid();
|
||||
CardsOnClipboard* card_data = new CardsOnClipboard(set, transaction_id, cards);
|
||||
drop_target->ignored_id = transaction_id;
|
||||
wxDropSource drag_source(this);
|
||||
drag_source.SetData(*card_data);
|
||||
drag_source.DoDragDrop(wxDrag_CopyOnly);
|
||||
}
|
||||
}
|
||||
|
||||
void CardListBase::onDrag(wxMouseEvent& ev) {
|
||||
ev.Skip();
|
||||
@@ -679,31 +679,31 @@ void CardListBase::onItemActivate(wxListEvent& ev) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardListDropTarget
|
||||
|
||||
CardListDropTarget::CardListDropTarget(CardListBase* card_list)
|
||||
: card_list(card_list), ignored_id(_(""))
|
||||
{
|
||||
data_object = new wxDataObjectComposite();
|
||||
CardListDropTarget::CardListDropTarget(CardListBase* card_list)
|
||||
: card_list(card_list), ignored_id(_(""))
|
||||
{
|
||||
data_object = new wxDataObjectComposite();
|
||||
data_object->Add(new CardsDataObject(), true);
|
||||
data_object->Add(new wxFileDataObject());
|
||||
data_object->Add(new wxImageDataObject());
|
||||
data_object->Add(new wxTextDataObject());
|
||||
SetDataObject(data_object);
|
||||
SetDataObject(data_object);
|
||||
}
|
||||
|
||||
CardListDropTarget::~CardListDropTarget() {}
|
||||
|
||||
wxDragResult CardListDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult defaultDragResult) {
|
||||
if (!GetData()) return wxDragNone;
|
||||
if (!card_list->parseData(true)) return wxDragError;
|
||||
wxDragResult CardListDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult defaultDragResult) {
|
||||
if (!GetData()) return wxDragNone;
|
||||
if (!card_list->parseData(true)) return wxDragError;
|
||||
return wxDragCopy;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardListBase : Event table
|
||||
|
||||
BEGIN_EVENT_TABLE(CardListBase, ItemList)
|
||||
EVT_LIST_COL_RIGHT_CLICK (wxID_ANY, CardListBase::onColumnRightClick)
|
||||
EVT_LIST_COL_END_DRAG (wxID_ANY, CardListBase::onColumnResize)
|
||||
EVT_LIST_ITEM_ACTIVATED (wxID_ANY, CardListBase::onItemActivate)
|
||||
EVT_LIST_ITEM_ACTIVATED (wxID_ANY, CardListBase::onItemActivate)
|
||||
EVT_LIST_BEGIN_DRAG (wxID_ANY, CardListBase::onBeginDrag)
|
||||
EVT_CHAR ( CardListBase::onChar)
|
||||
EVT_MOTION ( CardListBase::onDrag)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <gui/control/item_list.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <wx/dnd.h>
|
||||
#include <wx/dnd.h>
|
||||
|
||||
DECLARE_POINTER_TYPE(ChoiceField);
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
inline void setCard(const CardP& card, bool event = false) { selectItem(card, true, event); }
|
||||
|
||||
// --------------------------------------------------- : Clipboard and Drag'n'Drop
|
||||
|
||||
CardListDropTarget* drop_target;
|
||||
|
||||
CardListDropTarget* drop_target;
|
||||
|
||||
bool canCut() const override;
|
||||
bool canCopy() const override;
|
||||
@@ -81,20 +81,20 @@ public:
|
||||
bool doCopy() override;
|
||||
bool doCopyCardAndLinkedCards();
|
||||
bool doPaste() override;
|
||||
bool doDelete() override;
|
||||
|
||||
bool doDelete() override;
|
||||
|
||||
// Try to perform a bulk operation, return success
|
||||
bool doAddCSV();
|
||||
bool doAddJSON();
|
||||
bool doAddJSON();
|
||||
|
||||
bool doBulkModification();
|
||||
|
||||
// Look for cards inside some given data
|
||||
bool parseData(bool ignore_cards_from_own_card_list);
|
||||
bool parseUrl (String& url, vector<CardP>& out);
|
||||
bool parseFiles(wxArrayString& filenames, vector<CardP>& out);
|
||||
bool parseText (String& text, vector<CardP>& out);
|
||||
bool parseImage(Image& image, vector<CardP>& out);
|
||||
|
||||
// Look for cards inside some given data
|
||||
bool parseData(bool ignore_cards_from_own_card_list);
|
||||
bool parseUrl (String& url, vector<CardP>& out);
|
||||
bool parseFiles(wxArrayString& filenames, vector<CardP>& out);
|
||||
bool parseText (String& text, vector<CardP>& out);
|
||||
bool parseImage(Image& image, vector<CardP>& out);
|
||||
|
||||
// --------------------------------------------------- : Card linking
|
||||
|
||||
@@ -170,7 +170,7 @@ private:
|
||||
void onBeginDrag (wxListEvent&);
|
||||
void onDrag (wxMouseEvent&);
|
||||
void onContextMenu (wxContextMenuEvent&);
|
||||
};
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Drag'n'Drop
|
||||
|
||||
@@ -179,12 +179,12 @@ public:
|
||||
CardListDropTarget(CardListBase* card_list);
|
||||
~CardListDropTarget();
|
||||
|
||||
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult defaultDragResult) override;
|
||||
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult defaultDragResult) override;
|
||||
|
||||
wxDataObjectComposite* data_object; ///< the object that acquires the data from the Clipboard or a Drag'n'Drop
|
||||
wxDataObjectComposite* data_object; ///< the object that acquires the data from the Clipboard or a Drag'n'Drop
|
||||
|
||||
String ignored_id; ///< the id of the transaction we need to ignore (the one coming from our own card_list)
|
||||
private:
|
||||
private:
|
||||
CardListBase* card_list; ///< the card list we are the drop target of
|
||||
};
|
||||
|
||||
|
||||
@@ -42,22 +42,22 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
|
||||
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
|
||||
// draw short name
|
||||
wxFont font = wxFont(11,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_("Arial"));
|
||||
dc.SetFont(font);
|
||||
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 full name
|
||||
// draw full name
|
||||
font.SetPointSize(9);
|
||||
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
||||
dc.SetFont(font);
|
||||
dc.GetTextExtent(d->package->full_name, &w, &h);
|
||||
if (w > item_size.x) {
|
||||
font.SetPointSize(max(7,9*item_size.x/w));
|
||||
dc.GetTextExtent(d->package->full_name, &w, &h);
|
||||
if (w > item_size.x) {
|
||||
font.SetPointSize(max(7,9*item_size.x/w));
|
||||
dc.SetFont(font);
|
||||
dc.GetTextExtent(d->package->full_name, &w, &h);
|
||||
}
|
||||
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 + 9-font.GetPointSize()));
|
||||
dc.DestroyClippingRegion();
|
||||
@@ -92,9 +92,9 @@ void PackageList::showData(const String& pattern) {
|
||||
Image img;
|
||||
Bitmap bmp;
|
||||
if (stream && image_load_file(img, *stream)) {
|
||||
bmp = Bitmap(img);
|
||||
if (bmp.GetWidth() > 150 || bmp.GetHeight() > 150) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_1_("icon too large", p->relativeFilename()));
|
||||
bmp = Bitmap(img);
|
||||
if (bmp.GetWidth() > 150 || bmp.GetHeight() > 150) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_1_("icon too large", p->relativeFilename()));
|
||||
}
|
||||
}
|
||||
// add to list
|
||||
|
||||
Reference in New Issue
Block a user