2021-02-11 14:20:23 -08:00
|
|
|
#ifndef DRAW_H
|
|
|
|
#define DRAW_H
|
|
|
|
|
|
|
|
#include <gtkmm/textview.h>
|
2021-02-16 15:06:33 -08:00
|
|
|
#include <gtkmm/menu.h>
|
2021-02-12 09:07:37 -08:00
|
|
|
#include <pangomm/layout.h>
|
|
|
|
#include <cmark-gfm.h>
|
2021-02-11 14:20:23 -08:00
|
|
|
|
2021-02-15 10:03:07 -08:00
|
|
|
class MainWindow;
|
2021-02-11 14:37:05 -08:00
|
|
|
struct DispatchData;
|
2021-02-11 14:20:23 -08:00
|
|
|
|
|
|
|
class Draw : public Gtk::TextView
|
|
|
|
{
|
|
|
|
public:
|
2021-02-16 15:06:33 -08:00
|
|
|
sigc::signal<void> source_code;
|
|
|
|
|
2021-02-15 10:07:13 -08:00
|
|
|
explicit Draw(MainWindow &mainWindow);
|
2021-02-12 09:07:37 -08:00
|
|
|
void showMessage(const std::string &message, const std::string &detailed_info = "");
|
|
|
|
void showStartPage();
|
|
|
|
void processDocument(cmark_node *root_node);
|
2021-02-15 15:04:41 -08:00
|
|
|
void selectAll();
|
|
|
|
void cut();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
2021-02-11 14:20:23 -08:00
|
|
|
|
2021-02-15 10:03:07 -08:00
|
|
|
protected:
|
|
|
|
// Signals
|
|
|
|
void event_after(GdkEvent *ev);
|
2021-02-16 15:06:33 -08:00
|
|
|
void populate_popup(Gtk::Menu *menu);
|
2021-02-15 10:03:07 -08:00
|
|
|
|
2021-02-11 14:25:27 -08:00
|
|
|
private:
|
2021-02-15 10:03:07 -08:00
|
|
|
void followLink(Gtk::TextBuffer::iterator &iter);
|
|
|
|
|
2021-02-12 09:07:37 -08:00
|
|
|
void processNode(cmark_node *node, cmark_event_type ev_type);
|
2021-02-15 08:10:13 -08:00
|
|
|
// Helper functions for inserting text
|
|
|
|
void insertText(const std::string &text);
|
|
|
|
void insertHeading1(const std::string &text);
|
|
|
|
void insertHeading2(const std::string &text);
|
|
|
|
void insertHeading3(const std::string &text);
|
|
|
|
void insertHeading4(const std::string &text);
|
|
|
|
void insertHeading5(const std::string &text);
|
|
|
|
void insertHeading6(const std::string &text);
|
|
|
|
void insertItalic(const std::string &text);
|
|
|
|
void insertBold(const std::string &text);
|
|
|
|
void insertBoldItalic(const std::string &text);
|
|
|
|
|
|
|
|
void insertMarkupText(const std::string &text);
|
|
|
|
void insertLink(const std::string &text, const std::string &url);
|
2021-02-12 09:07:37 -08:00
|
|
|
void clear();
|
2021-02-15 08:10:13 -08:00
|
|
|
static gboolean insertTextIdle(struct DispatchData *data);
|
|
|
|
static gboolean insertLinkIdle(struct DispatchData *data);
|
2021-02-12 09:07:37 -08:00
|
|
|
static gboolean clearIdle(GtkTextBuffer *textBuffer);
|
2021-02-15 08:10:13 -08:00
|
|
|
static std::string const intToRoman(int num);
|
2021-02-12 09:07:37 -08:00
|
|
|
|
2021-02-15 10:03:07 -08:00
|
|
|
MainWindow &mainWindow;
|
2021-02-15 07:26:30 -08:00
|
|
|
GtkTextBuffer *buffer;
|
2021-02-12 09:07:37 -08:00
|
|
|
int fontSize;
|
|
|
|
std::string fontFamily;
|
|
|
|
int headingLevel;
|
|
|
|
int listLevel;
|
|
|
|
bool isBold;
|
|
|
|
bool isItalic;
|
|
|
|
int bulletListLevel;
|
|
|
|
int orderedListLevel;
|
|
|
|
bool isOrderedList;
|
2021-02-15 08:10:13 -08:00
|
|
|
bool isLink;
|
|
|
|
std::string linkURL;
|
2021-02-12 09:07:37 -08:00
|
|
|
std::map<int,int> orderedListCounters;
|
|
|
|
|
|
|
|
Pango::FontDescription defaultFont;
|
|
|
|
Pango::FontDescription bold;
|
|
|
|
Pango::FontDescription italic;
|
|
|
|
Pango::FontDescription boldItalic;
|
|
|
|
Pango::FontDescription heading1;
|
|
|
|
Pango::FontDescription heading2;
|
|
|
|
Pango::FontDescription heading3;
|
|
|
|
Pango::FontDescription heading4;
|
2021-02-12 14:30:39 -08:00
|
|
|
Pango::FontDescription heading5;
|
|
|
|
Pango::FontDescription heading6;
|
2021-02-11 14:20:23 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|