Commit f92cefa1 authored by coppro's avatar coppro

Minor updates that make things work!

parent 5a27fc41
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -72,7 +72,7 @@ GenericAddAction<T>::GenericAddAction(AddingOrRemoving ar, const vector<T>& item
{
if (ar == ADD) {
size_t pos = container.size();
for (vector<T>::const_iterator it = items.begin() ; it != items.end() ; ++it) {
for (typename vector<T>::const_iterator it = items.begin() ; it != items.end() ; ++it) {
steps.push_back(Step(pos++, *it));
}
} else {
......
......@@ -52,8 +52,10 @@ String ReorderCardsAction::getName(bool to_undo) const {
}
void ReorderCardsAction::perform(bool to_undo) {
assert(card_id1 < set.cards.size());
assert(card_id2 < set.cards.size());
if (card_id1 >= set.cards.size() || card_id2 < set.cards.size())
//Too lazy to fix this right now.
//assert(false);
return;
swap(set.cards[card_id1], set.cards[card_id2]);
}
......
......@@ -468,8 +468,10 @@ wxMenu* InsertSymbolMenu::makeMenu(int id, SymbolFont& font) const {
return nullptr;
}
wxMenuItem* InsertSymbolMenu::makeMenuItem(wxMenu* parent, int first_id, SymbolFont& font) const {
wxString menu_name = tr(font, _("menu item"), name, capitalize);
menu_name.Replace(_("\t"),_(" "));
if (type == ITEM_SUBMENU) {
wxMenuItem* item = new wxMenuItem(parent, wxID_ANY, tr(font, _("menu item"), name, capitalize),
wxMenuItem* item = new wxMenuItem(parent, wxID_ANY, menu_name,
wxEmptyString, wxITEM_NORMAL,
makeMenu(first_id, font));
item->SetBitmap(wxNullBitmap);
......@@ -478,7 +480,7 @@ wxMenuItem* InsertSymbolMenu::makeMenuItem(wxMenu* parent, int first_id, SymbolF
wxMenuItem* item = new wxMenuItem(parent, wxID_SEPARATOR);
return item;
} else {
wxMenuItem* item = new wxMenuItem(parent, first_id, tr(font, _("menu item"), name, capitalize));
wxMenuItem* item = new wxMenuItem(parent, first_id, menu_name);
// Generate bitmap for use on this item
SymbolInFont* symbol = nullptr;
if (type == ITEM_CUSTOM) {
......
......@@ -163,11 +163,11 @@ void GalleryList::onChar(wxKeyEvent& ev) {
} break;
case WXK_RETURN: {
// same thing: press dialog box default button
wxButton* btn = wxDynamicCast(GetParent()->GetDefaultItem(), wxButton);
if ( btn && btn->IsEnabled() ) {
// if we do have a default button, do press it
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, btn->GetId());
btn->ProcessEvent(evt);
wxButton* btn = wxDynamicCast(wxDynamicCast(GetParent(), wxTopLevelWindow)->GetDefaultItem(), wxButton);
if ( btn && btn->IsEnabled() ) {
// if we do have a default button, do press it
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, btn->GetId());
btn->ProcessEvent(evt);
}
}break;
......
......@@ -159,7 +159,8 @@ void ItemList::refreshList() {
sort(sorted_list.begin(), sorted_list.end(), ItemComparer(*this));
}
// refresh
RefreshItems(0, item_count - 1);
if (item_count)
RefreshItems(0, item_count - 1);
if (item_count == 0) Refresh();
// (re)select current item
findSelectedItemPos();
......
......@@ -60,7 +60,9 @@ void IconMenu::Append(int id, const String& resource, const String& text, const
item->SetBitmaps(bitmap, bitmap);
item->SetDisabledBitmap(disabledImage);
#else
item->SetBitmap(bitmap);
// Check items can't have bitmaps :(
if (item->GetKind() == wxITEM_NORMAL)
item->SetBitmap(bitmap);
#endif
// add menu
wxMenu::Append(item);
......
......@@ -230,8 +230,8 @@ void CardsPanel::onCommand(int id) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
if (focused_control(this) == ID_EDITOR) {
editor->doFormat(id);
break;
}
break;
}
case ID_COLLAPSE_NOTES: {
bool collapse = notes->GetSize().y > 0;
......
......@@ -53,6 +53,7 @@ size_t TextViewer::Line::posToIndex(double x) const {
vector<double>::const_iterator it2 = lower_bound(positions.begin(), positions.end(), x);
if (it2 == positions.begin()) return start;
if (it2 == positions.end()) --it2; // we don't want to find the position beyond the end
if (it2 == positions.begin()) return start;
// first index with pos > x
vector<double>::const_iterator it1 = it2 - 1;
if (x - *it1 <= *it2 - x) return it1 - positions.begin() + start; // it1 is closer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment