aboutsummaryrefslogtreecommitdiff
path: root/src/CGEditor.hpp
blob: e8b52864db19cde74d90ed5497af415b946dc5f3 (plain)
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
41
42
43
44
#pragma once

#include "components/Margin.hpp"
#include "components/Menu.hpp"
#include "components/MoveTable.hpp"
#include "components/Scrollbar.hpp"

#include <string>

namespace cgeditor {

class CGEditor {
  /// @brief Prepare element for drawing and draw
  void CallDrawElement(Element);
  /// @brief Draw all elements of a component
  void DrawComponent(Component *);

  Scrollbar *SBV, *SBH;
  MoveTable *MT;
  Margin *MA;
  Menu *ME;

protected:
  Status status;
  /// @brief Draw the Chess Game Editor on the canvas using current status
  void Draw();
  /// @brief Process the events generated during the drawing
  bool ProcessEvents();
  /// @brief Synchronize the editor cache (must be called when game was modified from outside the editor)
  void SyncCache();
  /// @brief Draw an element on the canvas
  virtual void DrawElement(const Element &) = 0;
  /// @brief Handle event that occured during editor drawing
  virtual void HandleEvent(const Event &) = 0;
public:
  CGEditor();
  ~CGEditor();

  /// @brief Convert NAG id to symbol using the NagTable
  std::string GetNAGSymbol(const std::uint8_t) const;
  /// @brief Convert NAG symbol to id using the NagTable
  std::uint8_t GetNAGId(const std::string&) const;
};
} // namespace cgeditor