From beb9bbefd734ef81944318d2fa4860102ec05fa3 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 13 Oct 2005 15:47:00 +0000 Subject: [PATCH] prettified the search window, as per #1477 --- .../src/modules/widgets/etc/Makefile.in | 3 +- .../include/LiveSupport/Widgets/Notebook.h | 3 +- .../LiveSupport/Widgets/ScrolledNotebook.h | 105 ++++++++++++++++++ .../LiveSupport/Widgets/ScrolledWindow.h | 2 - .../modules/widgets/src/ScrolledNotebook.cxx | 67 +++++++++++ .../gLiveSupport/src/AdvancedSearchItem.cxx | 4 +- .../gLiveSupport/src/SearchWindow.cxx | 44 +++++--- 7 files changed, 205 insertions(+), 23 deletions(-) create mode 100644 livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledNotebook.h create mode 100644 livesupport/src/modules/widgets/src/ScrolledNotebook.cxx diff --git a/livesupport/src/modules/widgets/etc/Makefile.in b/livesupport/src/modules/widgets/etc/Makefile.in index a94441f4b..1f7bd1a25 100644 --- a/livesupport/src/modules/widgets/etc/Makefile.in +++ b/livesupport/src/modules/widgets/etc/Makefile.in @@ -148,7 +148,8 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \ ${TMP_DIR}/Colors.o \ ${TMP_DIR}/MessageWindow.o \ ${TMP_DIR}/DialogWindow.o \ - ${TMP_DIR}/ScrolledWindow.o + ${TMP_DIR}/ScrolledWindow.o \ + ${TMP_DIR}/ScrolledNotebook.o TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \ ${TMP_DIR}/main.o diff --git a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h index 68ddf3e96..faaa086ac 100644 --- a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h +++ b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h @@ -48,6 +48,7 @@ #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Widgets/CornerImages.h" +#include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ImageButton.h" @@ -307,7 +308,7 @@ class Notebook : public Gtk::Alignment * @param widget the widget that is the page itself. * @param label the label of the page. */ - void + virtual void appendPage(Gtk::Widget & widget, const Glib::ustring & label) throw (); }; diff --git a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledNotebook.h b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledNotebook.h new file mode 100644 index 000000000..80aa3419a --- /dev/null +++ b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledNotebook.h @@ -0,0 +1,105 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_ScrolledNotebook_h +#define LiveSupport_Widgets_ScrolledNotebook_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include "LiveSupport/Widgets/Notebook.h" + + +namespace LiveSupport { +namespace Widgets { + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A Widgets::Notebook subclass, which puts pages inside + * a Widgets::ScrolledWindow before appending them. + * + * @author $Author$ + * @version $Revision$ + */ +class ScrolledNotebook : public Notebook +{ + public: + /** + * Constructor. + */ + ScrolledNotebook() throw () + : Notebook() + { + } + + /** + * A virtual destructor. + */ + virtual + ~ScrolledNotebook(void) throw () + { + } + + /** + * Append a page to the notebook. + * + * @param widget the widget that is the page itself. + * @param label the label of the page. + */ + virtual void + appendPage(Gtk::Widget & widget, + const Glib::ustring & label) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_ScrolledNotebook_h + diff --git a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledWindow.h b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledWindow.h index 82ce945f6..79490b5eb 100644 --- a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledWindow.h +++ b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ScrolledWindow.h @@ -47,8 +47,6 @@ namespace LiveSupport { namespace Widgets { - -using namespace LiveSupport::Core; /* ================================================================ constants */ diff --git a/livesupport/src/modules/widgets/src/ScrolledNotebook.cxx b/livesupport/src/modules/widgets/src/ScrolledNotebook.cxx new file mode 100644 index 000000000..92fcf83a7 --- /dev/null +++ b/livesupport/src/modules/widgets/src/ScrolledNotebook.cxx @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include "LiveSupport/Widgets/ScrolledWindow.h" +#include "LiveSupport/Widgets/ScrolledNotebook.h" + + +using namespace LiveSupport::Widgets; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Append a page to the notebook + *----------------------------------------------------------------------------*/ +void +ScrolledNotebook :: appendPage(Gtk::Widget & widget, + const Glib::ustring & label) throw () +{ + ScrolledWindow * scrolledWindow = Gtk::manage(new ScrolledWindow); + scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + + scrolledWindow->add(widget); + + Notebook::appendPage(*scrolledWindow, label); +} + diff --git a/livesupport/src/products/gLiveSupport/src/AdvancedSearchItem.cxx b/livesupport/src/products/gLiveSupport/src/AdvancedSearchItem.cxx index 9070e81e6..6d6281855 100644 --- a/livesupport/src/products/gLiveSupport/src/AdvancedSearchItem.cxx +++ b/livesupport/src/products/gLiveSupport/src/AdvancedSearchItem.cxx @@ -80,10 +80,10 @@ AdvancedSearchItem :: AdvancedSearchItem( pack_start(*searchByLabel, Gtk::PACK_SHRINK, 5); metadataEntry = Gtk::manage(wf->createMetadataComboBoxText(metadataTypes)); - pack_start(*metadataEntry, Gtk::PACK_EXPAND_WIDGET, 5); + pack_start(*metadataEntry, Gtk::PACK_SHRINK, 5); operatorEntry = Gtk::manage(wf->createOperatorComboBoxText(bundle)); - pack_start(*operatorEntry, Gtk::PACK_EXPAND_WIDGET, 5); + pack_start(*operatorEntry, Gtk::PACK_SHRINK, 5); valueEntry = Gtk::manage(wf->createEntryBin()); pack_start(*valueEntry, Gtk::PACK_EXPAND_WIDGET, 5); diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx index 0816571ad..78183da4a 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx @@ -38,7 +38,7 @@ #include #include "LiveSupport/Widgets/WidgetFactory.h" -#include "LiveSupport/Widgets/Notebook.h" +#include "LiveSupport/Widgets/ScrolledNotebook.h" #include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ZebraTreeView.h" #include "SearchWindow.h" @@ -74,18 +74,18 @@ SearchWindow :: SearchWindow (Ptr::Ref gLiveSupport, LocalizedObject(bundle), gLiveSupport(gLiveSupport) { - Gtk::Box * simpleSearchView = constructSimpleSearchView(); - Gtk::Box * advancedSearchView = constructAdvancedSearchView(); - Gtk::Box * browseView = constructBrowseView(); + Gtk::Box * simpleSearchView = constructSimpleSearchView(); + Gtk::Box * advancedSearchView = constructAdvancedSearchView(); + Gtk::Box * browseView = constructBrowseView(); - Notebook * views = Gtk::manage(new Notebook); + ScrolledNotebook * searchInput = Gtk::manage(new ScrolledNotebook); try { set_title(*getResourceUstring("windowTitle")); - views->appendPage(*simpleSearchView, *getResourceUstring( + searchInput->appendPage(*simpleSearchView, *getResourceUstring( "simpleSearchTab")); - views->appendPage(*advancedSearchView, *getResourceUstring( + searchInput->appendPage(*advancedSearchView, *getResourceUstring( "advancedSearchTab")); - views->appendPage(*browseView, *getResourceUstring( + searchInput->appendPage(*browseView, *getResourceUstring( "browseTab")); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; @@ -94,19 +94,23 @@ SearchWindow :: SearchWindow (Ptr::Ref gLiveSupport, // set up the search results box ZebraTreeView * searchResultsView = constructSearchResultsView(); - Gtk::ScrolledWindow * scrolledWindow = Gtk::manage(new Gtk::ScrolledWindow); - scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - scrolledWindow->add(*searchResultsView); + Gtk::ScrolledWindow * searchResults = Gtk::manage( + new Gtk::ScrolledWindow); + searchResults->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + searchResults->add(*searchResultsView); + // set the sizes of the two parts of the window + searchInput ->set_size_request(750, 240); + searchResults->set_size_request(750, 300); + // put them in one big box Gtk::VBox * bigBox = Gtk::manage(new Gtk::VBox); - bigBox->pack_start(*views, Gtk::PACK_SHRINK); - bigBox->pack_start(*scrolledWindow); + bigBox->pack_start(*searchInput, Gtk::PACK_SHRINK); + bigBox->pack_start(*searchResults); add(*bigBox); // show set_name("searchWindow"); - set_default_size(600, 500); set_modal(false); property_window_position().set_value(Gtk::WIN_POS_NONE); @@ -148,12 +152,18 @@ SearchWindow :: constructSimpleSearchView(void) throw () *this, &SearchWindow::onSimpleSearch )); Gtk::HBox * entryBox = Gtk::manage(new Gtk::HBox); - entryBox->pack_start(*simpleSearchEntry, Gtk::PACK_SHRINK, 5); - entryBox->pack_start(*searchButton, Gtk::PACK_SHRINK, 5); + entryBox->pack_start(*simpleSearchEntry, Gtk::PACK_EXPAND_WIDGET, 5); + entryBox->pack_start(*searchButton, Gtk::PACK_SHRINK, 5); + + // make the search entry + button take up 50% of the window horizontally + Gtk::Alignment * entryAlignment = Gtk::manage(new Gtk::Alignment( + 0, 0, 0.5, 0)); + entryAlignment->add(*entryBox); // make a new box and pack the main components into it Gtk::VBox * view = Gtk::manage(new Gtk::VBox); - view->pack_start(*entryBox, Gtk::PACK_EXPAND_WIDGET, 5); + view->pack_start(*entryAlignment, Gtk::PACK_SHRINK, 5); + return view; }