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-17 09:22:32 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \struct DispatchData
|
|
|
|
* \brief Data struct for dispatching calls to GTK thread (on idle)
|
|
|
|
*/
|
2021-02-11 14:37:05 -08:00
|
|
|
struct DispatchData;
|
2021-02-11 14:20:23 -08:00
|
|
|
|
2021-02-17 09:05:12 -08:00
|
|
|
/**
|
|
|
|
* \class Draw
|
|
|
|
* \brief Draw text area, where the document content will be displayed
|
|
|
|
*/
|
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-17 12:11:07 -08:00
|
|
|
void del();
|
2021-02-18 15:44:21 -08:00
|
|
|
void newDocument();
|
2021-02-19 10:38:05 -08:00
|
|
|
|
|
|
|
// Signals editor calls
|
2021-02-19 13:58:55 -08:00
|
|
|
void make_heading(int headingLevel);
|
2021-02-19 10:38:05 -08:00
|
|
|
void make_bold();
|
|
|
|
void make_italic();
|
|
|
|
void make_strikethrough();
|
|
|
|
void make_super();
|
|
|
|
void make_sub();
|
|
|
|
void make_quote();
|
2021-02-23 07:54:28 -08:00
|
|
|
void make_code();
|
2021-02-19 10:38:05 -08:00
|
|
|
void insert_link();
|
|
|
|
void insert_image();
|
|
|
|
void insert_bullet_list();
|
|
|
|
void insert_numbered_list();
|
|
|
|
void make_highlight();
|
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-18 15:44:21 -08:00
|
|
|
void disableEdit();
|
|
|
|
void enableEdit();
|
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);
|
2021-02-18 15:44:21 -08:00
|
|
|
void insertLink(const std::string &text, const std::string &url);
|
2021-02-15 08:10:13 -08:00
|
|
|
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);
|
|
|
|
|
2021-02-18 15:44:21 -08:00
|
|
|
void insertMarkupTextOnThread(const std::string &text);
|
|
|
|
void clearOnThread();
|
2021-02-15 08:10:13 -08:00
|
|
|
static gboolean insertTextIdle(struct DispatchData *data);
|
|
|
|
static gboolean insertLinkIdle(struct DispatchData *data);
|
2021-02-18 15:44:21 -08:00
|
|
|
static gboolean clearBufferIdle(GtkTextBuffer *textBuffer);
|
|
|
|
void clearBuffer();
|
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
|