diff options
author | danglassey <danglassey> | 2002-08-14 09:57:17 +0000 |
---|---|---|
committer | danglassey <danglassey> | 2002-08-14 09:57:17 +0000 |
commit | daa67ff1f728c07f2a116ee9a9f4505479ca6808 (patch) | |
tree | c224a537d30480002ae0560cc9104b543b4d1b5e /examples/X11 | |
parent | 6d6973e035aac5ec1676efccd5b8ada70c40b639 (diff) | |
download | sword-sf-cvs-daa67ff1f728c07f2a116ee9a9f4505479ca6808.tar.gz |
Initial import from crosswire CVS for syncingimport-1.1.1
Diffstat (limited to 'examples/X11')
-rw-r--r-- | examples/X11/gtk--/simplefrontend/simplefrontend.cpp | 93 | ||||
-rw-r--r-- | examples/X11/qt/simplefrontend/SimpleFrontEndProject.cpp | 75 |
2 files changed, 168 insertions, 0 deletions
diff --git a/examples/X11/gtk--/simplefrontend/simplefrontend.cpp b/examples/X11/gtk--/simplefrontend/simplefrontend.cpp new file mode 100644 index 0000000..ed5192a --- /dev/null +++ b/examples/X11/gtk--/simplefrontend/simplefrontend.cpp @@ -0,0 +1,93 @@ +#include <stdlib.h> +#include <stdio.h> + +#include <gtk--.h> + +#include <swmgr.h> + + +class SimpleFrontEnd : public Gtk_Window { + Gtk_Label l1; + Gtk_Label l2; + Gtk_Label l3; + Gtk_Entry kt; + Gtk_Combo cb; + Gtk_VBox *vb; + Gtk_Text *text; + SWMgr manager; +public: + SimpleFrontEnd() : l1("Module Name:"), l2("KeyText:"), l3(""), kt(), vb(new Gtk_VBox), text(new Gtk_Text) { + add(vb); + vb->pack_start(&l1); + vb->pack_start(&cb); + vb->pack_start(&l2); + vb->pack_start(&kt); + vb->pack_start(&l3); + vb->pack_start(text); + vb->show(); + l1.show(); + l2.show(); + l3.show(); + kt.show(); + cb.show(); + text->set_word_wrap(TRUE); + text->show(); + + connect_to_method(kt.changed,this,&keypress); + // use SWMgr to traverse installed modules and insert into QComboBox + + ModMap::iterator modIterator; + G_List cbItems; + + for (modIterator = manager.Modules.begin(); modIterator != manager.Modules.end(); modIterator++) + cbItems.append((void *)modIterator->first.c_str()); + cb.set_popdown_strings(cbItems); + + + } + + gint delete_event_impl(GdkEventAny*) { + Gtk_Main::instance()->quit(); return 0; + } + + void keypress() { + string keyText; + string modName; + ModMap::iterator it; + gint position=0; + + keyText = kt.get_text(); + modName = cb.entry.get_text(); + + it = manager.Modules.find(modName.c_str()); + if (it != manager.Modules.end()) { + it->second->SetKey(keyText.c_str()); + text->delete_text(0, text->get_length()); + text->insert_text((const char *)*it->second, strlen(*it->second), &position); + l3.set(it->second->KeyText()); + } + } + +}; + + +int main(int argc, char *argv[]) { + Gtk_Main m(&argc,&argv); + SimpleFrontEnd *t=new SimpleFrontEnd; + t->show(); + m.run(); + printf("After run!\n"); + return(EXIT_SUCCESS); +} + + + + + + + + + + + + diff --git a/examples/X11/qt/simplefrontend/SimpleFrontEndProject.cpp b/examples/X11/qt/simplefrontend/SimpleFrontEndProject.cpp new file mode 100644 index 0000000..3ddc77d --- /dev/null +++ b/examples/X11/qt/simplefrontend/SimpleFrontEndProject.cpp @@ -0,0 +1,75 @@ +/*********************************************** +** Source Dump From QtEZ http://qtez.zax.net/qtez +** --------------------------------------------- +** Dumped: Mon Sep 21 01:22:44 1998 +** To: /usr/src/sword/examples/X11/qt/simplefrontend/SimpleFrontEndProject.cpp +** By: root +***********************************************/ + +#include "/usr/src/sword/examples/X11/qt/simplefrontend/SimpleFrontEndProject.h" +#include <string> +#include <swmgr.h> + +SimpleFrontEndProject::SimpleFrontEndProject(QWidget *parent, char *name) + : QDialog(parent,name,FALSE,WStyle_Customize | WStyle_NormalBorder) +{ + resize(420,320); + + label2 = new QLabel(this, "label2"); + label2->setText("Module Name"); + label2->setAlignment(AlignLeft | AlignTop); + label2->setGeometry(21,6,115,28); + + label1 = new QLabel(this, "label1"); + label1->setText("KeyText"); + label1->setAlignment(AlignLeft | AlignTop); + label1->setGeometry(21,51,115,28); + + label3 = new QLabel(this, "label3"); + label3->setText("[ none ]"); + label3->setAlignment(AlignLeft | AlignTop); + label3->setGeometry(21,96,115,28); + + combo1 = new QComboBox((bool)0,this,"combo1"); + combo1->setGeometry(143,6,270,28); + + mlined1 = new QMultiLineEdit(this, "mlined1"); + mlined1->setGeometry(21,141,390,160); + mlined1->setReadOnly(TRUE); + + text1 = new QLineEdit(this, "text1"); + text1->setGeometry(143,50,270,28); + + QObject::connect(text1,SIGNAL(textChanged(const char *)), + this,SLOT(lookup(const char *))); + + QObject::connect(combo1,SIGNAL(activated(const char *)), + this,SLOT(lookup(const char *))); + +// use SWMgr to traverse installed modules and insert into QComboBox + + ModMap::iterator modIterator; + + for (modIterator = manager.Modules.begin(); modIterator != manager.Modules.end(); modIterator++) + combo1->insertItem(modIterator->first.c_str()); +} + +void +SimpleFrontEndProject::lookup(const char *) +{ + string keyText; + string modName; + ModMap::iterator it; + + keyText = text1->text(); + modName = combo1->currentText(); + + it = manager.Modules.find(modName.c_str()); + if (it != manager.Modules.end()) { + it->second->SetKey(keyText.c_str()); + mlined1->setText(*it->second); + label3->setText(it->second->KeyText()); + } + +} + |