#ifndef UNDO_H #define UNDO_H #include #ifndef WX_PRECOMP #include #endif #include #include #include class MapeditFrame; class Undoable { public: Undoable(std::string title, std::function forward, std::function backward); virtual std::string getTitle() const; virtual void apply(); virtual void undo(); virtual void endChanges() {} protected: Undoable() {} std::string title; std::function forward; std::function backward; }; class UndoableTextBox : public wxTextCtrl { public: UndoableTextBox(); UndoableTextBox(wxWindow* parent, wxWindowID id, wxString startText, std::string undoType, MapeditFrame* realParent, wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize, long style = 0); private: class Undo : public Undoable { public: Undo(std::string title, wxString origText, UndoableTextBox& parent); void apply(); void undo(); void endChanges(); wxString origText; wxString newText; UndoableTextBox& parent; }; void Init(); void OnFocus(wxFocusEvent& event); void OnKillFocus(wxFocusEvent& event); void OnTextChange(wxCommandEvent& event); MapeditFrame* realParent; std::string undoText; wxString curText; std::shared_ptr undo; wxDECLARE_EVENT_TABLE(); }; #endif ref='/lingo-ap-tracker/tree/src/version.h?h=v2.0.0&id=22435b61c1633e4d7a4d47bd1a3f3f621d214b2f'>tree commit diff stats
blob: 805dc2d35e5b5768e0763c8986ae77150c7462bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef VERSION_H_C757E53C
#define VERSION_H_C757E53C

#include <iostream>
#include <regex>

struct Version {
  int major = 0;
  int minor = 0;
  int revision = 0;

  constexpr Version(int major_arg, int minor_arg, int rev_arg)
      : major(major_arg), minor(minor_arg), revision(rev_arg) {}

  Version(const std::string& ver_str) {
    const std::regex version_regex("v([0-9]*)\.([0-9]*)\.([0-9]*)");
    std::smatch version_match;

    if (std::regex_match(ver_str, version_match, version_regex)) {
      major = std::atoi(version_match[1].str().c_str());
      minor = std::atoi(version_match[2].str().c_str());
      revision = std::atoi(version_match[3].str().c_str());
    }
  }

  bool operator<(const Version& rhs) const {
    return (major < rhs.major) ||
           (major == rhs.major &&
            (minor < rhs.minor ||
             (minor == rhs.minor && revision < rhs.revision)));
  }
};

std::ostream& operator<<(std::ostream& out, const Version& ver) {
  return out << "v" << ver.major << "." << ver.minor << "." << ver.revision;
}

constexpr const Version kTrackerVersion = Version(0, 9, 0);

#endif /* end of include guard: VERSION_H_C757E53C */