/[svn]/gigedit/trunk/src/gigedit/scripteditor.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/scripteditor.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3286 - (show annotations) (download) (as text)
Thu Jun 22 10:54:10 2017 UTC (6 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4225 byte(s)
* Script Editor: strike through code blocks filtered out by the
  preprocessor.
* Visual refinements of hatched patterns.
* Bumped version (1.0.0.svn53).

1 /*
2 Copyright (c) 2014-2017 Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #ifndef GIGEDIT_SCRIPTEDITOR_H
9 #define GIGEDIT_SCRIPTEDITOR_H
10
11 #ifdef LIBGIG_HEADER_FILE
12 # include LIBGIG_HEADER_FILE(gig.h)
13 #else
14 # include <gig.h>
15 #endif
16
17 #include <gtkmm.h>
18 #if HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 #include "compat.h"
22 #include <gtkmm/uimanager.h>
23 #include <gtkmm/actiongroup.h>
24 #include "ManagedWindow.h"
25
26 // Should we use a very simple (and buggy) local NKSP syntax parser, or should
27 // we rather use the full featured NKSP syntax highlighting backend from
28 // liblinuxsampler for syntax highlighting of this text editor?
29 #if HAVE_LINUXSAMPLER
30 # define USE_LS_SCRIPTVM 1
31 #endif
32
33 #if USE_LS_SCRIPTVM
34 # ifdef LIBLINUXSAMPLER_HEADER_FILE
35 # include LIBLINUXSAMPLER_HEADER_FILE(scriptvm/ScriptVM.h)
36 # include LIBLINUXSAMPLER_HEADER_FILE(scriptvm/ScriptVMFactory.h)
37 # else
38 # include <linuxsampler/scriptvm/ScriptVM.h>
39 # include <linuxsampler/scriptvm/ScriptVMFactory.h>
40 # endif
41 #endif
42
43 class ScriptEditor : public ManagedWindow {
44 public:
45 ScriptEditor();
46 ~ScriptEditor();
47 void setScript(gig::Script* script);
48
49 sigc::signal<void, gig::Script*> signal_script_to_be_changed;
50 sigc::signal<void, gig::Script*> signal_script_changed;
51
52 // implementation for abstract methods of interface class "ManagedWindow"
53 virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->scriptEditorWindowX; }
54 virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->scriptEditorWindowY; }
55 virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->scriptEditorWindowW; }
56 virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->scriptEditorWindowH; }
57
58 protected:
59 Gtk::VBox m_vbox;
60 Gtk::HBox m_footerHBox;
61 Gtk::HBox m_statusHBox;
62 Gtk::HButtonBox m_buttonBox;
63 Gtk::ScrolledWindow m_scrolledWindow;
64 Glib::RefPtr<Gtk::TextBuffer> m_textBuffer;
65 Glib::RefPtr<Gtk::TextBuffer::TagTable> m_tagTable;
66 Glib::RefPtr<Gtk::TextBuffer::Tag> m_keywordTag;
67 Glib::RefPtr<Gtk::TextBuffer::Tag> m_eventTag;
68 Glib::RefPtr<Gtk::TextBuffer::Tag> m_variableTag;
69 Glib::RefPtr<Gtk::TextBuffer::Tag> m_functionTag;
70 Glib::RefPtr<Gtk::TextBuffer::Tag> m_numberTag;
71 Glib::RefPtr<Gtk::TextBuffer::Tag> m_stringTag;
72 Glib::RefPtr<Gtk::TextBuffer::Tag> m_commentTag;
73 Glib::RefPtr<Gtk::TextBuffer::Tag> m_preprocTag;
74 Glib::RefPtr<Gtk::TextBuffer::Tag> m_errorTag;
75 Glib::RefPtr<Gtk::TextBuffer::Tag> m_warningTag;
76 Glib::RefPtr<Gtk::TextBuffer::Tag> m_preprocCommentTag;
77 Gtk::TextView m_textView;
78 Gtk::Image m_statusImage;
79 Gtk::Label m_statusLabel;
80 Gtk::Button m_applyButton;
81 Gtk::Button m_cancelButton;
82
83 Glib::RefPtr<Gdk::Pixbuf> m_warningIcon;
84 Glib::RefPtr<Gdk::Pixbuf> m_errorIcon;
85 Glib::RefPtr<Gdk::Pixbuf> m_successIcon;
86
87 Glib::RefPtr<Gtk::ActionGroup> m_actionGroup;
88 Glib::RefPtr<Gtk::UIManager> m_uiManager;
89
90 gig::Script* m_script;
91 #if USE_LS_SCRIPTVM
92 LinuxSampler::ScriptVM* m_vm;
93 std::vector<LinuxSampler::ParserIssue> m_issues;
94 std::vector<LinuxSampler::ParserIssue> m_errors;
95 std::vector<LinuxSampler::ParserIssue> m_warnings;
96 std::vector<LinuxSampler::CodeBlock> m_preprocComments;
97 #endif
98
99 bool isModified() const;
100 void onButtonCancel();
101 void onButtonApply();
102 void onWindowHide();
103 void onTextInserted(const Gtk::TextBuffer::iterator& it, const Glib::ustring& txt, int length);
104 void onTextErased(const Gtk::TextBuffer::iterator& itStart, const Gtk::TextBuffer::iterator& itEnd);
105 void onModifiedChanged();
106 #if USE_LS_SCRIPTVM
107 void updateSyntaxHighlightingByVM();
108 void updateParserIssuesByVM();
109 LinuxSampler::ScriptVM* GetScriptVM();
110 void updateIssueTooltip(GdkEventMotion* e);
111 void updateStatusBar();
112 #endif
113 bool on_motion_notify_event(GdkEventMotion* e);
114 bool onWindowDelete(GdkEventAny* e);
115 void onMenuChangeFontSize();
116 int currentFontSize() const;
117 void setFontSize(int size, bool save);
118 };
119
120 #endif // GIGEDIT_SCRIPTEDITOR_H

  ViewVC Help
Powered by ViewVC