diff options
| author | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-06-18 13:14:09 +0000 |
|---|---|---|
| committer | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-06-18 13:14:09 +0000 |
| commit | 74651351d05898e961941e98ad68043028ce3a87 (patch) | |
| tree | 712604789db98b301c7d23a0182aee356b850c15 | |
| parent | Fix layer selection so defs don't change layers, updated symbol text. (diff) | |
| download | inkscape-74651351d05898e961941e98ad68043028ce3a87.tar.gz inkscape-74651351d05898e961941e98ad68043028ce3a87.zip | |
First newFromTemplate commit. Some basic widgets mechanics
(bzr r12379.2.1)
| -rw-r--r-- | src/templates/main.cpp | 14 | ||||
| -rw-r--r-- | src/templates/newfromtemplate.cpp | 35 | ||||
| -rw-r--r-- | src/templates/newfromtemplate.h | 25 | ||||
| -rw-r--r-- | src/templates/preview.png | bin | 0 -> 2426 bytes | |||
| -rw-r--r-- | src/templates/statictemplateloadtab.cpp | 42 | ||||
| -rw-r--r-- | src/templates/statictemplateloadtab.h | 27 | ||||
| -rw-r--r-- | src/templates/templateloadtab.cpp | 101 | ||||
| -rw-r--r-- | src/templates/templateloadtab.h | 53 |
8 files changed, 297 insertions, 0 deletions
diff --git a/src/templates/main.cpp b/src/templates/main.cpp new file mode 100644 index 000000000..1ff93822c --- /dev/null +++ b/src/templates/main.cpp @@ -0,0 +1,14 @@ +#include <gtkmm/main.h> + +#include "newfromtemplate.h" + +int main (int argc, char *argv[]) +{ + Gtk::Main kit(argc, argv); + + NewFromTemplate dialog; + dialog.run(); + //Gtk::Main::run(dialog); + + return 0; +}
\ No newline at end of file diff --git a/src/templates/newfromtemplate.cpp b/src/templates/newfromtemplate.cpp new file mode 100644 index 000000000..3a215889d --- /dev/null +++ b/src/templates/newfromtemplate.cpp @@ -0,0 +1,35 @@ +#include "newfromtemplate.h" +#include "gtkmm/alignment.h" + + +NewFromTemplate::NewFromTemplate() : + createButton("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(mainWidget); + mainWidget.append_page(tab1, "Static Templates"); + mainWidget.append_page(tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(createButton); + + createButton.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::createFromTemplate() +{ + if (mainWidget.get_current_page() == 0) + tab1.createTemplate(); + else + tab2.createTemplate(); + + response(0); +}
\ No newline at end of file diff --git a/src/templates/newfromtemplate.h b/src/templates/newfromtemplate.h new file mode 100644 index 000000000..1a6ce555d --- /dev/null +++ b/src/templates/newfromtemplate.h @@ -0,0 +1,25 @@ +#ifndef GTKMM_NEW_FROM_TEMPLATE_H +#define GTKMM_TNEW_FROM_TEMPLATE_H + +#include <gtkmm/button.h> +#include <gtkmm/dialog.h> +#include <gtkmm/notebook.h> + +#include "templateloadtab.h" +#include "statictemplateloadtab.h" + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook mainWidget; + Gtk::Button createButton; + StaticTemplateLoadTab tab1; + TemplateLoadTab tab2; + + void createFromTemplate(); +}; +#endif
\ No newline at end of file diff --git a/src/templates/preview.png b/src/templates/preview.png Binary files differnew file mode 100644 index 000000000..c56a832a2 --- /dev/null +++ b/src/templates/preview.png diff --git a/src/templates/statictemplateloadtab.cpp b/src/templates/statictemplateloadtab.cpp new file mode 100644 index 000000000..b82338f16 --- /dev/null +++ b/src/templates/statictemplateloadtab.cpp @@ -0,0 +1,42 @@ +#include <gtkmm/alignment.h> +#include <gtkmm/button.h> +#include <gtkmm/label.h> +#include <iostream> + +#include "statictemplateloadtab.h" + + +StaticTemplateLoadTab::StaticTemplateLoadTab() : + moreInfoButton("More info"), + previewImage("preview.png"), + shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), + templateNameLabel("Template_name"), + templateAuthorLabel("by template_author") +{ + templateInfoColumn.pack_start(templateNameLabel, Gtk::PACK_SHRINK, 4); + templateInfoColumn.pack_start(templateAuthorLabel, Gtk::PACK_SHRINK, 0); + templateInfoColumn.pack_start(previewImage, Gtk::PACK_SHRINK, 15); + templateInfoColumn.pack_start(shortDescriptionLabel, Gtk::PACK_SHRINK, 4); + + shortDescriptionLabel.set_line_wrap(true); + shortDescriptionLabel.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(moreInfoButton); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::displayTemplateInfo() +{ + TemplateLoadTab::displayTemplateInfo(); + templateNameLabel.set_text(currentTemplate); +} + diff --git a/src/templates/statictemplateloadtab.h b/src/templates/statictemplateloadtab.h new file mode 100644 index 000000000..43d640b85 --- /dev/null +++ b/src/templates/statictemplateloadtab.h @@ -0,0 +1,27 @@ +#ifndef GTKMM_STATIC_TEMPLATE_LOAD_TAB_H +#define GTKMM_STATIC_TEMPLATE_LOAD_TAB_H + +#include <gtkmm/label.h> +#include <gtkmm/button.h> +#include <gtkmm/image.h> + +#include "templateloadtab.h" + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void displayTemplateInfo(); + + Gtk::Button moreInfoButton; + Gtk::Label shortDescriptionLabel; + Gtk::Label templateAuthorLabel; + Gtk::Label templateNameLabel; + Gtk::Image previewImage; +}; + +#endif
\ No newline at end of file diff --git a/src/templates/templateloadtab.cpp b/src/templates/templateloadtab.cpp new file mode 100644 index 000000000..734ac3eec --- /dev/null +++ b/src/templates/templateloadtab.cpp @@ -0,0 +1,101 @@ +#include <gtkmm/alignment.h> +#include <iostream> + +#include "templateloadtab.h" + + +TemplateLoadTab::TemplateLoadTab() +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + templatesColumn.pack_start(keywordsCombo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + initLists(); + + add(mainBox); + mainBox.pack_start(templatesColumn, Gtk::PACK_SHRINK, 20); + mainBox.pack_start(templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); + + templatesColumn.pack_start(templatesView, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = + templatesView.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::displayTemplateInfo)); + + keywordsCombo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::displayTemplateInfo() +{ + Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = templatesView.get_selection(); + if (templateSelectionRef->get_selected()) + currentTemplate = (*templateSelectionRef->get_selected())[templatesColumns.textValue]; +} + + +void TemplateLoadTab::initKeywordsList() +{ + keywordsCombo.append_text("All"); + keywordsCombo.set_active_text("All"); + + for (int i=0; i<10; ++i){ + + keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::initLists() +{ + templatesRef = Gtk::ListStore::create(templatesColumns); + templatesView.set_model(templatesRef); + templatesView.append_column("", templatesColumns.textValue); + templatesView.set_headers_visible(false); + + initKeywordsList(); + refreshTemplatesList(); +} + + +void TemplateLoadTab::keywordSelected() +{ + currentKeyword = keywordsCombo.get_active_text(); + refreshTemplatesList(); +} + + +void TemplateLoadTab::refreshTemplatesList() +{ + templatesRef->clear(); + for (int i=0; i<7; ++i){ + Gtk::TreeModel::iterator iter = templatesRef->append(); + Gtk::TreeModel::Row row = *iter; + row[templatesColumns.textValue] = "Template" + Glib::ustring::format(i); + } +}
\ No newline at end of file diff --git a/src/templates/templateloadtab.h b/src/templates/templateloadtab.h new file mode 100644 index 000000000..3947e25fb --- /dev/null +++ b/src/templates/templateloadtab.h @@ -0,0 +1,53 @@ +#ifndef GTKMM_TEMPLATE_LOAD_TAB_H +#define GTKMM_TEMPLATE_LOAD_TAB_H + +#include <gtkmm/box.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/frame.h> +#include <gtkmm/liststore.h> +#include <gtkmm/treeview.h> + + +class TemplateLoadTab : public Gtk::Frame +{ + +public: + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn<Glib::ustring> textValue; + }; + + Glib::ustring currentKeyword; + Glib::ustring currentTemplate; + + virtual void displayTemplateInfo(); + virtual void initKeywordsList(); + virtual void refreshTemplatesList(); + + void initLists(); + void keywordSelected(); + + Gtk::HBox mainBox; + Gtk::VBox templatesColumn; + Gtk::VBox templateInfoColumn; + + Gtk::ComboBoxText keywordsCombo; + + Gtk::TreeView templatesView; + Glib::RefPtr<Gtk::ListStore> templatesRef; + StringModelColumns templatesColumns; + +}; + +#endif // GTKMM_TEMPLATE_LOAD_TAB_H
\ No newline at end of file |
