author | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
commit | 6d08277737e22b7a1527124623f3571969073ddf (patch) (side-by-side diff) | |
tree | 4129e674e21df767b31299e873dd44e33a308e1b /libopie2/opieui | |
parent | 8e28911f7199f4450ac5eef09482069f9b9caea2 (diff) | |
download | opie-6d08277737e22b7a1527124623f3571969073ddf.zip opie-6d08277737e22b7a1527124623f3571969073ddf.tar.gz opie-6d08277737e22b7a1527124623f3571969073ddf.tar.bz2 |
Move XML class to internal PIM
Add namespaces!!!
Opie::Core and Opie::Core::Private
Opie::Net and Opie::Net::Private
Opie::Ui and Opie::Ui::Private
Opie::MM and Opie::MM::Private
Opie::DB and Opie::DB::Private
PIM classes are not yet converted because we will do other work
on it as well
48 files changed, 378 insertions, 221 deletions
diff --git a/libopie2/opieui/big-screen/obigscreen_p.h b/libopie2/opieui/big-screen/obigscreen_p.h index db8fc83..a85a56c 100644 --- a/libopie2/opieui/big-screen/obigscreen_p.h +++ b/libopie2/opieui/big-screen/obigscreen_p.h @@ -1,28 +1,31 @@ #ifndef OPIE_BIG_SCREEN_PRIVATE #define OPIE_BIG_SCREEN_PRIVATE /* QT */ #include <qstring.h> class QWidget; -namespace Opie -{ +namespace Opie { +namespace Ui { +namespace Private{ struct OSplitterContainer { bool operator==( const OSplitterContainer& o) const { if (widget != o.widget ) return false; if (icon != o.icon ) return false; if (name != o.name ) return false; return true; } QWidget* widget; QString icon; QString name; }; -}; +} +} +} #endif diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index 89f3793..bcfd3a6 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp @@ -1,638 +1,639 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "osplitter.h" /* OPIE */ #include <opie2/otabwidget.h> /* QT */ #include <qvaluelist.h> #include <qvbox.h> -using namespace Opie; +using namespace Opie::Ui; +using namespace Opie::Ui::Private; /** * * This is the constructor of OSplitter * You might want to call setSizeChange to tell * OSplitter to change its layout when a specefic * mark was crossed. OSplitter sets a default value. * * You cann add widget with addWidget to the OSplitter. * OSplitter supports also grouping of Splitters where they * can share one OTabBar in small screen mode. This can be used * for email clients like vies but see the example. * * @param orient The orientation wether to layout horizontal or vertical * @param parent The parent of this widget * @param name The name passed on to QObject * @param fl Additional widgets flags passed to QWidget * * @short single c'tor of the OSplitter */ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) : QFrame( parent, name, fl ) { m_orient = orient; m_hbox = 0; m_size_policy = 330; setFontPropagation( AllChildren ); setPalettePropagation( AllChildren ); /* start by default with the tab widget */ m_tabWidget = 0; m_parentTab = 0; changeTab(); } /** * Destructor destructs this object and cleans up. All child * widgets will be deleted * @see addWidget */ OSplitter::~OSplitter() { qWarning("Deleted Splitter"); m_splitter.setAutoDelete( true ); m_splitter.clear(); delete m_hbox; delete m_tabWidget; } /** * Sets the label for the Splitter. This label will be used * if a parent splitter is arranged as TabWidget but * this splitter is in fullscreen mode. Then a tab with OSplitter::label() * and iconName() gets added. * * @param name The name of the Label */ void OSplitter::setLabel( const QString& name ) { m_name = name; } /** * @see setLabel but this is for the icon retrieved by Resource * * @param name The name of the icon in example ( "zoom" ) */ void OSplitter::setIconName( const QString& name ) { m_icon = name; } /** * returns the iconName * @see setIconName */ QString OSplitter::iconName()const { return m_icon; } /** * returns the label set with setLabel * @see setLabel */ QString OSplitter::label()const { return m_name; } /** * This function sets the size change policy of the splitter. * If this size marked is crossed the splitter will relayout. * Note: that depending on the set Orientation it'll either look * at the width or height. * Note: If you want to from side to side view to tabbed view you need * to make sure that the size you supply is not smaller than the minimum * size of your added widgets. Note that if you use widgets like QComboBoxes * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy * * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. * @return void */ void OSplitter::setSizeChange( int width_height ) { m_size_policy = width_height; QSize sz(width(), height() ); QResizeEvent ev(sz, sz ); resizeEvent(&ev); } /** * This functions allows to add another OSplitter and to share * the OTabBar in small screen mode. The ownerships gets transfered. * OSplitters are always added after normal widget items */ void OSplitter::addWidget( OSplitter* split ) { m_splitter.append( split ); /* * set tab widget */ if (m_tabWidget ) setTabWidget( m_parentTab ); else { - Opie::OSplitterContainer con; + OSplitterContainer con; con.widget =split; addToBox( con ); } } /* * If in a tab it should be removed * and if in a hbox the reparent kills it too */ /** * This removes the splitter again. You currently need to call this * before you delete or otherwise you can get mem corruption * or other weird behaviour. * Owner ship gets transfered back to you it's current parent * is 0 */ void OSplitter::removeWidget( OSplitter* split) { split->setTabWidget( 0 ); split->reparent( 0, 0, QPoint(0, 0) ); } /** * Adds a widget to the Splitter. The widgets gets inserted * at the end of either the Box or TabWidget. * Ownership gets transfered and the widgets gets reparented. * Note: icon and label is only available on small screensizes * if size is smaller than the mark * Warning: No null checking of the widget is done. Only on debug * a message will be outputtet * * @param wid The widget which will be added * @param icon The icon of the possible Tab * @param label The label of the possible Tab */ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { #ifdef DEBUG if (!wid ) { qWarning("Widget is not valid!"); return; } #endif - Opie::OSplitterContainer cont; + OSplitterContainer cont; cont.widget = wid; cont.icon =icon; cont.name = label; m_container.append( cont ); /* * */ if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) setTabWidget( m_parentTab ); else { if (m_hbox ) addToBox( cont ); else addToTab( cont ); } } /** * Removes the widget from the tab widgets if necessary. * OSplitter drops ownership of this widget and the widget * will be reparented i tto 0. * The widget will not be deleted. * * @param w The widget to be removed */ void OSplitter::removeWidget( QWidget* w) { ContainerList::Iterator it; for ( it = m_container.begin(); it != m_container.end(); ++it ) if ( (*it).widget == w ) break; if (it == m_container.end() ) return; /* only tab needs to be removed.. box recognizes it */ if ( !m_hbox ) removeFromTab( w ); /* Find reparent it and remove it from our list */ w->reparent( 0, 0, QPoint(0, 0)); it = m_container.remove( it ); } /** * This method will give focus to the widget. If in a tabwidget * the tabbar will be changed * * @param w The widget which will be set the current one */ void OSplitter::setCurrentWidget( QWidget* w) { if (m_tabWidget ) m_tabWidget->setCurrentTab( w ); // else // m_hbox->setFocus( w ); } /** * This is an overloaded member function and only differs in the * argument it takes. * Searches list of widgets for label. It'll pick the first label it finds * * @param label Label to look for. First match will be taken */ void OSplitter::setCurrentWidget( const QString& label ) { ContainerList::Iterator it; for (it = m_container.begin(); it != m_container.end(); ++it ) { if ( (*it).name == label ) { setCurrentWidget( (*it).widget ); break; } } } /** * This will only work when the TabWidget is active * If everything is visible this signal is kindly ignored * @see OTabWidget::setCurrentTab(int) * * @param tab The tab to make current */ void OSplitter::setCurrentWidget( int tab ) { if (m_tabWidget ) m_tabWidget->setCurrentTab( tab ); } /** * return the currently activated widget if in tab widget mode * or null because all widgets are visible */ QWidget* OSplitter::currentWidget() const { if (m_tabWidget) return m_tabWidget->currentWidget(); else if (m_parentTab ) return m_parentTab->currentWidget(); return 0l; } /* wrong */ #if 0 /** * @reimplented for internal reasons * returns the sizeHint of one of its sub widgets */ QSize OSplitter::sizeHint()const { if (m_parentTab ) return QFrame::sizeHint(); if (m_hbox ) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } QSize OSplitter::minimumSizeHint()const { if (m_parentTab ) return QFrame::minimumSizeHint(); if (m_hbox) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } #endif /** * @reimplemented for internal reasons */ void OSplitter::resizeEvent( QResizeEvent* res ) { QFrame::resizeEvent( res ); /* * */ // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); bool mode = true; qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); if ( res->size().width() > m_size_policy && m_orient == Horizontal ) { changeHBox(); mode = false; } else if ( (res->size().width() <= m_size_policy && m_orient == Horizontal ) || (res->size().height() <= m_size_policy && m_orient == Vertical ) ) { changeTab(); } else if ( res->size().height() > m_size_policy && m_orient == Vertical ) { qWarning("Changng to vbox %s", name() ); changeVBox(); mode = false; } emit sizeChanged(mode, m_orient ); } /* * Adds a container to a tab either the parent tab * or our own */ -void OSplitter::addToTab( const Opie::OSplitterContainer& con ) +void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con ) { QWidget *wid = con.widget; // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); if (m_parentTab ) m_parentTab->addTab( wid, con.icon, con.name ); else m_tabWidget->addTab( wid, con.icon, con.name ); } /* * adds a container to the box */ -void OSplitter::addToBox( const Opie::OSplitterContainer& con ) +void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con ) { QWidget* wid = con.widget; wid->reparent(m_hbox, 0, QPoint(0, 0) ); } /* * Removes a widget from the tab */ void OSplitter::removeFromTab( QWidget* wid ) { if (m_parentTab ) m_parentTab->removePage( wid ); else m_tabWidget->removePage( wid ); } /* * switches over to a OTabWidget layout * it is recursive */ void OSplitter::changeTab() { /* if we're the owner of the tab widget */ if (m_tabWidget ) { raise(); show(); m_tabWidget->setGeometry( frameRect() ); return; } qWarning(" New Tab Widget %s", name() ); /* * and add all widgets this will reparent them * delete m_hbox set it to 0 * */ OTabWidget *tab; if ( m_parentTab ) { hide(); tab = m_parentTab; /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ if (!m_container.isEmpty() ) { ContainerList::Iterator it = m_container.begin(); for (; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } else tab = m_tabWidget = new OTabWidget( this ); connect(tab, SIGNAL(currentChanged(QWidget*) ), this, SIGNAL(currentChanged(QWidget*) ) ); for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { qWarning("Widget is %s", (*it).name.latin1() ); addToTab( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { split->reparent(this, 0, QPoint(0, 0) ); split->setTabWidget( tab ); } delete m_hbox; m_hbox = 0; if (!m_tabWidget ) return; m_tabWidget->setGeometry( frameRect() ); m_tabWidget->show(); } /* * changes over to a box * this is recursive as well */ void OSplitter::changeHBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } qWarning("new HBox %s", name() ); m_hbox = new QHBox( this ); commonChangeBox(); } void OSplitter::changeVBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } qWarning("New VBOX %s", name() ); m_hbox = new QVBox( this ); commonChangeBox(); } /* * common box code * first remove and add children * the other splitters * it is recursive as well due the call to setTabWidget */ void OSplitter::commonChangeBox() { qWarning(" Name of Splitters is %s", name() ); for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ if (m_parentTab ) removeFromTab( (*it).widget ); qWarning("Adding to box %s", (*it).name.latin1() ); addToBox( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { /* tell them the world had changed */ split->setTabWidget( 0 ); - Opie::OSplitterContainer con; + OSplitterContainer con; con.widget = split; // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) // : static_cast<QWidget*>(split->m_hbox); addToBox( con ); } if (m_parentTab ) m_parentTab->addTab(m_hbox, iconName(), label() ); else { qWarning(" setting Box geometry for %s", name() ); m_hbox->setGeometry( frameRect() ); m_hbox->show(); delete m_tabWidget; m_tabWidget = 0; show(); // also show this widget } } /* * sets the tabwidget, removes tabs, and relayouts the widget */ void OSplitter::setTabWidget( OTabWidget* wid) { /* clean up cause m_parentTab will not be available for us */ if ( m_parentTab ) { if (m_hbox ) m_parentTab->removePage( m_hbox ); else if (!m_container.isEmpty() ) { ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } /* the parent Splitter changed so either make us indepent or dep */ m_parentTab = wid; QWidget *tab = m_tabWidget; QWidget *box = m_hbox; m_hbox = 0; m_tabWidget = 0; if ( layoutMode() ) changeTab(); else if (m_orient == Horizontal ) changeHBox(); else changeVBox(); /* our own crap is added and children from change* */ delete tab; delete box; } #if 0 void OSplitter::reparentAll() { if (m_container.isEmpty() ) return; ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) (*it).wid->reparent(0, 0, QPoint(0, 0) ); } #endif /** * @internal */ bool OSplitter::layoutMode()const { if ( size().width() > m_size_policy && m_orient == Horizontal ) { return false; } else if ( size().height() > m_size_policy && m_orient == Vertical ) { return false; } return true; } diff --git a/libopie2/opieui/big-screen/osplitter.h b/libopie2/opieui/big-screen/osplitter.h index 2daae7f..7b5ea53 100644 --- a/libopie2/opieui/big-screen/osplitter.h +++ b/libopie2/opieui/big-screen/osplitter.h @@ -1,150 +1,151 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + */ #ifndef OSPLITTER_H #define OSPLITTER_H #include "obigscreen_p.h" /* QT */ #include <qframe.h> #include <qlist.h> #include <qstring.h> #include <qvaluelist.h> class QHBox; //template class QValueList<Opie::OSplitterContainer>; /* * TODO * -check API docu * -one more example * -allow inserting at a position */ -namespace Opie -{ +namespace Opie{ +namespace Ui { class OTabWidget; /** * * If you've widgets that could be placed side by side but you think * on small resolutions is not enough place but it would really make sense * on bigger resolutions this class will help you. * You can add as many widgets you want to it. Set a poliy on which width/height it * should switch the layout. * You can either say to place widgets vertical or horizontal. * This class uses QHBox, QVBox and QTAbWidget internally. * OSplitter takes ownership of the widgets * * @since 1.2 * * @short a small dynamically changing its layout to store two or more widgets side by side * @version 0.1 * @author zecke */ class OSplitter : public QFrame { Q_OBJECT public: - typedef QValueList<Opie::OSplitterContainer> ContainerList; + typedef QValueList<Opie::Ui::Private::OSplitterContainer> ContainerList; OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, const char* name = 0, WFlags fl = 0 ); ~OSplitter(); void setLabel( const QString& name ); void setIconName( const QString& name ); QString label()const; QString iconName()const; void setSizeChange( int width_height ); void addWidget( OSplitter* splitter ); void addWidget( QWidget* wid, const QString& icon, const QString& label ); void removeWidget( QWidget* ); void removeWidget( OSplitter* ); void setCurrentWidget( QWidget* ); void setCurrentWidget( const QString& label ); void setCurrentWidget( int ); QWidget* currentWidget()const; signals: /** * Emitted if in tab and comes directly from the tab widget * */ void currentChanged( QWidget* ); /** * emitted whenever a border is crossed * true if in small screen mode * false if in bigscreen * this signal is emitted after the layout switch * @param b The layout mode * @param ori The orientation */ void sizeChanged( bool b, Orientation ori); public: // QSize sizeHint()const; // QSize minimumSizeHint()const; protected: void resizeEvent( QResizeEvent* ); private: /* true if OTabMode */ bool layoutMode()const; // void reparentAll(); void setTabWidget( OTabWidget*); - void addToTab( const Opie::OSplitterContainer& ); - void addToBox( const Opie::OSplitterContainer& ); + void addToTab( const Opie::Ui::Private::OSplitterContainer& ); + void addToBox( const Opie::Ui::Private::OSplitterContainer& ); void removeFromTab( QWidget* ); void changeTab(); void changeHBox(); void changeVBox(); void commonChangeBox(); QHBox *m_hbox; OTabWidget *m_tabWidget; OTabWidget *m_parentTab; Orientation m_orient; int m_size_policy; ContainerList m_container; QList<OSplitter> m_splitter; QString m_icon, m_name; struct Private; Private *d; }; -}; +} +} #endif diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp index 57e97e3..a0a6355 100644 --- a/libopie2/opieui/big-screen/owidgetstack.cpp +++ b/libopie2/opieui/big-screen/owidgetstack.cpp @@ -1,135 +1,135 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "owidgetstack.h" /* QT */ #include <qapplication.h> #include <qwidgetstack.h> -namespace { +namespace Opie { +namespace Ui { const int mode_size = 330; -} -using namespace Opie; + /** * This is the standard widget. For simple usage see the example. Normally this widget * is the central widget of a QMainWindow. * Use removeWidget before you delete a widget yourself. OWidgetStack does not * yet recognize removal of children. * * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. * Or you use QPEApplication::showMainWidget(). * @param name Name will be passed on to QObject * @param fl Additional window flags passed to QFrame. see @Qt::WFlags */ OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) : QFrame( parent, name, fl ) { m_last = m_mWidget = 0; m_forced = false; QApplication::desktop()->installEventFilter( this ); setFontPropagation ( AllChildren ); setPalettePropagation( AllChildren ); /* sets m_mode and initializes more */ /* if you change this call change switchTop as well */ m_stack = 0; switchStack(); } /** * The destructor. It deletes also all added widgets. * */ OWidgetStack::~OWidgetStack() { if (m_mode == BigScreen && !m_list.isEmpty() ) { QMap<int, QWidget*>::Iterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) delete it.data(); } m_list.clear(); } /** * return the mode of the desktop. There are currently two modes. SmallScreen * with a normal PDA resolution and BigScreen with resolutions greater than * 330 for width and height. * You can also force the mode this widget is in with forceMode() * Note that NoForce will be never returned from here */ enum OWidgetStack::Mode OWidgetStack::mode()const { return m_mode; } /** * You can also force one of the modes and then * this widget stops on listening to size changes. You * can revert to the scanning behaviour by setting mode * to NoForce */ void OWidgetStack::forceMode( enum Mode mode) { m_forced = mode != NoForce; /* we need to see which mode we're in */ if (!m_forced ) { if ( QApplication::desktop()->width() >= mode_size ) mode = BigScreen; else mode = SmallScreen; } switch( mode ) { case NoForce: case SmallScreen: switchStack(); break; case BigScreen: switchTop(); break; } m_mode = mode; } /** * Adds a widget to the stack. The first widget added is considered * to be the mainwindow. This is important because if Opie is in * BigScreen mode the sizeHint of the MainWindow will be returned. * In Small Screen the sizeHint of the QWidgetStack is returned. * See QWidgetStack::sizeHint. * This widget takes ownership of the widget and may even reparent. * All windows will be hidden * * @param wid The QWidget to be added * @param id An ID for the Widget. If the ID is duplicated the last set widget will be related to the id @@ -340,96 +340,99 @@ void OWidgetStack::resizeEvent( QResizeEvent* ev ) { * the mainwindow but you can change this with this * function. * If in BigScreen mode the current mainwindow will be reparented * and hidden. The position will be taken by the new one. * If the old MainWindow was hidden the new window will * also be hidden. If the window was visible the new mainwindow * will be made visible too and the old one hidden. If there * was no mainwindow it will be hidden as well. * * @param wid The new mainwindow */ void OWidgetStack::setMainWindow( QWidget* wid ) { if (m_mode == BigScreen ) { bool wasVisible = false; if (m_mWidget ) { wasVisible = !m_mWidget->isHidden(); /* hidden by default */ m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); } wid->reparent(this, 0, frameRect().topLeft() ); if (wasVisible) wid->show(); } m_mWidget = wid; } /** * this is an overloaded member and only differs * in the type of arguments. * @see setMainWindow(QWidget*) */ void OWidgetStack::setMainWindow( int id) { setMainWindow( widget( id ) ); } /* * this function switches to a stack ;) */ void OWidgetStack::switchStack() { if (m_stack ) { m_stack->setGeometry( frameRect() ); return; } m_mode = SmallScreen; m_stack = new QWidgetStack(this); connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), this, SIGNAL(aboutToShow(QWidget*) ) ); connect(m_stack, SIGNAL(aboutToShow(int) ), this, SIGNAL(aboutToShow(int) ) ); /* now reparent the widgets... luckily QWidgetSatck does most of the work */ if (m_list.isEmpty() ) return; QMap<int, QWidget*>::Iterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) m_stack->addWidget( it.data(), it.key() ); } /* * we will switch to top level mode * reparent the list of widgets and then delete the stack */ void OWidgetStack::switchTop() { m_mode = BigScreen; /* this works because it is guaranteed that switchStack was called at least once*/ if (!m_stack && m_mWidget) { m_mWidget->setGeometry( frameRect() ); return; }else if (!m_stack) return; if (!m_list.isEmpty() ) { QMap<int, QWidget*>::Iterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) { /* better than reparenting twice */ if ( it.data() == m_mWidget ) { m_mWidget->reparent(this, 0, frameRect().topLeft() ); m_mWidget->setGeometry( frameRect() ); m_mWidget->show(); }else /* ### FIXME we need to place the widget better */ it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); } } delete m_stack; m_stack = 0; } + +} +}
\ No newline at end of file diff --git a/libopie2/opieui/big-screen/owidgetstack.h b/libopie2/opieui/big-screen/owidgetstack.h index 53818c8..d2f9a9f 100644 --- a/libopie2/opieui/big-screen/owidgetstack.h +++ b/libopie2/opieui/big-screen/owidgetstack.h @@ -1,132 +1,133 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OWIDGETSTACK_H #define OWIDGETSTACK_H /* QT*/ #include <qframe.h> #include <qmap.h> class QWidgetStack; -namespace Opie -{ +namespace Opie { +namespace Ui { /** * * OWidgetStack is the answer to the problem of using Opie at different screen * sizes and to have a different behaviour. Most applications use a QWidgetStack * to supply a view on click. And by clicking the (X) you go back but this * behaviour feels strange on bigger screens. It's ok on smaller one because * one can't determine the difference. * This stack reads the default out of the size of the desktop widget but * can be forced to have either the one or the other behaviour. * The first widget added is considered the 'main' widget and its * sizeHint will be taking if in BigScreen mode. * In small screen mode this widget behaves exactly like a QWidgetStack and in BigScreen * mode it'll use the MainWindow as child of this widget and arranges the others as * hidden top level widgets. * * @version 0.1 * @author hOlgAr F. * @short Either a true stack or a list of top Level widgets */ class OWidgetStack : public QFrame { Q_OBJECT public: enum Mode { SmallScreen, BigScreen, NoForce }; OWidgetStack( QWidget* parent, const char* name = 0, WFlags fl = 0 ); ~OWidgetStack(); enum Mode mode()const; void forceMode( enum Mode ); void addWidget( QWidget* , int ); void removeWidget( QWidget* ); // QSizeHint sizeHint()const; // QSizeHint minimumSizeHint()const; QWidget *widget( int )const; int id( QWidget* )const; QWidget* visibleWidget() const; bool eventFilter( QObject*, QEvent* ); signals: /** * OWidgetStack monitors the Desktop Widget for * size changes if it recignizes a change size it'll * send a signal and adjust its mode. After the signal * was emitted. During the signal a call to mode() the * old mode will be returned. Note that if a size change happens * but no modeChange no signal will be emitted * * * @param mode The new mode of the desktop */ void modeChanged( enum Mode mode); /** * These two signals are emitted whenever we're about to * show one of the widgets */ void aboutToShow( QWidget* ); void aboutToShow( int ); public slots: void raiseWidget( int ); void raiseWidget( QWidget* ); void hideWidget( int ); void hideWidget( QWidget* ); void setMainWindow( QWidget* ); void setMainWindow( int ); protected: void resizeEvent( QResizeEvent* ); private: void switchStack(); void switchTop(); QMap<int, QWidget*> m_list; QWidgetStack *m_stack; QWidget *m_mWidget; QWidget *m_last; enum Mode m_mode; bool m_forced : 1; struct Private; Private *d; }; -}; +} +} #endif diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp index e7daead..beb4d6c 100644 --- a/libopie2/opieui/fileselector/ofiledialog.cpp +++ b/libopie2/opieui/fileselector/ofiledialog.cpp @@ -1,138 +1,138 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/ofiledialog.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> /* QT */ #include <qfileinfo.h> #include <qstring.h> #include <qapplication.h> #include <qlayout.h> -using namespace Opie; +using namespace Opie::Ui; namespace { /* * helper functions to load the start dir * and to save it * helper to extract the dir out of a file name */ /** * This method will use Config( argv[0] ); * @param key The group key used */ QString lastUsedDir( const QString& key ) { if ( qApp->argc() < 1 ) return QString::null; Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname cfg.setGroup( key ); return cfg.readEntry("LastDir", QPEApplication::documentDir() ); } void saveLastDir( const QString& key, const QString& file ) { if ( qApp->argc() < 1 ) return; Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); cfg.setGroup( key ); QFileInfo inf( file ); cfg.writeEntry("LastDir", inf.dirPath( true ) ); } }; /** * This constructs a modal dialog * * @param caption The caption of the dialog * @param wid The parent widget * @param mode The mode of the OFileSelector @see OFileSelector * @param selector The selector of the OFileSelector * @param dirName the dir or resource to start from * @param fileName a proposed or existing filename * @param mimetypes The mimeTypes */ OFileDialog::OFileDialog(const QString &caption, QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName, const QMap<QString,QStringList>& mimetypes ) : QDialog( wid, "OFileDialog", true ) { // QVBoxLayout *lay = new QVBoxLayout(this); //showMaximized(); QVBoxLayout *lay = new QVBoxLayout(this ); file = new OFileSelector(this , mode, selector, dirName, fileName, mimetypes ); lay->addWidget( file ); //lay->addWidget( file ); //showFullScreen(); setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); connect(file, SIGNAL(fileSelected(const QString&) ), this, SLOT(slotFileSelected(const QString&) ) ); connect(file, SIGNAL(ok() ), this, SLOT(slotSelectorOk()) ) ; connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); #if 0 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); #endif } /** * @returns the mimetype of the selected * currently it return QString::null */ QString OFileDialog::mimetype()const { return QString::null; } /** * @return the fileName */ QString OFileDialog::fileName()const { return file->selectedName(); } /** * return a DocLnk to the current file */ DocLnk OFileDialog::selectedDocument()const diff --git a/libopie2/opieui/fileselector/ofiledialog.h b/libopie2/opieui/fileselector/ofiledialog.h index 01a599b..dfecf3d 100644 --- a/libopie2/opieui/fileselector/ofiledialog.h +++ b/libopie2/opieui/fileselector/ofiledialog.h @@ -1,109 +1,110 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFILEDIALOG_H #define OFILEDIALOG_H /* OPIE */ #include <opie2/ofileselector.h> /* QT */ #include <qdialog.h> -namespace Opie -{ +namespace Opie { +namespace Ui { /** * This class places a OFileSelector inside a QDialog. * It provides static method for letting a user chose * a file for either opening or saving. * Most of the time the c'tor will not be used instead using * the static member functions is prefered. * * <pre> * QMap<QString, QStringList> mimeTypes; * QStringList types; * types << "text[slash]* "; * mimeTypes.insert( tr("Text"), types ); * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, * "foo","bar", mimeTypes); * </pre> * * @short A small QDialog swalloing a FileSelector * @see QDialog * @see OFileSelector * @version 0.1-unfinished * @author Holger Freyther ( zecke@handhelds.org ) */ class OFileDialog : public QDialog { Q_OBJECT public: OFileDialog(const QString &caption, QWidget *, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const MimeTypes &mimetypes = MimeTypes() ); QString mimetype() const; QString fileName() const; DocLnk selectedDocument()const; // static methods static QString getOpenFileName(int selector, const QString& startDir = QString::null, const QString &fileName = QString::null, const MimeTypes& mime = MimeTypes(), QWidget *wid = 0, const QString &caption = QString::null ); static QString getSaveFileName(int selector, const QString& startDir = QString::null, const QString& fileName = QString::null, const MimeTypes& mimefilter = MimeTypes(), QWidget *wid = 0, const QString &caption = QString::null ); //let's OFileSelector catch up first //static QString getExistingDirectory(const QString& startDir = QString::null, //QWidget *parent = 0, const QString& caption = QString::null ); private: class OFileDialogPrivate; OFileDialogPrivate *d; OFileSelector *file; private slots: void slotFileSelected( const QString & ); void slotDirSelected(const QString & ); void slotSelectorOk(); }; -}; +} +} #endif diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 15cadd4..c4d5033 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -1,155 +1,158 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* hacky but we need to get FileSelector::filter */ #define private public #include <qpe/fileselector.h> #undef private #include "ofileselector_p.h" /* OPIE */ #include <opie2/ofileselector.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> /* QT */ #include <qcombobox.h> #include <qdir.h> #include <qhbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qregexp.h> #include <qobjectlist.h> -using namespace Opie; +using namespace Opie::Ui::Private; +namespace Opie { +namespace Ui { +namespace Private { OFileViewInterface::OFileViewInterface( OFileSelector* selector ) : m_selector( selector ) {} OFileViewInterface::~OFileViewInterface() {} QString OFileViewInterface::name()const { return m_name; } void OFileViewInterface::setName( const QString& name ) { m_name = name; } OFileSelector* OFileViewInterface::selector()const { return m_selector; } DocLnk OFileViewInterface::selectedDocument()const { return DocLnk( selectedName() ); } bool OFileViewInterface::showNew()const { return selector()->showNew(); } bool OFileViewInterface::showClose()const { return selector()->showClose(); } MimeTypes OFileViewInterface::mimeTypes()const { return selector()->mimeTypes(); } QStringList OFileViewInterface::currentMimeType()const { return selector()->currentMimeType(); } void OFileViewInterface::activate( const QString& ) { // not implemented here } void OFileViewInterface::ok() { emit selector()->ok(); } void OFileViewInterface::cancel() { emit selector()->cancel(); } void OFileViewInterface::closeMe() { emit selector()->closeMe(); } void OFileViewInterface::fileSelected( const QString& str) { emit selector()->fileSelected( str); } void OFileViewInterface::fileSelected( const DocLnk& lnk) { emit selector()->fileSelected( lnk ); } void OFileViewInterface::setCurrentFileName( const QString& str ) { selector()->m_lneEdit->setText( str ); } QString OFileViewInterface::currentFileName()const { return selector()->m_lneEdit->text(); } QString OFileViewInterface::startDirectory()const { return selector()->m_startDir; } ODocumentFileView::ODocumentFileView( OFileSelector* selector ) :OFileViewInterface( selector ) { m_selector = 0; @@ -717,192 +720,194 @@ bool OFileViewFileListView::compliesMime( const QString& str) return true; } return false; } /* * The listView giving access to the file system! */ class OFileViewFileSystem : public OFileViewInterface { public: OFileViewFileSystem( OFileSelector* ); ~OFileViewFileSystem(); QString selectedName() const; QString selectedPath() const; QString directory()const; void reread(); int fileCount()const; QWidget* widget( QWidget* parent ); void activate( const QString& ); private: OFileViewFileListView* m_view; bool m_all : 1; }; OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) : OFileViewInterface( sel ) { m_view = 0; m_all = false; } OFileViewFileSystem::~OFileViewFileSystem() { } QString OFileViewFileSystem::selectedName()const { if (!m_view ) return QString::null; QString cFN=currentFileName(); if (cFN.startsWith("/")) return cFN; return m_view->currentDir() + "/" + cFN; } QString OFileViewFileSystem::selectedPath()const { return QString::null; } QString OFileViewFileSystem::directory()const { if (!m_view) return QString::null; OFileSelectorItem* item = m_view->currentItem(); if (!item ) return QString::null; return QDir(item->directory() ).absPath(); } void OFileViewFileSystem::reread() { if (!m_view) return; m_view->reread( m_all ); } int OFileViewFileSystem::fileCount()const { if (!m_view ) return -1; return m_view->fileCount(); } QWidget* OFileViewFileSystem::widget( QWidget* parent ) { if (!m_view ) { m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); } return m_view; } void OFileViewFileSystem::activate( const QString& str) { m_all = (str != QObject::tr("Files") ); } + +} /* Selector */ /** * @short new and complete c'tor * * Create a OFileSelector to let the user select a file. It can * either be used to open a file, select a save name in a dir or * as a dropin for the FileSelector. * * <pre> * QMap<QString, QStringList> mimeTypes; * QStringList types; * types << "text@slash* "; * types << "audio@slash*"; * mimeTypes.insert( tr("Audio and Text"), types ); * mimeTypes.insert( tr("All"), "*@slash*); * * now you could create your fileselector * </pre> * * * @param parent the parent of this widget * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) * @param sel The selector to be used * @param dirName The name of the dir to start int * @param fileName The fileName placed in the fileselector lineedit * @param mimetypes The MimeType map of used mimetypes * @param showNew Show a New Button. Most likely to be used in the FileSelector view. * @param showClose Show a Close Button. Most likely to be used in FileSelector view. * */ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, const QString& dirName, const QString& fileName, const MimeTypes& mimetypes, bool showNew, bool showClose) :QWidget( parent, "OFileSelector" ) { m_current = 0; m_shNew = showNew; m_shClose = showClose; m_mimeType = mimetypes; m_startDir = dirName; m_mode = mode; m_selector = sel; initUI(); m_lneEdit->setText( fileName ); initMime(); initViews(); QString str; switch ( m_selector ) { default: case Normal: str = QObject::tr("Documents"); m_cmbView->setCurrentItem( 0 ); break; case Extended: str = QObject::tr("Files"); m_cmbView->setCurrentItem( 1 ); break; case ExtendedAll: str = QObject::tr("All Files"); m_cmbView->setCurrentItem( 2 ); break; } slotViewChange( str ); } /** * This a convience c'tor to just substitute the use of FileSelector */ OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, bool showNew, bool showClose ) : QWidget( parent, name ) { m_current = 0; m_shNew = showNew; m_shClose = showClose; m_startDir = QPEApplication::documentDir(); if (!mimeFilter.isEmpty() ) m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); m_mode = OFileSelector::FileSelector; m_selector = OFileSelector::Normal; initUI(); initMime(); initViews(); m_cmbView->setCurrentItem( 0 ); slotViewChange( QObject::tr("Documents") ); } @@ -1071,96 +1076,98 @@ OFileViewInterface* OFileSelector::currentView()const bool OFileSelector::showNew()const { return m_shNew; } bool OFileSelector::showClose()const { return m_shClose; } MimeTypes OFileSelector::mimeTypes()const { return m_mimeType; } /** * @return the Mode of the OFileSelector */ int OFileSelector::mode()const { return m_mode; } /** * @return the Selector of the OFileSelector */ int OFileSelector::selector()const { return m_selector; } QStringList OFileSelector::currentMimeType()const { return m_mimeType[m_cmbMime->currentText()]; } void OFileSelector::slotMimeTypeChanged() { reread(); } void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { m_lneEdit->setText( lnk.name() ); emit fileSelected( lnk ); emit fileSelected( lnk.name() ); } void OFileSelector::slotFileBridge( const QString& str) { DocLnk lnk( str ); emit fileSelected( lnk ); } void OFileSelector::slotViewChange( const QString& view ) { OFileViewInterface* interface = m_views[view]; if (!interface) return; interface->activate( view ); if (m_current) m_stack->removeWidget( m_current->widget( m_stack ) ); static int id = 1; m_stack->addWidget( interface->widget(m_stack), id ); m_stack->raiseWidget( id ); interface->reread(); m_current = interface; id++; } void OFileSelector::setNewVisible( bool b ) { m_shNew = b; currentView()->reread(); } void OFileSelector::setCloseVisible( bool b ) { m_shClose = b; currentView()->reread(); } void OFileSelector::setNameVisible( bool b ) { if ( b ) m_nameBox->show(); else m_nameBox->hide(); } +} +} diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index 7fa657b..2205963 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h @@ -1,219 +1,222 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This is based on code and ideas of L. J. Potter ljp@llornkcor.com Thanks a lot */ #ifndef OFILESELECTOR_H #define OFILESELECTOR_H /* OPIE */ #include <qpe/applnk.h> /* QT */ #include <qlist.h> #include <qwidget.h> #include <qmap.h> #include <qvaluelist.h> #include <qstringlist.h> class QLineEdit; class QComboBox; class QWidgetStack; class QHBox; typedef QMap<QString, QStringList> MimeTypes; -namespace Opie -{ +namespace Opie { +namespace Ui { +namespace Private { class OFileViewInterface; class OFileViewFileListView; +} /** * @short a dropin replacement for the FileSelector * * This class is first used insert the OFileDialog. * It supports multiple view and mimetype filtering for now. * * @see OFileDialog * @see FileSelector * @author zecke * @version 0.1 */ class OFileSelector : public QWidget { Q_OBJECT - friend class Opie::OFileViewInterface; - friend class Opie::OFileViewFileListView; + friend class Private::OFileViewInterface; + friend class Private::OFileViewFileListView; public: /** * The Mode of the Fileselector * Open = Open A File * Save = Save a File * FILESELECTOR = As A GUI in a screen to select a file */ enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; /** * Normal = The old FileSelector * Extended = Dir View * ExtendedAll = Dir View with all hidden files * Default = What the vendor considers best */ enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; OFileSelector(QWidget* parent, int mode, int selector, const QString& dirName, const QString& fileName, const MimeTypes& mimetypes = MimeTypes(), bool newVisible = FALSE, bool closeVisible = FALSE ); OFileSelector(const QString& mimeFilter, QWidget* parent, const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); ~OFileSelector(); const DocLnk* selected(); QString selectedName()const; QString selectedPath()const; QString directory()const; DocLnk selectedDocument()const; int fileCount()const; void reread(); int mode()const; int selector()const; /** * Set the Icon visible * @param b Show or Hide the New Button */ void setNewVisible( bool b ); /** * Set the Icon visible */ void setCloseVisible( bool b ); /** * Set the Name Line visible */ void setNameVisible( bool b ); signals: /** * dirSelected is emitted whenever changed into a different dir */ void dirSelected( const QString& ); /** * fileSelected is emitted when a file is selected * it uses a DocLnk as parameter */ void fileSelected( const DocLnk& ); /** * fileSelected is emitted when a file is selected * the complete path is a parameter */ void fileSelected( const QString& ); /** * Create a new File with a DocLnk */ void newSelected( const DocLnk& ); void closeMe(); /** * Ok is emitted on a Qt::Key_Return or Q::Key_Enter * in the line edit */ void ok(); void cancel(); /* used by the ViewInterface */ private: bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; private: /* inits the Widgets */ void initUI(); /* inits the MimeType ComboBox content + connects signals and slots */ void initMime(); /* init the Views :) */ void initViews(); private: QLineEdit* m_lneEdit; // the LineEdit for the Name QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType QWidgetStack* m_stack; // our widget stack which will contain the views - OFileViewInterface* currentView() const; // returns the currentView - OFileViewInterface* m_current; // here is the view saved + Private::OFileViewInterface* currentView() const; // returns the currentView + Private::OFileViewInterface* m_current; // here is the view saved bool m_shNew : 1; // should we show New? bool m_shClose : 1; // should we show Close? MimeTypes m_mimeType; // list of mimetypes - QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr + QMap<QString, Private::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr QHBox* m_nameBox; // the LineEdit + Label is hold here QHBox* m_cmbBox; // this holds the two combo boxes QString m_startDir; int m_mode; int m_selector; struct Data; // used for future versions Data *d; private slots: void slotMimeTypeChanged(); /* will set the text of the lineedit and emit a fileChanged signal */ void slotDocLnkBridge( const DocLnk& ); void slotFileBridge( const QString& ); void slotViewChange( const QString& ); bool eventFilter (QObject *o, QEvent *e); }; -}; +} +} #endif diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index 818ced9..376dc98 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h @@ -1,191 +1,193 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFILESELECTOR_PRIVATE_H #define OFILESELECTOR_PRIVATE_H /* OPIE */ #include <qpe/applnk.h> #include <qpe/fileselector.h> /* QT */ #include <qmap.h> #include <qstringlist.h> #include <qwidget.h> #include <qlistview.h> /* * How to avoid having really two different objects * for Extended and ExtendedAll * The only difference is the Lister... * a) static object? * b) leave some object inside the OFileSelector which can be used? * c) when switching views tell which view we want o have.. internally we can switch then * * I'll take c) -zecke */ typedef QMap<QString, QStringList> MimeTypes; /* the View Interface */ class QFileInfo; class QToolButton; -namespace Opie -{ - +namespace Opie{ +namespace Ui{ class OFileSelector; +namespace Private { class OFileViewInterface { public: OFileViewInterface( OFileSelector* selector ); virtual ~OFileViewInterface(); virtual QString selectedName()const = 0; virtual QString selectedPath()const = 0; virtual QString directory()const = 0; virtual void reread() = 0; virtual int fileCount()const = 0; virtual DocLnk selectedDocument()const; virtual QWidget* widget( QWidget* parent) = 0; virtual void activate( const QString& ); QString name()const; protected: OFileSelector* selector()const; void setName( const QString& ); bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; QString startDirectory()const; protected: void ok(); void cancel(); void closeMe(); void fileSelected( const QString& ); void fileSelected( const DocLnk& ); void setCurrentFileName( const QString& ); QString currentFileName()const; private: QString m_name; OFileSelector* m_selector; }; /* THE Document View hosting a FileSelector*/ class ODocumentFileView : public OFileViewInterface { public: ODocumentFileView( OFileSelector* selector ); ~ODocumentFileView(); QString selectedName() const; QString selectedPath() const; QString directory() const; void reread(); int fileCount()const; DocLnk selectedDocument()const; QWidget* widget( QWidget* parent ); private: mutable FileSelector* m_selector; }; class OFileSelectorItem : public QListViewItem { public: OFileSelectorItem( QListView* view, const QPixmap& pixmap, const QString& path, const QString& date, const QString& size, const QString& mDir, bool isLocked = false, bool isDir = false ); ~OFileSelectorItem(); bool isLocked()const; bool isDir()const; QString directory()const; QString path()const; QString key(int id, bool )const; private: bool m_locked : 1; bool m_isDir : 1; QString m_dir; }; class OFileViewFileListView : public QWidget { Q_OBJECT public: OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); ~OFileViewFileListView(); OFileSelectorItem* currentItem()const; void reread( bool all = false ); int fileCount()const; QString currentDir()const; protected: bool eventFilter (QObject *o, QEvent *e); private slots: void slotNew(); // will emit newSelected void cdUP(); void cdHome(); void cdDoc(); void changeDir( const QString& ); void slotCurrentChanged( QListViewItem* ); void slotClicked(int, QListViewItem*, const QPoint&, int ); void slotFSActivated(int); protected: OFileSelector* selector(); private: QMap<QString, QString> m_dev; bool m_all : 1; OFileSelector* m_sel; QPopupMenu* m_fsPop; bool compliesMime( const QString& ); QStringList m_mimes; // used in compy mime QString m_currentDir; QToolButton *m_btnNew, *m_btnClose; void connectSlots(); void addFile( QFileInfo* info, bool symlink = FALSE ); void addDir ( QFileInfo* info, bool symlink = FALSE ); void addSymlink( QFileInfo* info, bool = FALSE ); private: QListView* m_view; }; -}; +} +} +} #endif diff --git a/libopie2/opieui/fileselector/ofileview.h b/libopie2/opieui/fileselector/ofileview.h index 495401b..aaf56b1 100644 --- a/libopie2/opieui/fileselector/ofileview.h +++ b/libopie2/opieui/fileselector/ofileview.h @@ -1,95 +1,98 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFILEVIEW_H #define OFILEVIEW_H /* QT */ #include <qobject.h> #include <qwidget.h> class QFileInfo; class QDir; class DocLnk; -namespace Opie -{ +namespace Opie { +namespace Ui { +namespace Private { /** * A OFileView is a specialised View for the * OFileSelector * With a View you can chage the user visible * representation of a OFileLister * OFileView is just a basic interface which helps you to * write new views */ class OFileView : public QWidget { Q_OBJECT public: OFileView(QWidget *widget, const char *name ); OFileView(); virtual void addFile(const QString &mine, QFileInfo *info, bool isSymlink = FALSE ) = 0; virtual void addDir (const QString &mine, QFileInfo *info, bool isSymlink = FALSE ) = 0; virtual void addSymlink(const QString &mime, QFileInfo *info, bool isSymlink = FALSE ) = 0; virtual void cd(const QString &path ) = 0; signals: void fileSelected(const QString &); void fileSelected(const DocLnk & ); void contextMenu(); void changedDir(const QString &); void changedDir(const QDir & ); }; class OFileViewFactory { // Q_OBJECT public: OFileViewFactory() {} ; virtual ~OFileViewFactory() = 0; OFileView* newView(QWidget *parent, const char *name ); QString name()const; }; -}; +} +} +} #endif diff --git a/libopie2/opieui/oclickablelabel.cpp b/libopie2/opieui/oclickablelabel.cpp index 4c4e581..53cb77a 100644 --- a/libopie2/opieui/oclickablelabel.cpp +++ b/libopie2/opieui/oclickablelabel.cpp @@ -1,128 +1,128 @@ /* This file is part of the Opie Project Copyright (C) Maximillian Reiß <harlekin@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/oclickablelabel.h> -using namespace Opie; +using namespace Opie::Ui; /** * This constructs the clickable ButtonLabel * * @param parent The parent of this label * @param name A name of this label @see QObject * @param fl The windowing flags */ OClickableLabel::OClickableLabel(QWidget* parent, const char* name, WFlags fl) :QLabel(parent,name,fl) { textInverted=false; isToggle=false; isDown=false; showState(false); setFrameShadow(Sunken); } /** * This method makes the label behave as a toggle button * * @param t Whether or not to behave like a toggle button */ void OClickableLabel::setToggleButton(bool t) { isToggle=t; } /** * @internal */ void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) { if (isToggle && isDown) { showState(false); } else { showState(true); } } /** * @internal */ void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { if (rect().contains(e->pos()) && isToggle) isDown=!isDown; if (isToggle && isDown) { showState(true); } else { showState(false); } if (rect().contains(e->pos())) { if (isToggle) { emit toggled(isDown); } emit clicked(); } } /** * @internal */ void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) { if (rect().contains(e->pos())) { if (isToggle && isDown) { showState(false); } else { showState(true); } } else { if (isToggle && isDown) { showState(true); } else { showState(false); } } diff --git a/libopie2/opieui/oclickablelabel.h b/libopie2/opieui/oclickablelabel.h index b224d61..90859a0 100644 --- a/libopie2/opieui/oclickablelabel.h +++ b/libopie2/opieui/oclickablelabel.h @@ -1,103 +1,104 @@ /* This file is part of the Opie Project Copyright (C) Maximillian Reiß <harlekin@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OCLICKABLELABEL_H #define OCLICKABLELABEL_H /* QT */ #include <qlabel.h> -namespace Opie -{ +namespace Opie{ +namespace Ui { /** * This class is a special QLabel which can behave * as a QPushButton or QToggleButton. * The reason to use a clickable is if you want to save space * or you want to skip the border of a normal button * * <pre> * QLabel* lbl = new OClickableLabel( parent, "PushLabel" ); * lbl->setPixmap( "config" ); * QWhatsThis::add( lbl, tr("Click here to do something") ); * </pre> * * @short A Label behaving as button * @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org ) * @see QLabel * @see QPushButton * @see QToggleButton * @version 1.0 */ class OClickableLabel: public QLabel { Q_OBJECT public: OClickableLabel(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); void setToggleButton(bool t); protected: /** @internal */ void mousePressEvent( QMouseEvent *e ); /** @internal */ void mouseReleaseEvent( QMouseEvent *e ); /** @internal */ void mouseMoveEvent( QMouseEvent *e ); public slots: void setOn(bool on); signals: /** * emitted when the labels gets clicked */ void clicked(); /** * emitted when the labels gets toggled * @param on the new new state of the label */ void toggled(bool on); private: bool isToggle : 1; bool isDown : 1; bool textInverted : 1; void showState(bool on); void setInverted(bool on); private: class Private; Private *d; // private d pointer }; -}; +} +} #endif diff --git a/libopie2/opieui/odialog.cpp b/libopie2/opieui/odialog.cpp index 4d269d4..27f8d20 100644 --- a/libopie2/opieui/odialog.cpp +++ b/libopie2/opieui/odialog.cpp @@ -1,55 +1,57 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/odialog.h> #warning Make Margin and Spacing device dependend and configurable! +using namespace Opie::Ui; + int ODialog::mMarginSize = 5; int ODialog::mSpacingSize = 2; ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f) :QDialog(parent, name, modal, f) { // d = new ODialogPrivate(); } int ODialog::marginHint() { return( mMarginSize ); } int ODialog::spacingHint() { return( mSpacingSize ); } // Placeholder for even more sophisticed things diff --git a/libopie2/opieui/odialog.h b/libopie2/opieui/odialog.h index ceff612..57f534c 100644 --- a/libopie2/opieui/odialog.h +++ b/libopie2/opieui/odialog.h @@ -1,91 +1,96 @@ /* This file is part of the Opie Project (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ODIALOG_H #define ODIALOG_H class QLayoutItem; #include <qdialog.h> /** * Dialog with extended nonmodal support and methods for OPIE standard * compliance. * * The @ref marginHint() and @ref spacingHint() sizes shall be used * whenever you layout the interior of a dialog. One special note. If * you make your own action buttons (OK, Cancel etc), the space * beteween the buttons shall be @ref spacingHint(), whereas the space * above, below, to the right and to the left shall be @ref marginHint(). * If you add a separator line above the buttons, there shall be a * @ref marginHint() between the buttons and the separator and a * @ref marginHint() above the separator as well. * * @author Michael 'Mickey' Lauer <mickey@Vanille.de> */ // lets fix up Qt instead! Size does matter. -zecke // while that may be true, reducing maintainance effort for the future does also matter - // and I believe that maintaining a patch against QtE is more work than our classes -mml +namespace Opie { +namespace Ui { + class ODialog : public QDialog { Q_OBJECT public: /** * Constructor. * * Takes the same arguments as @ref QDialog. */ ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); /** * Return the number of pixels you shall use between a * dialog edge and the outermost widget(s) according to the KDE standard. **/ static int marginHint(); /** * Return the number of pixels you shall use between * widgets inside a dialog according to the KDE standard. */ static int spacingHint(); private: static int mMarginSize; static int mSpacingSize; class ODialogPrivate; ODialogPrivate *d; }; +} +} #endif // ODIALOG_H diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp index f93781f..b19c26e 100644 --- a/libopie2/opieui/ofontselector.cpp +++ b/libopie2/opieui/ofontselector.cpp @@ -1,206 +1,206 @@ /* This file is part of the Opie Project Copyright (C) Robert Griebl <sandman@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/ofontselector.h> #include <qpe/fontdatabase.h> /* QT */ #include <qlayout.h> #include <qlistbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qmultilineedit.h> -using namespace Opie; -namespace Opie -{ +namespace Opie { +namespace Ui { +namespace Private { class OFontSelectorPrivate { public: QListBox * m_font_family_list; QComboBox * m_font_style_list; QComboBox * m_font_size_list; QMultiLineEdit *m_preview; bool m_pointbug : 1; FontDatabase m_fdb; }; -}; - -namespace -{ - class FontListItem : public QListBoxText { public: FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() { m_name = t; m_styles = styles; m_sizes = sizes; QString str = t; str [0] = str [0]. upper(); setText ( str ); } QString family() const { return m_name; } const QStringList &styles() const { return m_styles; } const QValueList<int> &sizes() const { return m_sizes; } private: QStringList m_styles; QValueList<int> m_sizes; QString m_name; }; +} +} +} + +using namespace Opie::Ui; +using namespace Opie::Ui::Private; static int findItemCB( QComboBox *box, const QString &str ) { for ( int i = 0; i < box->count(); i++ ) { if ( box->text ( i ) == str ) return i; } return -1; } -} /* static same as anon. namespace */ static int qt_version() { const char *qver = qVersion(); return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); } /** * Constructs the Selector object * @param withpreview If a font preview should be given * @param parent The parent of the Font Selector * @param name The name of the object * @param fl WidgetFlags */ OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) { d = new OFontSelectorPrivate(); QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); gridLayout->setRowStretch( 4, 10 ); d->m_font_family_list = new QListBox( this, "FontListBox" ); gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); QLabel *label = new QLabel( tr( "Style" ), this ); gridLayout->addWidget( label, 0, 1 ); d->m_font_style_list = new QComboBox( this, "StyleListBox" ); connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); gridLayout->addWidget( d->m_font_style_list, 1, 1 ); label = new QLabel( tr( "Size" ), this ); gridLayout->addWidget( label, 2, 1 ); d->m_font_size_list = new QComboBox( this, "SizeListBox" ); connect( d->m_font_size_list, SIGNAL( activated(int) ), this, SLOT( fontSizeClicked(int) ) ); gridLayout->addWidget( d->m_font_size_list, 3, 1 ); d->m_pointbug = ( qt_version() <= 233 ); if ( withpreview ) { d->m_preview = new QMultiLineEdit ( this, "Preview" ); d->m_preview->setAlignment ( AlignCenter ); d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); d->m_preview->setMargin ( 3 ); d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); gridLayout->addRowSpacing ( 5, 4 ); gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); gridLayout->setRowStretch ( 6, 5 ); } else d->m_preview = 0; loadFonts ( d->m_font_family_list ); } OFontSelector::~OFontSelector() { delete d; } /** * This methods tries to set the font * @param f The wishes font * @return success or failure */ bool OFontSelector::setSelectedFont ( const QFont &f ) { return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); } /** * This is an overloaded method @see setSelectedFont * @param familyStr The family of the font * @param styleStr The style of the font * @param sizeVal The size of font * @param charset The charset to be used. Will be deprecated by QT3 */ bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) { QString sizeStr = QString::number ( sizeVal ); QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); if ( !family ) family = d->m_font_family_list->findItem ( "Helvetica" ); if ( !family ) family = d->m_font_family_list->firstItem(); d->m_font_family_list->setCurrentItem ( family ); fontFamilyClicked ( d->m_font_family_list->index ( family )); int style = findItemCB ( d->m_font_style_list, styleStr ); @@ -333,96 +333,97 @@ void OFontSelector::fontFamilyClicked ( int index ) FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index ); d->m_font_style_list->clear(); d->m_font_style_list->insertStringList ( fli->styles()); d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty()); int i; i = findItemCB ( d->m_font_style_list, oldstyle ); if ( i < 0 ) i = findItemCB ( d->m_font_style_list, "Regular" ); if (( i < 0 ) && ( d->m_font_style_list->count() > 0 )) i = 0; if ( i >= 0 ) { d->m_font_style_list->setCurrentItem ( i ); fontStyleClicked ( i ); } d->m_font_size_list->clear(); QValueList<int> sl = fli->sizes(); for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it ) d->m_font_size_list->insertItem ( QString::number ( *it )); i = findItemCB ( d->m_font_size_list, oldsize ); if ( i < 0 ) i = findItemCB ( d->m_font_size_list, "10" ); if (( i < 0 ) && ( d->m_font_size_list->count() > 0 )) i = 0; if ( i >= 0 ) { d->m_font_size_list->setCurrentItem ( i ); fontSizeClicked ( i ); } changeFont(); } void OFontSelector::fontStyleClicked ( int /*index*/ ) { changeFont(); } void OFontSelector::fontSizeClicked ( int /*index*/ ) { changeFont(); } void OFontSelector::changeFont() { QFont f = selectedFont(); if ( d->m_preview ) d->m_preview->setFont ( f ); emit fontSelected ( f ); } /** * Return the selected font */ QFont OFontSelector::selectedFont() { int ffa = d->m_font_family_list->currentItem(); int fst = d->m_font_style_list->currentItem(); int fsi = d->m_font_size_list->currentItem(); FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); if ( fli ) { return d->m_fdb. font ( fli->family(), \ fst >= 0 ? fli->styles() [fst] : QString::null, \ fsi >= 0 ? fli->sizes() [fsi] : 10, \ d->m_fdb. charSets ( fli->family()) [0] ); } else return QFont(); } void OFontSelector::resizeEvent ( QResizeEvent *re ) { if ( d->m_preview ) { d->m_preview->setMinimumHeight ( 1 ); d->m_preview->setMaximumHeight ( 32767 ); } QWidget::resizeEvent ( re ); if ( d->m_preview ) d->m_preview->setFixedHeight ( d->m_preview->height()); } + diff --git a/libopie2/opieui/ofontselector.h b/libopie2/opieui/ofontselector.h index ad51819..1d97233 100644 --- a/libopie2/opieui/ofontselector.h +++ b/libopie2/opieui/ofontselector.h @@ -1,104 +1,106 @@ /* This file is part of the Opie Project Copyright (C) Robert Griebl <sandman@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFONTSELECTOR_H #define OFONTSELECTOR_H /* QT */ #include <qwidget.h> class QListBox; -namespace Opie -{ - +namespace Opie { +namespace Ui { +namespace Private { class OFontSelectorPrivate; +} /** * This class lets you chose a Font out of a list of Fonts. * It can show a preview too. This selector will use all available * fonts * * * @short A widget to select a font * @see QWidget * @see QFont * @author Rober Griebl */ class OFontSelector : public QWidget { Q_OBJECT public: OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); virtual ~OFontSelector ( ); bool selectedFont ( QString &family, QString &style, int &size ); bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); QFont selectedFont ( ); bool setSelectedFont ( const QFont & ); bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); QString fontFamily ( ) const; QString fontStyle ( ) const; int fontSize ( ) const; QString fontCharSet ( ) const; signals: /** * This signal gets emitted when a font got chosen */ void fontSelected ( const QFont & ); protected slots: /** @internal */ virtual void fontFamilyClicked ( int ); /** @internal */ virtual void fontStyleClicked ( int ); /** @internal */ virtual void fontSizeClicked ( int ); protected: virtual void resizeEvent ( QResizeEvent *re ); private: void loadFonts ( QListBox * ); void changeFont ( ); private: - OFontSelectorPrivate *d; + Private::OFontSelectorPrivate *d; }; -}; +} +} #endif diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp index 9a58bb9..be47eb2 100644 --- a/libopie2/opieui/oimageeffect.cpp +++ b/libopie2/opieui/oimageeffect.cpp @@ -1,139 +1,143 @@ /* This file is part of the KDE libraries Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org> (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // $Id$ #include <math.h> #include <qimage.h> #include <stdlib.h> #include <opie2/oimageeffect.h> #include <opie2/odebug.h> #define MaxRGB 255L #define DegreesToRadians(x) ((x)*M_PI/180.0) using namespace std; +using namespace Opie::Core; + +namespace Opie { +namespace Ui { inline unsigned int intensityValue(unsigned int color) { return((unsigned int)((0.299*qRed(color) + 0.587*qGreen(color) + 0.1140000000000001*qBlue(color)))); } //====================================================================== // // Gradient effects // //====================================================================== QImage OImageEffect::gradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType eff, int ncols) { int rDiff, gDiff, bDiff; int rca, gca, bca, rcb, gcb, bcb; QImage image(size, 32); if (size.width() == 0 || size.height() == 0) { odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl; return image; } register int x, y; rDiff = (rcb = cb.red()) - (rca = ca.red()); gDiff = (gcb = cb.green()) - (gca = ca.green()); bDiff = (bcb = cb.blue()) - (bca = ca.blue()); if( eff == VerticalGradient || eff == HorizontalGradient ){ uint *p; uint rgb; register int rl = rca << 16; register int gl = gca << 16; register int bl = bca << 16; if( eff == VerticalGradient ) { int rcdelta = ((1<<16) / size.height()) * rDiff; int gcdelta = ((1<<16) / size.height()) * gDiff; int bcdelta = ((1<<16) / size.height()) * bDiff; for ( y = 0; y < size.height(); y++ ) { p = (uint *) image.scanLine(y); rl += rcdelta; gl += gcdelta; bl += bcdelta; rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); for( x = 0; x < size.width(); x++ ) { *p = rgb; p++; } } } else { // must be HorizontalGradient unsigned int *o_src = (unsigned int *)image.scanLine(0); unsigned int *src = o_src; int rcdelta = ((1<<16) / size.width()) * rDiff; int gcdelta = ((1<<16) / size.width()) * gDiff; int bcdelta = ((1<<16) / size.width()) * bDiff; for( x = 0; x < size.width(); x++) { rl += rcdelta; gl += gcdelta; bl += bcdelta; *src++ = qRgb( (rl>>16), (gl>>16), (bl>>16)); } src = o_src; // Believe it or not, manually copying in a for loop is faster // than calling memcpy for each scanline (on the order of ms...). // I think this is due to the function call overhead (mosfet). for (y = 1; y < size.height(); ++y) { p = (unsigned int *)image.scanLine(y); src = o_src; for(x=0; x < size.width(); ++x) *p++ = *src++; } } @@ -3672,97 +3676,98 @@ QImage OImageEffect::blur(QImage &src, double factor) Blur(2); Blur(weight); Blur(2); s=p+2*src.width(); Blur(1); Blur(2); Blur(1); *q = qRgba((unsigned char)((total_red+(quantum/2))/quantum), (unsigned char)((total_green+(quantum/2))/quantum), (unsigned char)((total_blue+(quantum/2))/quantum), (unsigned char)((total_opacity+(quantum/2))/quantum)); p++; q++; } p++; *q++=(*p); } } else{ // PsudeoClass source image unsigned char *p, *p2, *p3, *s; unsigned int *cTable = src.colorTable(); int scanLineIdx; for(y=0; y < src.height(); ++y){ scanLineIdx = QMIN(QMAX(y-1,0),src.height()-3); p = (unsigned char *)src.scanLine(scanLineIdx); p2 = (unsigned char *)src.scanLine(scanLineIdx+1); p3 = (unsigned char *)src.scanLine(scanLineIdx+2); q = (unsigned int *)dest.scanLine(y); // blur this row of pixels. *q++=(*(cTable+(*p2))); for(x=1; x < src.width()-1; ++x){ // compute weighted average of target pixel color components. total_red=0.0; total_green=0.0; total_blue=0.0; total_opacity=0.0; s=p; Blur256(1); Blur256(2); Blur256(1); s=p2; Blur256(2); Blur256(weight); Blur256(2); s=p3; Blur256(1); Blur256(2); Blur256(1); *q = qRgba((unsigned char)((total_red+(quantum/2))/quantum), (unsigned char)((total_green+(quantum/2))/quantum), (unsigned char)((total_blue+(quantum/2))/quantum), (unsigned char)((total_opacity+(quantum/2))/quantum)); p++; p2++; p3++; q++; } p++; *q++=(*(cTable+(*p))); } } return(dest); } // High quality, expensive HSV contrast. You can do a faster one by just // taking a grayscale threshold (ie: 128) and incrementing RGB color // channels above it and decrementing those below it, but this gives much // better results. (mosfet 12/28/01) void OImageEffect::contrastHSV(QImage &img, bool sharpen) { int i, sign; unsigned int *data; int count; double brightness, scale, theta; QColor c; int h, s, v; sign = sharpen ? 1 : -1; scale=0.5000000000000001; if(img.depth() > 8){ count = img.width()*img.height(); data = (unsigned int *)img.bits(); } else{ count = img.numColors(); data = (unsigned int *)img.colorTable(); } for(i=0; i < count; ++i){ c.setRgb(data[i]); c.hsv(&h, &s, &v); brightness = v/255.0; theta=(brightness-0.5)*M_PI; brightness+=scale*(((scale*((sin(theta)+1.0)))-brightness)*sign); if (brightness > 1.0) brightness=1.0; else if (brightness < 0) brightness=0.0; v = (int)(brightness*255); c.setHsv(h, s, v); data[i] = qRgba(c.red(), c.green(), c.blue(), qAlpha(data[i])); } } - +} +} diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h index fb4d22d..4f86d5b 100644 --- a/libopie2/opieui/oimageeffect.h +++ b/libopie2/opieui/oimageeffect.h @@ -1,137 +1,139 @@ //FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? //FIXME: Maybe not on SL5xxx, but surely on C700 :)) //FIXME: I think we don#t need that -zecke /* This file is part of the KDE libraries Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // $Id$ #ifndef OIMAGEEFFECT_H #define OIMAGEEFFECT_H class QImage; class QSize; class QColor; +namespace Opie { +namespace Ui { /** * This class includes various @ref QImage based graphical effects. * * Everything is * static, so there is no need to create an instance of this class. You can * just call the static methods. They are encapsulated here merely to provide * a common namespace. */ class OImageEffect { public: enum GradientType { VerticalGradient, HorizontalGradient, DiagonalGradient, CrossDiagonalGradient, PyramidGradient, RectangleGradient, PipeCrossGradient, EllipticGradient }; enum RGBComponent { Red, Green, Blue, Gray, All }; enum Lighting {NorthLite, NWLite, WestLite, SWLite, SouthLite, SELite, EastLite, NELite}; enum ModulationType { Intensity, Saturation, HueShift, Contrast }; enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, ImpulseNoise, LaplacianNoise, PoissonNoise}; enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; /** * Create a gradient from color a to color b of the specified type. * * @param size The desired size of the gradient. * @param ca Color a * @param cb Color b * @param type The type of gradient. * @param ncols The number of colors to use when not running on a * truecolor display. The gradient will be dithered to this number of * colors. Pass 0 to prevent dithering. */ static QImage gradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType type, int ncols=3); /** * Create an unbalanced gradient. * An unbalanced gradient is a gradient where the transition from * color a to color b is not linear, but in this case, exponential. * * @param size The desired size of the gradient. * @param ca Color a * @param cb Color b * @param type The type of gradient. * @param xfactor The x decay length. Use a value between -200 and 200. * @param yfactor The y decay length. * @param ncols The number of colors. See OPixmapEffect:gradient. */ static QImage unbalancedGradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType type, int xfactor = 100, int yfactor = 100, int ncols = 3); /** * Blends a color into the destination image, using an opacity * value for blending one into another. Very fast direct pixel * manipulation is used. * * @author Karol Szwed (gallium@kde.org) * @param clr source color to be blended into the destination image. * @param dst destination image in which the source will be blended into. * @param opacity opacity (in percent) which determines how much the source * color will be blended into the destination image. * @return The destination image (dst) containing the result. */ static QImage& blend(const QColor& clr, QImage& dst, float opacity); /** * Blend the src image into the destination image, using an opacity * value for blending one into another. Very fast direct pixel * manipulation is used. * * @author Karol Szwed (gallium@kde.org) * @param src source image to be blended into the destination image. * @param dst destination image in which the source will be blended into. * @param opacity opacity (in percent) which determines how much the source * image will be blended into the destination image. * @return The destination image (dst) containing the result. */ static QImage& blend(QImage& src, QImage& dst, float opacity); /** * Blend the provided image into a background of the indicated color. * * @param initial_intensity this parameter takes values from -1 to 1: * a) if positive: how much to fade the image in its * less affected spot * b) if negative: roughly indicates how much of the image * remains unaffected @@ -463,97 +465,100 @@ public: * @param background An RGBA value to use for the background. After the * effect some pixels may be "empty". This value is used for those pixels. * @return The imploded image. The original is not changed. */ static QImage implode(QImage &src, double factor=30.0, unsigned int background = 0xFFFFFFFF); /** * Produces an oil painting effect. * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param radius The radius of the pixel neighborhood used in applying the * effect. * @return The new image. The original is not changed. */ static QImage oilPaint(QImage &src, int radius=3); /** * Sharpens the pixels in the image using pixel neighborhoods. * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param factor The percent weight to give to the center pixel. * @return The sharpened image. The original is not changed. */ static QImage sharpen(QImage &src, double factor=30.0); /** * Randomly displaces pixels. * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param amount The vicinity for choosing a random pixel to swap. * @return The image with pixels displaced. The original is not changed. */ static QImage spread(QImage &src, unsigned int amount=3); /** * Shades the image using a distance light source. * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param color_shading If true do color shading, otherwise do grayscale. * @param azimuth Determines the light source and direction. * @param elevation Determines the light source and direction. * @return The shaded image. The original is not changed. */ static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0, double elevation=30.0); /** * Swirls the image by a specified amount * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param degrees The tightness of the swirl. * @param background An RGBA value to use for the background. After the * effect some pixels may be "empty". This value is used for those pixels. * @return The swirled image. The original is not changed. */ static QImage swirl(QImage &src, double degrees=50.0, unsigned int background = 0xFFFFFFFF); /** * Modifies the pixels along a sine wave. * * @author Daniel M. Duley (mosfet) * @param src The QImage to process. * @param amplitude The amplitude of the sine wave. * @param wavelength The frequency of the sine wave. * @return The new image. The original is not changed. */ static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0, unsigned int background = 0xFFFFFFFF); private: /** * Helper function to fast calc some altered (lighten, shaded) colors * */ static unsigned int lHash(unsigned int c); static unsigned int uHash(unsigned int c); /** * Helper function to find the nearest color to the RBG triplet */ static int nearestColor( int r, int g, int b, const QColor *pal, int size ); static void hull(const int x_offset, const int y_offset, const int polarity, const int width, const int height, unsigned int *f, unsigned int *g); static unsigned int generateNoise(unsigned int pixel, NoiseType type); static unsigned int interpolateColor(QImage *image, double x, double y, unsigned int background); }; +} +} + #endif diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 0ee2fde..38670b4 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp @@ -1,134 +1,139 @@ /* This file is part of the Opie Project =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qpixmap.h> /* OPIE */ #include <opie2/odebug.h> #include <opie2/olistview.h> +using namespace Opie::Core; + + +namespace Opie { +namespace Ui { /*====================================================================================== * OListView *======================================================================================*/ OListView::OListView( QWidget *parent, const char *name ) :QListView( parent, name ) { //FIXME: get from global settings and calculate ==> see oglobalsettings.* m_alternateBackground = QColor( 238, 246, 255 ); m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); m_fullWidth = true; connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); } OListView::~OListView() { } void OListView::setFullWidth( bool fullWidth ) { m_fullWidth = m_fullWidth; #if QT_VERSION > 290 header()->setStretchEnabled( fullWidth, columns()-1 ); #endif } bool OListView::fullWidth() const { return m_fullWidth; } int OListView::addColumn( const QString& label, int width ) { int result = QListView::addColumn( label, width ); #if QT_VERSION > 290 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) { int result = QListView::addColumn( iconset, label, width ); #if QT_VERSION > 290 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } void OListView::removeColumn( int index ) { QListView::removeColumn(index); #if QT_VERSION > 290 if ( m_fullWidth && index == columns() ) { header()->setStretchEnabled( true, columns()-1 ); } #endif } const QColor& OListView::alternateBackground() const { return m_alternateBackground; } void OListView::setAlternateBackground( const QColor &c ) { m_alternateBackground = c; repaint(); } const QPen& OListView::columnSeparator() const { return m_columnSeparator; } void OListView::setColumnSeparator( const QPen& p ) { m_columnSeparator = p; repaint(); } void OListView::expand(QListViewItem *item) { ((OListViewItem*)item)->expand(); } OListViewItem* OListView::childFactory() { @@ -662,96 +667,98 @@ ONamedListViewItem* ONamedListView::find( const QString& column, const QString& { int col = findColumn( column ); if ( col != -1 ) return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const { int col = findColumn( column ); if ( col != -1 ) return find( item, col, text, recurse ); else return 0; } /*====================================================================================== * ONamedListViewItem *======================================================================================*/ ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) :OListViewItem( parent ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) :OListViewItem( parent ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) :OListViewItem( parent, after ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) :OListViewItem( parent, after ) { setText( texts ); } ONamedListViewItem::~ONamedListViewItem() { } void ONamedListViewItem::setText( const QStringList& texts ) { int col = 0; for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) { qDebug( "setting column %d = text %s", col, (const char*) *it ); OListViewItem::setText( col++, *it ); } } void ONamedListViewItem::setText( const QString& column, const QString& text ) { //FIXME: If used excessively, this will slow down performance of updates //FIXME: because of the linear search over all column texts. //FIXME: I will optimize later by using a hash map. int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) OListViewItem::setText( col, text ); else qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); } ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const { return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); } ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const { int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } +} +} diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index 59b0973..8195a62 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h @@ -1,409 +1,426 @@ /* This file is part of the Opie Project =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OLISTVIEW_H #define OLISTVIEW_H #include <qcolor.h> #include <qlistview.h> #include <qpen.h> #include <qdatastream.h> #include <qstringlist.h> + +namespace Opie { +namespace Ui { class OListViewItem; /*====================================================================================== * OListView *======================================================================================*/ /** * @brief A list/tree widget. * * A @ref QListView variant featuring visual and functional enhancements * like an alternate background for odd rows, an autostretch mode * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class OListView: public QListView { + Q_OBJECT public: /** * Constructor. * * The parameters @a parent and @a name are handled by * @ref QListView, as usual. */ OListView( QWidget* parent = 0, const char* name = 0 ); /** * Destructor. */ virtual ~OListView(); /** * Let the last column fit exactly all the available width. */ void setFullWidth( bool fullWidth ); /** * Returns whether the last column is set to fit the available width. */ bool fullWidth() const; /** * Reimplemented for full width support */ virtual int addColumn( const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual void removeColumn(int index); /** * Set the alternate background background @a color. * Set to an invalid color to disable alternate colors. * This only has an effect if the items are OListViewItems */ void setAlternateBackground( const QColor& color ); /** * Sets the column separator @a pen. */ void setColumnSeparator( const QPen& pen ); /** * @returns the alternate background color */ const QColor& alternateBackground() const; /** * @return the column separator pen */ const QPen& columnSeparator() const; /** * Create a list view item as child of this object * @returns the new object */ virtual OListViewItem* childFactory(); #ifndef QT_NO_DATASTREAM /** * Serialize this object to @ref QDataStream @a stream */ virtual void serializeTo( QDataStream& stream ) const; /** * Serialize this object from a @ref QDataStream @a stream */ virtual void serializeFrom( QDataStream& s ); #endif public slots: /** * Expand all items */ void expand(); /** * Collapse all items */ void collapse(); protected slots: /** * expand the current OListViewItem */ void expand(QListViewItem*); private: QColor m_alternateBackground; - bool m_fullWidth; + bool m_fullWidth : 1; QPen m_columnSeparator; + class Private; + Private *d; }; #ifndef QT_NO_DATASTREAM /** * @relates OListView * Writes @a listview to the @a stream and returns a reference to the stream. */ QDataStream& operator<<( QDataStream& stream, const OListView& listview ); /** * @relates OListView * Reads @a listview from the @a stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream& stream, OListView& listview ); #endif // QT_NO_DATASTREAM /*====================================================================================== * OListViewItem *======================================================================================*/ class OListViewItem: public QListViewItem { friend class OCheckListItem; public: /** * Constructors. */ OListViewItem( QListView * parent ); OListViewItem( QListViewItem * parent ); OListViewItem( QListView * parent, QListViewItem * after ); OListViewItem( QListViewItem * parent, QListViewItem * after ); OListViewItem( QListView * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListView * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); /** * Destructor. */ virtual ~OListViewItem(); /** * @returns the background color of the list item. */ const QColor& backgroundColor(); /** * @returns true, if the item is at an odd position and * thus have to be painted with the alternate background color. */ bool isAlternate(); /** * @note: Reimplemented for internal purposes - the API is not affected * */ void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); /** * Perform object initialization. */ void init(); /** * create a list view item as child of this object * @returns the new object */ virtual OListViewItem* childFactory(); #ifndef QT_NO_DATASTREAM /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeTo( QDataStream& s ) const; /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeFrom( QDataStream& s ); #endif /** * expand the the item */ virtual void expand(){}; private: - bool m_known; - bool m_odd; + bool m_known : 1; + bool m_odd : 1; + class Private; + Private *d; }; #ifndef QT_NO_DATASTREAM /** * @relates QListViewItem * Writes listview @a item and all subitems recursively to @a stream * and returns a reference to the stream. */ QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); /** * @relates QListViewItem * Reads listview @a item from @a stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); #endif // QT_NO_DATASTREAM /*====================================================================================== * OCheckListItem *======================================================================================*/ class OCheckListItem : public QCheckListItem { public: OCheckListItem( QCheckListItem *parent, const QString &text, Type = Controller ); OCheckListItem( QListViewItem *parent, const QString &text, Type = Controller ); OCheckListItem( QListView *parent, const QString &text, Type = Controller ); OCheckListItem( QListViewItem *parent, const QString &text, const QPixmap & ); OCheckListItem( QListView *parent, const QString &text, const QPixmap & ); ~OCheckListItem(); /** * @returns the background color of the list item. */ const QColor& backgroundColor(); /** * @returns true, if the item is at an odd position and * thus have to be painted with the alternate background color. */ bool isAlternate(); /** * @note: Reimplemented for internal purposes - the API is not affected * */ void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); /** * Perform object initialization. */ void init(); private: bool m_known; bool m_odd; }; /*====================================================================================== * ONamedListView *======================================================================================*/ class ONamedListViewItem; /** * @brief An OListView variant with named columns. * * This class provides a higher-level interface to an OListView. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONamedListView: public OListView { public: /** * Constructor. * * The parameters @a parent and @a name are handled by * @ref OListView, as usual. */ ONamedListView( QWidget* parent = 0, const char* name = 0 ); /** * Destructor. */ virtual ~ONamedListView(); /** * Add a number of @a columns to the listview. */ virtual void addColumns( const QStringList& columns ); /** * @returns the column index matching to @a text or -1 if not found. */ virtual int findColumn( const QString& text ) const; /** * @returns the first item which has a @a text in column @a column. * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> * <li>set it to 0 to search only among direct childs, * <li>set it to 1 to search direct childs and all 1st order subchilds * <li>set it to -1 for maximum recursion. * </ul> * @sa ONamedListViewItem::find() */ virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; + private: + class Private; + Private *d; }; /*====================================================================================== * ONamedListViewItem *======================================================================================*/ /** * @brief An OListView variant with named columns. * * This class provides a higher-level interface to an OListViewItem. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONamedListViewItem: public OListViewItem { public: /** * Constructor. Accepts the same parameters as a @ref OListViewItem, * plus a @ref QStringList which holds an arbitrary number of @a texts. */ ONamedListViewItem( QListView* parent, const QStringList& texts ); ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); /** * Destructor. */ virtual ~ONamedListViewItem(); /** * Sets the text in column @a column to @a text. * This method differs from @ref QListViewItem::setText() in that it * accepts a string as column indicator instead of an int. */ virtual void setText( const QString& column, const QString& text ); /** * Sets a number of @a texts for this item. */ virtual void setText( const QStringList& texts ); /** * @returns the first child which has a @a text in column @a column. * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> * <li>set it to 0 to search only among direct childs, * <li>set it to 1 to search direct childs and all 1st order subchilds * <li>set it to -1 for maximum recursion. * </ul> * @sa ONamedListView::find() */ virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; -}; + private: + class Private; + Private *d; + +}; +} +} #endif // OLISTVIEW_H diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro index 1be8db5..e895edc 100644 --- a/libopie2/opieui/opieui.pro +++ b/libopie2/opieui/opieui.pro @@ -1,66 +1,63 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = oclickablelabel.h \ odialog.h \ ofontselector.h \ oimageeffect.h \ olistview.h \ - omessagebox.h \ opixmapeffect.h \ opopupmenu.h \ opixmapprovider.h \ - oresource.h \ oselector.h \ oseparator.h \ otabinfo.h \ otabbar.h \ otabwidget.h \ otaskbarapplet.h \ oticker.h \ otimepicker.h \ oversatileview.h \ oversatileviewitem.h \ owait.h SOURCES = oclickablelabel.cpp \ odialog.cpp \ ofontselector.cpp \ oimageeffect.cpp \ olistview.cpp \ opixmapeffect.cpp \ opopupmenu.cpp \ opixmapprovider.cpp \ - oresource.cpp \ oselector.cpp \ oseparator.cpp \ otabbar.cpp \ otabwidget.cpp \ otaskbarapplet.cpp \ oticker.cpp \ otimepicker.cpp \ oversatileview.cpp \ oversatileviewitem.cpp \ owait.cpp include ( big-screen/big-screen.pro ) include ( fileselector/fileselector.pro ) INTERFACES = otimepickerbase.ui TARGET = opieui2 VERSION = 1.8.5 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lopiecore2 !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opieui/opixmapeffect.cpp b/libopie2/opieui/opixmapeffect.cpp index 05f851d..794c7b2 100644 --- a/libopie2/opieui/opixmapeffect.cpp +++ b/libopie2/opieui/opixmapeffect.cpp @@ -1,115 +1,117 @@ /* This file is part of the KDE libraries Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> */ // $Id$ /* QT */ #include <qimage.h> #include <qpainter.h> /* OPIE */ #include <opie2/opixmapeffect.h> #include <opie2/oimageeffect.h> + +using namespace Opie::Ui; //====================================================================== // // Gradient effects // //====================================================================== OPixmap& OPixmapEffect::gradient(OPixmap &pixmap, const QColor &ca, const QColor &cb, GradientType eff, int ncols) { if(pixmap.depth() > 8 && (eff == VerticalGradient || eff == HorizontalGradient)) { int rDiff, gDiff, bDiff; int rca, gca, bca /*, rcb, gcb, bcb*/; register int x, y; rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); register int rl = rca << 16; register int gl = gca << 16; register int bl = bca << 16; int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; QPainter p(&pixmap); // these for-loops could be merged, but the if's in the inner loop // would make it slow switch(eff) { case VerticalGradient: for ( y = 0; y < pixmap.height(); y++ ) { rl += rcdelta; gl += gcdelta; bl += bcdelta; p.setPen(QColor(rl>>16, gl>>16, bl>>16)); p.drawLine(0, y, pixmap.width()-1, y); } break; case HorizontalGradient: for( x = 0; x < pixmap.width(); x++) { rl += rcdelta; gl += gcdelta; bl += bcdelta; p.setPen(QColor(rl>>16, gl>>16, bl>>16)); p.drawLine(x, 0, x, pixmap.height()-1); } break; default: ; } } else { QImage image = OImageEffect::gradient(pixmap.size(), ca, cb, (OImageEffect::GradientType) eff, ncols); pixmap.convertFromImage(image); } return pixmap; } // ----------------------------------------------------------------------------- OPixmap& OPixmapEffect::unbalancedGradient(OPixmap &pixmap, const QColor &ca, const QColor &cb, GradientType eff, int xfactor, int yfactor, int ncols) { QImage image = OImageEffect::unbalancedGradient(pixmap.size(), ca, cb, (OImageEffect::GradientType) eff, xfactor, yfactor, ncols); pixmap.convertFromImage(image); return pixmap; } //====================================================================== // // Intensity effects // //====================================================================== OPixmap& OPixmapEffect::intensity(OPixmap &pixmap, float percent) { QImage image = pixmap.convertToImage(); OImageEffect::intensity(image, percent); diff --git a/libopie2/opieui/opixmapeffect.h b/libopie2/opieui/opixmapeffect.h index 283fe2d..b780f9f 100644 --- a/libopie2/opieui/opixmapeffect.h +++ b/libopie2/opieui/opixmapeffect.h @@ -1,113 +1,116 @@ /* This file is part of the KDE libraries Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> */ // $Id$ #ifndef __OPIXMAP_EFFECT_H #define __OPIXMAP_EFFECT_H #include <qsize.h> typedef QPixmap OPixmap; class QColor; + +namespace Opie { +namespace Ui { /** * This class includes various pixmap-based graphical effects. * * Everything is * static, so there is no need to create an instance of this class. You can * just call the static methods. They are encapsulated here merely to provide * a common namespace. */ class OPixmapEffect { public: enum GradientType { VerticalGradient, HorizontalGradient, DiagonalGradient, CrossDiagonalGradient, PyramidGradient, RectangleGradient, PipeCrossGradient, EllipticGradient }; enum RGBComponent { Red, Green, Blue }; enum Lighting {NorthLite, NWLite, WestLite, SWLite, SouthLite, SELite, EastLite, NELite}; /** * Creates a gradient from color a to color b of the specified type. * * @param pixmap The pixmap to process. * @param ca Color a. * @param cb Color b. * @param type The type of gradient. * @param ncols The number of colors to use when not running on a * truecolor display. The gradient will be dithered to this number of * colors. Pass 0 to prevent dithering. * @return Returns the generated pixmap, for convenience. */ static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb, GradientType type, int ncols=3); /** * Creates an unbalanced gradient. * * An unbalanced gradient is a gradient where the transition from * color a to color b is not linear, but in this case, exponential. * * @param pixmap The pixmap that should be written. * @param ca Color a. * @param cb Color b. * @param type The type of gradient. * @param xfactor The x decay length. Use a value between -200 and 200. * @param yfactor The y decay length. * @param ncols The number of colors. See #gradient. * @return The generated pixmap, for convencience. */ static OPixmap& unbalancedGradient(OPixmap& pixmap, const QColor &ca, const QColor &cb, GradientType type, int xfactor = 100, int yfactor = 100, int ncols=3); /** * Creates a pixmap of a given size with the given pixmap. * * if the * given size is bigger than the size of the pixmap, the pixmap is * tiled. * * @param pixmap This is the source pixmap * @param size The size the new pixmap should have. * @return The generated, tiled pixmap. */ static OPixmap createTiled(const OPixmap& pixmap, QSize size); /** * Either brightens or dims a pixmap by a specified ratio. * * @param pixmap The pixmap to process. * @param ratio The ratio to use. Use negative value to dim. * @return Returns The @ref pixmap(), provided for convenience. */ static OPixmap& intensity(OPixmap& pixmap, float ratio); /** * Modifies the intensity of a pixmap's RGB channel component. * * @param pixmap The pixmap to process. * @param ratio value. Use negative value to dim. * @param channel Which channel(s) should be modified * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& channelIntensity(OPixmap& pixmap, float ratio, RGBComponent channel); /** * Blends the provided pixmap into a background of the indicated color. * * @param pixmap The pixmap to process. * @param initial_intensity this parameter takes values from -1 to 1: * @li If positive, it tells how much to fade the image in its * less affected spot. * @li If negative, it tells roughly indicates how much of the image * remains unaffected @@ -117,99 +120,100 @@ public: * with concentric blending effects). * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& blend(OPixmap& pixmap, float initial_intensity, const QColor &bgnd, GradientType eff, bool anti_dir=false, int ncols=3); /** * Builds a hash on any given pixmap. * * @param pixmap The pixmap to process. * @param lite The hash faces the indicated lighting (cardinal poles) * @param spacing How many unmodified pixels inbetween hashes. * @return Returns The @ref pixmap(), provided for convenience. */ static OPixmap& hash(OPixmap& pixmap, Lighting lite=NorthLite, unsigned int spacing=0, int ncols=3); /** * Creates a pattern from a pixmap. * * The given pixmap is "flattened" * between color a to color b. * * @param pixmap The pixmap to process. * @param ca Color a. * @param cb Color b. * @param ncols The number of colors to use. The image will be * dithered to this depth. Pass zero to prevent dithering. * @return The @ref pixmap(), provided for convenience. */ static OPixmap pattern(const OPixmap& pixmap, QSize size, const QColor &ca, const QColor &cb, int ncols=8); /** * Recolors a pixmap. * * The most dark color will become color a, * the most bright one color b, and in between. * * @param pixmap The pixmap to process. * @param ca Color a. * @param cb Color b. * @param ncols The number of colors to use. Pass zero to prevent * dithering. * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& fade(OPixmap& pixmap, double val, const QColor &color); /** * Converts a pixmap to grayscale. * * @param pixmap The pixmap to process. * @param fast Set to @p true in order to use a faster but non-photographic * quality algorithm. Appropriate for things such as toolbar icons. * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& toGray(OPixmap& pixmap, bool fast=false); /** * Desaturates a pixmap. * * @param pixmap The pixmap to process. * @param desat A value between 0 and 1 setting the degree of desaturation * @return Returns The @ref pixmap(), provided for convenience. */ static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3); /** * Modifies the contrast of a pixmap. * * @param pixmap The pixmap to process. * @param c A contrast value between -255 and 255. * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& contrast(OPixmap& pixmap, int c); /** * Dithers a pixmap using Floyd-Steinberg dithering for low-color * situations. * * @param pixmap The pixmap to process. * @param palette The color palette to use. * @param size The size of the palette. * @return Returns the @ref pixmap(), provided for convenience. */ static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size); /** * Calculate a 'selected' pixmap, for instance a selected icon * on the desktop. * @param pixmap the pixmap to select * @param col the selected color, usually from QColorGroup::highlight(). */ static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col ); }; - +} +} #endif diff --git a/libopie2/opieui/opixmapprovider.cpp b/libopie2/opieui/opixmapprovider.cpp index 7be9e3b..7eb67a2 100644 --- a/libopie2/opieui/opixmapprovider.cpp +++ b/libopie2/opieui/opixmapprovider.cpp @@ -1,27 +1,29 @@ /* This file is part of the KDE libraries Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License (LGPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/opixmapprovider.h> +using namespace Opie::Ui; + OPixmapProvider::~OPixmapProvider() {} void OPixmapProvider::virtual_hook( int , void* ) { /*BASE::virtual_hook( id, data );*/ } diff --git a/libopie2/opieui/opixmapprovider.h b/libopie2/opieui/opixmapprovider.h index 5b76647..9d9bd69 100644 --- a/libopie2/opieui/opixmapprovider.h +++ b/libopie2/opieui/opixmapprovider.h @@ -1,54 +1,62 @@ /* This file is part of the KDE libraries Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License (LGPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OPIXMAPPROVIDER_H #define OPIXMAPPROVIDER_H #include <qpixmap.h> +namespace Opie { +namespace Ui { /** + * \todo make usefull * A tiny abstract class with just one method: * @ref pixmapFor() * * It will be called whenever an icon is searched for @p text. * * Used e.g. by @ref KHistoryCombo * * @author Carsten Pfeiffer <pfeiffer@kde.org> * @short an abstract interface for looking up icons */ class OPixmapProvider { public: virtual ~OPixmapProvider(); /** * You may subclass this and return a pixmap of size @p size for @p text. * @param text the text that is associated with the pixmap * @param size the size of the icon in pixels, 0 for defaylt size. * See @ref KIcon::StdSize. * @return the pixmap for the arguments, or null if there is none */ virtual QPixmap pixmapFor( const QString& text, int size = 0 ) = 0; protected: virtual void virtual_hook( int id, void* data ); +private: + class Private; + Private *d; }; +} +} #endif // OPIXMAPPROVIDER_H diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index d5cc575..3ab8490 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp @@ -1,125 +1,128 @@ /* This file is part of the KDE libraries Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qdrawutil.h> #include <qtimer.h> /* OPIE */ #include <opie2/opopupmenu.h> #include <opie2/oconfig.h> +using namespace Opie::Core; +using namespace Opie::Ui; + OPopupTitle::OPopupTitle(QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) { titleStr = text; if (icon) miniicon = *icon; else miniicon.resize(0, 0); int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setText( const QString &text ) { titleStr = text; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setIcon( const QPixmap &pix ) { miniicon = pix; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::paintEvent(QPaintEvent *) { QRect r(rect()); QPainter p(this); #if QT_VERSION > 290 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); #else #warning OPopupMenu is not fully functional on Qt2 #endif if (!miniicon.isNull()) p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); if (!titleStr.isNull()) { p.setPen(palette().active().text()); QFont f = p.font(); f.setBold(true); p.setFont(f); if(!miniicon.isNull()) { p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), height(), AlignLeft | AlignVCenter | SingleLine, titleStr); } else { p.drawText(0, 0, width(), height(), AlignCenter | SingleLine, titleStr); } } p.setPen(palette().active().highlight()); p.drawLine(0, 0, r.right(), 0); } QSize OPopupTitle::sizeHint() const { return(minimumSize()); } class OPopupMenu::OPopupMenuPrivate { public: OPopupMenuPrivate () diff --git a/libopie2/opieui/opopupmenu.h b/libopie2/opieui/opopupmenu.h index 54e4301..419a954 100644 --- a/libopie2/opieui/opopupmenu.h +++ b/libopie2/opieui/opopupmenu.h @@ -1,129 +1,131 @@ //FIXME what is ODE? ODE Desktop Environemt? -zecke //FIXME do we need titles? space is limited that is only eyecandy? -zecke //FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke /* This file is part of the ODE libraries Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _OPOPUP_H #define _OPOPUP_H #define INCLUDE_MENUITEM_DEF /* QT */ #include <qpopupmenu.h> /* OPIE */ #include <opie2/opixmapeffect.h> +namespace Opie { +namespace Ui { /** * Title widget for use in @ref OPopupMenu. * * You usually don't have to create this manually since * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if * you wish to customize it's look. * * @author Daniel M. Duley <mosfet@kde.org> * @short OPopupMenu title widget. */ class OPopupTitle : public QWidget { Q_OBJECT public: /** * Constructs a title widget with the user specified gradient, pixmap, * and colors. */ OPopupTitle(QWidget *parent=0, const char *name=0); /** * @deprecated * Constructs a title widget with the specified gradient and colors. */ OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color, const QColor &textColor, QWidget *parent=0, const char *name=0); /** * @deprecated * Constructs a title widget with the specified pixmap and colors. */ OPopupTitle(const OPixmap &background, const QColor &color, const QColor &textColor, QWidget *parent=0, const char *name=0); /** * Sets the title string and optional icon for the title widget. * * You will want to call this before inserting into a menu. */ void setTitle(const QString &text, const QPixmap *icon=NULL); /** * Returns the current title. */ QString title() const { return(titleStr); } /** * Returns the current icon. */ QPixmap icon() const { return(miniicon); } QSize sizeHint() const; public slots: /// @since 3.1 void setText( const QString &text ); /// @since 3.1 void setIcon( const QPixmap &pix ); protected: void paintEvent(QPaintEvent *ev); QString titleStr; QPixmap miniicon; // Remove in KDE4 OPixmapEffect::GradientType grType; QPixmap fill; QColor fgColor, bgColor, grHigh, grLow; bool useGradient; protected: virtual void virtual_hook( int id, void* data ); private: class OPopupTitlePrivate; OPopupTitlePrivate *d; }; /** * OPopupMenu is a class for menus with standard title items and keyboard * accessibility for popups with many options and/or varying options. It acts * identically to QPopupMenu, with the addition of insertTitle(), * changeTitle(), setKeyboardShortcutsEnabled() and * setKeyboardShortcutsExecute() methods. * * The titles support a text string, an icon, plus user defined gradients, * colors, and background pixmaps. * * The keyboard search algorithm is incremental with additional underlining * for user feedback. * * @short A menu with title items. * @author Daniel M. Duley <mosfet@kde.org> * @author Hamish Rodda <meddie@yoyo.its.monash.edu.au> */ class OPopupMenu : public QPopupMenu { Q_OBJECT public: @@ -163,97 +165,100 @@ public: QString title(int id=-1) const; /** * Returns the icon of the title item at the specified id. */ QPixmap titlePixmap(int id) const; /** * Enables keyboard navigation by searching for the entered key sequence. * Also underlines the currently selected item, providing feedback on the search. * * Defaults to off. * * WARNING: calls to text() of currently keyboard-selected items will * contain additional ampersand characters. * * WARNING: though pre-existing keyboard shortcuts will not interfere with the * operation of this feature, they may be confusing to the user as the existing * shortcuts will not work. * @since 3.1 */ void setKeyboardShortcutsEnabled(bool enable); /** * Enables execution of the menu item once it is uniquely specified. * Defaults to off. * @since 3.1 */ void setKeyboardShortcutsExecute(bool enable); /** * Obsolete method provided for backwards compatibility only. Use the * normal constructor and insertTitle instead. */ OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0); /** * Obsolete method provided for backwards compatibility only. Use * insertTitle and changeTitle instead. */ void setTitle(const QString &title); /** * Returns the context menu associated with this menu * @since 3.2 */ QPopupMenu* contextMenu(); /** * Hides the context menu if shown * @since 3.2 */ void cancelContextMenuShow(); /** * Returns the OPopupMenu associated with the current context menu * @since 3.2 */ static OPopupMenu* contextMenuFocus(); /** * returns the ID of the menuitem associated with the current context menu * @since 3.2 */ static int contextMenuFocusItem(); signals: /** * connect to this signal to be notified when a context menu is about to be shown * @param menu The menu that the context menu is about to be shown for * @param menuItem The menu item that the context menu is currently on * @param ctxMenu The context menu itself * @since 3.2 */ void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu); protected: virtual void closeEvent(QCloseEvent *); virtual void keyPressEvent(QKeyEvent* e); virtual bool eventFilter(QObject* obj, QEvent* event); virtual void hideEvent(QHideEvent*); virtual void virtual_hook( int id, void* data ); protected slots: /// @since 3.1 QString underlineText(const QString& text, uint length); /// @since 3.1 void resetKeyboardVars(bool noMatches = false); void itemHighlighted(int whichItem); void showCtxMenu(QPoint pos); void ctxMenuHiding(); private: class OPopupMenuPrivate; OPopupMenuPrivate *d; }; +} +} + #endif diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp index 23b3ce3..5f6f10f 100644 --- a/libopie2/opieui/oselector.cpp +++ b/libopie2/opieui/oselector.cpp @@ -1,571 +1,573 @@ /* This file is part of the KDE libraries Copyright (C) 1997 Martin Jones (mjones@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qimage.h> #include <qdrawutil.h> /* OPIE */ #include <opie2/oimageeffect.h> #include <opie2/oselector.h> #define STORE_W 8 #define STORE_W2 STORE_W * 2 //----------------------------------------------------------------------------- /* * 2D value selector. * The contents of the selector are drawn by derived class. */ +using namespace Opie::Ui; + OXYSelector::OXYSelector( QWidget *parent, const char *name ) : QWidget( parent, name ) { xPos = 0; yPos = 0; minX = 0; minY = 0; maxX = 100; maxY = 100; store.setOptimization( QPixmap::BestOptim ); store.resize( STORE_W2, STORE_W2 ); } OXYSelector::~OXYSelector() {} void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) { px = 2; py = 2; minX = _minX; minY = _minY; maxX = _maxX; maxY = _maxY; } void OXYSelector::setValues( int _xPos, int _yPos ) { xPos = _xPos; yPos = _yPos; if ( xPos > maxX ) xPos = maxX; else if ( xPos < minX ) xPos = minX; - + if ( yPos > maxY ) yPos = maxY; else if ( yPos < minY ) yPos = minY; int xp = 2 + (width() - 4) * xPos / (maxX - minX); int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); setPosition( xp, yp ); } QRect OXYSelector::contentsRect() const { return QRect( 2, 2, width()-4, height()-4 ); } void OXYSelector::paintEvent( QPaintEvent *ev ) { QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); QRect paintRect = ev->rect(); QPainter painter; painter.begin( this ); QBrush brush; qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), TRUE, 2, &brush ); drawContents( &painter ); if (paintRect.contains(cursorRect)) { bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, STORE_W2, STORE_W2, CopyROP ); drawCursor( &painter, px, py ); } else if (paintRect.intersects(cursorRect)) { repaint( cursorRect, false); } painter.end(); } void OXYSelector::mousePressEvent( QMouseEvent *e ) { int xVal, yVal; valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); setValues( xVal, yVal ); emit valueChanged( xPos, yPos ); } void OXYSelector::mouseMoveEvent( QMouseEvent *e ) { int xVal, yVal; valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); setValues( xVal, yVal ); emit valueChanged( xPos, yPos ); } void OXYSelector::wheelEvent( QWheelEvent *e ) { #if QT_VERSION > 290 if ( e->orientation() == Qt::Horizontal ) setValues( xValue() + e->delta()/120, yValue() ); else setValues( xValue(), yValue() + e->delta()/120 ); emit valueChanged( xPos, yPos ); #endif } void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const { xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); if ( xVal > maxX ) xVal = maxX; else if ( xVal < minX ) xVal = minX; if ( yVal > maxY ) yVal = maxY; else if ( yVal < minY ) yVal = minY; } void OXYSelector::setPosition( int xp, int yp ) { if ( xp < 2 ) xp = 2; else if ( xp > width() - 2 ) xp = width() - 2; if ( yp < 2 ) yp = 2; else if ( yp > height() - 2 ) yp = height() - 2; QPainter painter; painter.begin( this ); bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, STORE_W2, STORE_W2, CopyROP ); bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, STORE_W2, STORE_W2, CopyROP ); drawCursor( &painter, xp, yp ); px = xp; py = yp; painter.end(); } void OXYSelector::drawContents( QPainter * ) {} void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) { p->setPen( QPen( white ) ); p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); } //----------------------------------------------------------------------------- /* * 1D value selector with contents drawn by derived class. * See OColorDialog for example. */ OSelector::OSelector( QWidget *parent, const char *name ) : QWidget( parent, name ), QRangeControl() { _orientation = Horizontal; _indent = TRUE; } OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) : QWidget( parent, name ), QRangeControl() { _orientation = o; _indent = TRUE; } OSelector::~OSelector() {} QRect OSelector::contentsRect() const { if ( orientation() == Vertical ) return QRect( 2, 5, width()-9, height()-10 ); else return QRect( 5, 2, width()-10, height()-9 ); } void OSelector::paintEvent( QPaintEvent * ) { QPainter painter; painter.begin( this ); drawContents( &painter ); QBrush brush; if ( indent() ) { if ( orientation() == Vertical ) qDrawShadePanel( &painter, 0, 3, width()-5, height()-6, colorGroup(), TRUE, 2, &brush ); else qDrawShadePanel( &painter, 3, 0, width()-6, height()-5, colorGroup(), TRUE, 2, &brush ); } QPoint pos = calcArrowPos( value() ); - drawArrow( &painter, TRUE, pos ); + drawArrow( &painter, TRUE, pos ); painter.end(); } void OSelector::mousePressEvent( QMouseEvent *e ) { moveArrow( e->pos() ); } void OSelector::mouseMoveEvent( QMouseEvent *e ) { moveArrow( e->pos() ); } void OSelector::wheelEvent( QWheelEvent *e ) { int val = value() + e->delta()/120; emit valueChanged( val ); setValue( val ); } void OSelector::valueChange() { QPainter painter; QPoint pos; painter.begin( this ); pos = calcArrowPos( prevValue() ); - drawArrow( &painter, FALSE, pos ); + drawArrow( &painter, FALSE, pos ); pos = calcArrowPos( value() ); - drawArrow( &painter, TRUE, pos ); + drawArrow( &painter, TRUE, pos ); painter.end(); } void OSelector::moveArrow( const QPoint &pos ) { int val; if ( orientation() == Vertical ) val = ( maxValue() - minValue() ) * (height()-pos.y()-3) / (height()-10) + minValue(); else val = ( maxValue() - minValue() ) * (width()-pos.x()-3) / (width()-10) + minValue(); if ( val > maxValue() ) val = maxValue(); if ( val < minValue() ) val = minValue(); emit valueChanged( val ); setValue( val ); } QPoint OSelector::calcArrowPos( int val ) { QPoint p; if ( orientation() == Vertical ) { p.setY( height() - ( (height()-10) * val / ( maxValue() - minValue() ) + 5 ) ); p.setX( width() - 5 ); } else { p.setX( width() - ( (width()-10) * val / ( maxValue() - minValue() ) + 5 ) ); p.setY( height() - 5 ); } return p; } void OSelector::drawContents( QPainter * ) {} void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos ) { if ( show ) { QPointArray array(3); painter->setPen( QPen() ); painter->setBrush( QBrush( colorGroup().buttonText() ) ); if ( orientation() == Vertical ) { array.setPoint( 0, pos.x()+0, pos.y()+0 ); array.setPoint( 1, pos.x()+5, pos.y()+5 ); array.setPoint( 2, pos.x()+5, pos.y()-5 ); } else { array.setPoint( 0, pos.x()+0, pos.y()+0 ); array.setPoint( 1, pos.x()+5, pos.y()+5 ); array.setPoint( 2, pos.x()-5, pos.y()+5 ); } painter->drawPolygon( array ); - } - else + } + else { if ( orientation() == Vertical ) { repaint(pos.x(), pos.y()-5, 6, 11, true); } else { repaint(pos.x()-5, pos.y(), 11, 6, true); } } } //---------------------------------------------------------------------------- OGradientSelector::OGradientSelector( QWidget *parent, const char *name ) : OSelector( parent, name ) { init(); } OGradientSelector::OGradientSelector( Orientation o, QWidget *parent, const char *name ) : OSelector( o, parent, name ) { init(); } OGradientSelector::~OGradientSelector() {} void OGradientSelector::init() { color1.setRgb( 0, 0, 0 ); color2.setRgb( 255, 255, 255 ); - + text1 = text2 = ""; } void OGradientSelector::drawContents( QPainter *painter ) { QImage image( contentsRect().width(), contentsRect().height(), 32 ); QColor col; float scale; int redDiff = color2.red() - color1.red(); int greenDiff = color2.green() - color1.green(); int blueDiff = color2.blue() - color1.blue(); if ( orientation() == Vertical ) { for ( int y = 0; y < image.height(); y++ ) { scale = 1.0 * y / image.height(); col.setRgb( color1.red() + int(redDiff*scale), color1.green() + int(greenDiff*scale), color1.blue() + int(blueDiff*scale) ); unsigned int *p = (uint *) image.scanLine( y ); for ( int x = 0; x < image.width(); x++ ) *p++ = col.rgb(); } } else { unsigned int *p = (uint *) image.scanLine( 0 ); for ( int x = 0; x < image.width(); x++ ) { scale = 1.0 * x / image.width(); col.setRgb( color1.red() + int(redDiff*scale), color1.green() + int(greenDiff*scale), color1.blue() + int(blueDiff*scale) ); *p++ = col.rgb(); } for ( int y = 1; y < image.height(); y++ ) memcpy( image.scanLine( y ), image.scanLine( y - 1), sizeof( unsigned int ) * image.width() ); } QColor ditherPalette[8]; for ( int s = 0; s < 8; s++ ) ditherPalette[s].setRgb( color1.red() + redDiff * s / 8, color1.green() + greenDiff * s / 8, color1.blue() + blueDiff * s / 8 ); OImageEffect::dither( image, ditherPalette, 8 ); QPixmap p; p.convertFromImage( image ); painter->drawPixmap( contentsRect().x(), contentsRect().y(), p ); if ( orientation() == Vertical ) { int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2; int xPos = contentsRect().left() + (contentsRect().width() - painter->fontMetrics().width( text2 )) / 2; QPen pen( color2 ); painter->setPen( pen ); painter->drawText( xPos, yPos, text2 ); yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; - xPos = contentsRect().left() + (contentsRect().width() - + xPos = contentsRect().left() + (contentsRect().width() - painter->fontMetrics().width( text1 )) / 2; pen.setColor( color1 ); painter->setPen( pen ); painter->drawText( xPos, yPos, text1 ); } else { int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2; QPen pen( color2 ); painter->setPen( pen ); painter->drawText( contentsRect().left() + 2, yPos, text1 ); pen.setColor( color1 ); painter->setPen( pen ); painter->drawText( contentsRect().right() - painter->fontMetrics().width( text2 ) - 2, yPos, text2 ); } } //----------------------------------------------------------------------------- static QColor *standardPalette = 0; #define STANDARD_PAL_SIZE 17 OColor::OColor() : QColor() { r = 0; g = 0; b = 0; h = 0; s = 0; v = 0; }; OColor::OColor( const OColor &col) : QColor( col ) { h = col.h; s = col.s; v = col.v; r = col.r; g = col.g; b = col.b; }; OColor::OColor( const QColor &col) : QColor( col ) { QColor::rgb(&r, &g, &b); QColor::hsv(&h, &s, &v); }; bool OColor::operator==(const OColor& col) const { return (h == col.h) && (s == col.s) && (v == col.v) && (r == col.r) && (g == col.g) && (b == col.b); } OColor& OColor::operator=(const OColor& col) { *(QColor *)this = col; h = col.h; s = col.s; v = col.v; r = col.r; g = col.g; b = col.b; return *this; } void OColor::setHsv(int _h, int _s, int _v) { h = _h; s = _s; v = _v; QColor::setHsv(h, s, v); QColor::rgb(&r, &g, &b); }; void OColor::setRgb(int _r, int _g, int _b) { r = _r; g = _g; b = _b; QColor::setRgb(r, g, b); QColor::hsv(&h, &s, &v); } void OColor::rgb(int *_r, int *_g, int *_b) const { *_r = r; *_g = g; *_b = b; } void OColor::hsv(int *_h, int *_s, int *_v) const { *_h = h; *_s = s; *_v = v; } static void createStandardPalette() { if ( standardPalette ) return; standardPalette = new QColor[STANDARD_PAL_SIZE]; int i = 0; diff --git a/libopie2/opieui/oselector.h b/libopie2/opieui/oselector.h index f832239..fe75a46 100644 --- a/libopie2/opieui/oselector.h +++ b/libopie2/opieui/oselector.h @@ -1,125 +1,128 @@ /* This file is part of the KDE libraries Copyright (C) 1997 Martin Jones (mjones@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //----------------------------------------------------------------------------- // Selector widgets for KDE Color Selector, but probably useful for other // stuff also. #ifndef __OSELECT_H__ #define __OSELECT_H__ #include <qwidget.h> #include <qrangecontrol.h> #include <qpixmap.h> + +namespace Opie { +namespace Ui { /** * OXYSelector is the base class for other widgets which * provides the ability to choose from a two-dimensional * range of values. The currently chosen value is indicated * by a cross. An example is the @ref OHSSelector which * allows to choose from a range of colors, and which is * used in OColorDialog. * * A custom drawing routine for the widget surface has * to be provided by the subclass. */ class OXYSelector : public QWidget { Q_OBJECT public: /** * Constructs a two-dimensional selector widget which * has a value range of [0..100] in both directions. */ OXYSelector( QWidget *parent=0, const char *name=0 ); /** * Destructs the widget. */ ~OXYSelector(); /** * Sets the current values in horizontal and * vertical direction. */ void setValues( int xPos, int yPos ); /** * Sets the range of possible values. */ void setRange( int minX, int minY, int maxX, int maxY ); /** * @return the current value in horizontal direction. */ int xValue() const { return xPos; } /** * @return the current value in vertical direction. */ int yValue() const { return yPos; } /** * @return the rectangle on which subclasses should draw. */ QRect contentsRect() const; signals: /** * This signal is emitted whenever the user chooses a value, * e.g. by clicking with the mouse on the widget. */ void valueChanged( int x, int y ); protected: /** * Override this function to draw the contents of the widget. * The default implementation does nothing. * * Draw within @ref contentsRect() only. */ virtual void drawContents( QPainter * ); /** * Override this function to draw the cursor which * indicates the currently selected value pair. */ virtual void drawCursor( QPainter *p, int xp, int yp ); /** * @reimplemented */ virtual void paintEvent( QPaintEvent *e ); /** * @reimplemented */ virtual void mousePressEvent( QMouseEvent *e ); /** * @reimplemented */ virtual void mouseMoveEvent( QMouseEvent *e ); /** * @reimplemented */ virtual void wheelEvent( QWheelEvent * ); /** * Converts a pixel position to its corresponding values. */ void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const; private: void setPosition( int xp, int yp ); int px; int py; int xPos; @@ -419,100 +422,102 @@ private: private: class OHSSelectorPrivate; OHSSelectorPrivate *d; }; class OValueSelectorPrivate; /** * Widget for color value selection. * * @see OHSSelector, OColorDialog * @author Martin Jones (mjones@kde.org) * @version $Id$ */ class OValueSelector : public OSelector { Q_OBJECT public: /** * Constructs a widget for color selection. */ OValueSelector( QWidget *parent=0, const char *name=0 ); /** * Constructs a widget for color selection with a given orientation */ OValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 ); int hue() const { return _hue; } void setHue( int h ) { _hue = h; } int saturation() const { return _sat; } void setSaturation( int s ) { _sat = s; } void updateContents(); protected: /** * Draws the contents of the widget on a pixmap, * which is used for buffering. */ virtual void drawPalette( QPixmap *pixmap ); /** * @reimplemented */ virtual void resizeEvent( QResizeEvent * ); /** * Reimplemented from OSelector. The drawing is * buffered in a pixmap here. As real drawing * routine, drawPalette() is used. */ virtual void drawContents( QPainter *painter ); private: int _hue; int _sat; QPixmap pixmap; private: class OValueSelectorPrivate; OValueSelectorPrivate *d; }; class OColor : public QColor { public: OColor(); OColor( const OColor &col); OColor( const QColor &col); OColor& operator=( const OColor& col); bool operator==( const OColor& col) const; void setHsv(int _h, int _s, int _v); void setRgb(int _r, int _g, int _b); void rgb(int *_r, int *_g, int *_b) const; void hsv(int *_h, int *_s, int *_v) const; protected: int h; int s; int v; int r; int g; int b; private: class OColorPrivate; OColorPrivate *d; }; +} +} #endif // __OSELECT_H__ diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp index b93c225..bbc4381 100644 --- a/libopie2/opieui/oseparator.cpp +++ b/libopie2/opieui/oseparator.cpp @@ -1,127 +1,129 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/odebug.h> #include <opie2/oseparator.h> /* QT */ +using namespace Opie::Core; +using namespace Opie::Ui; OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f) { setLineWidth(1); setMidLineWidth(0); setOrientation( HLine ); } OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f) { setLineWidth(1); setMidLineWidth(0); setOrientation( orientation ); } void OSeparator::setOrientation(int orientation) { switch(orientation) { case Vertical: case VLine: setFrameStyle( QFrame::VLine | QFrame::Sunken ); setMinimumSize(2, 0); break; default: owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; case Horizontal: case HLine: setFrameStyle( QFrame::HLine | QFrame::Sunken ); setMinimumSize(0, 2); break; } } int OSeparator::orientation() const { if ( frameStyle() & VLine ) return VLine; if ( frameStyle() & HLine ) return HLine; return 0; } void OSeparator::drawFrame(QPainter *p) { QPoint p1, p2; QRect r = frameRect(); const QColorGroup & g = colorGroup(); if ( frameStyle() & HLine ) { p1 = QPoint( r.x(), r.height()/2 ); p2 = QPoint( r.x()+r.width(), p1.y() ); } else { p1 = QPoint( r.x()+r.width()/2, 0 ); p2 = QPoint( p1.x(), r.height() ); } #if QT_VERSION < 300 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); #else QStyleOption opt( lineWidth(), midLineWidth() ); style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); #endif } QSize OSeparator::sizeHint() const { if ( frameStyle() & VLine ) return QSize(2, 0); if ( frameStyle() & HLine ) return QSize(0, 2); return QSize(-1, -1); } diff --git a/libopie2/opieui/oseparator.h b/libopie2/opieui/oseparator.h index e59b3f4..6fc4344 100644 --- a/libopie2/opieui/oseparator.h +++ b/libopie2/opieui/oseparator.h @@ -1,90 +1,95 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OSEPARATOR_H #define OSEPARATOR_H #include <qframe.h> +namespace Opie { +namespace Ui { + /** * Standard horizontal or vertical separator. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> * @author Michael Roth <mroth@wirlweb.de> * @version $Id$ */ class OSeparator : public QFrame { Q_OBJECT Q_PROPERTY( int orientation READ orientation WRITE setOrientation ) public: /** * Constructor. **/ OSeparator(QWidget* parent=0, const char* name=0, WFlags f=0); /** * Constructor. * * @param orientation Set the orientation of the separator. * Possible values are HLine or Horizontal and VLine or Vertical. **/ OSeparator(int orientation, QWidget* parent=0, const char* name=0, WFlags f=0); /** * Returns the orientation of the separator. * * Possible values are VLine and HLine. **/ int orientation() const; /** * Set the orientation of the separator to @p orient * * Possible values are VLine and HLine. */ void setOrientation(int orient); /** * The recommended height (width) for a horizontal (vertical) separator. **/ virtual QSize sizeHint() const; protected: virtual void drawFrame( QPainter * ); private: class OSeparatorPrivate* d; }; +} +} #endif // OSEPARATOR_H diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp index cd3a34b..a62e18b 100644 --- a/libopie2/opieui/otabbar.cpp +++ b/libopie2/opieui/otabbar.cpp @@ -1,83 +1,83 @@ /* This file is part of the Opie Project Copyright (c) 2002 Dan Williams <williamsdr@acm.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/otabbar.h> -using namespace Opie; +using namespace Opie::Ui; OTabBar::OTabBar( QWidget *parent , const char *name ) :QTabBar( parent, name ) {} void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const { QRect r = br; if ( t->iconset) { QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && has_focus ) { mode = QIconSet::Active; } QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); r.setLeft( r.left() + pixw + 2 ); p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); } QRect tr = r; if ( t->id == currentTab() ) { tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); } if ( t->enabled && isEnabled() ) { p->setPen( colorGroup().foreground() ); p->drawText( tr, AlignCenter | ShowPrefix, t->label ); } else if ( style() == MotifStyle ) { p->setPen( palette().disabled().foreground() ); p->drawText( tr, AlignCenter | ShowPrefix, t->label ); } else { p->setPen( colorGroup().light() ); QRect wr = tr; wr.moveBy( 1, 1 ); p->drawText( wr, AlignCenter | ShowPrefix, t->label ); p->setPen( palette().disabled().foreground() ); p->drawText( tr, AlignCenter | ShowPrefix, t->label ); } } diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h index 2f35c85..925ae96 100644 --- a/libopie2/opieui/otabbar.h +++ b/libopie2/opieui/otabbar.h @@ -1,85 +1,86 @@ /* This file is part of the Opie Project Copyright (c) 2002 Dan Williams <williamsdr@acm.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTABBAR_H #define OTABBAR_H /* QT */ #include <qtabbar.h> -namespace Opie -{ +namespace Opie { +namespace Ui { /** * @class OTabBar * @brief The OTabBar class is a derivative of QTabBar. * * OTabBar is a derivation of TrollTech's QTabBar which provides * a row of tabs for selection. The only difference between this * class and QTabBar is that there is no dotted line box around * the label of the tab with the current focus. */ class OTabBar : public QTabBar { Q_OBJECT public: /** * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) * @brief Object constructor. * * @param parent Pointer to parent of this control. * @param name Name of control. * * Constructs a new OTabBar control with parent and name. */ OTabBar( QWidget * = 0, const char * = 0 ); protected: /** * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const * @brief Internal function to draw a tab's label. * * @param p Pointer to QPainter used for drawing. * @param br QRect providing region to draw label in. * @param t Tab to draw label for. * @param has_focus Boolean value not used, retained for compatibility reasons. */ void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; private: class Private; Private *d; }; -}; +} +} #endif diff --git a/libopie2/opieui/otabinfo.h b/libopie2/opieui/otabinfo.h index 4a6ce14..426c45a 100644 --- a/libopie2/opieui/otabinfo.h +++ b/libopie2/opieui/otabinfo.h @@ -1,140 +1,141 @@ /* This file is part of the Opie Project Copyright (c) 2002 Dan Williams <williamsdr@acm.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTABINFO_H #define OTABINFO_H /* QT */ #include <qlist.h> #include <qstring.h> class QWidget; -namespace Opie -{ +namespace Opie{ +namespace Ui { /** * @class OTabInfo * @brief The OTabInfo class is used internally by OTabWidget to keep track * of widgets added to the control. * * OTabInfo provides the following information about a widget added to an * OTabWidget control: * * ID - integer tab bar ID * Control - QWidget pointer to child widget * Label - QString text label for OTabWidget selection control * Icon - QString name of icon file */ class OTabInfo { public: /** * @fn OTabInfo() * @brief Object constructor. * * @param parent Pointer to parent of this control. * @param name Name of control. * @param s Style of widget selection control. * @param p Position of the widget selection control. */ OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} /** * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) * @brief Object constructor. * * @param id TabBar identifier for widget. * @param control QWidget pointer to widget. * @param icon QString name of icon file. * @param label QString text label for OTabWidget selection control. */ OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) : i( id ), c( control ), p( icon ), l( label ) {} /** * @fn id()const * @brief Returns TabBar ID. */ int id() const { return i; } /** * @fn label()const * @brief Returns text label for widget. */ const QString &label() const { return l; } /** * @fn setLabel( const QString &label ) * @brief Set label for tab. * * @param label QString text label for OTabWidget selection control. */ void setLabel( const QString &label ) { l = label; } /** * @fn control()const * @brief Returns pointer to widget. */ QWidget *control() const { return c; } /** * @fn icon()const * @brief Returns name of icon file. */ const QString &icon() const { return p; } /** * @fn setIcon( const QString &icon ) * @brief Set icon for tab. * * @param icon QString name of icon file. */ void setIcon( const QString &icon ) { p = icon; } private: int i; QWidget *c; QString p; QString l; class Private; Private *d; }; /** * @class OTabInfoList * @brief A list of OTabInfo objects used by OTabWidget. */ typedef QList<OTabInfo> OTabInfoList; -}; +} +} #endif diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp index f47c90b..a9f7da9 100644 --- a/libopie2/opieui/otabwidget.cpp +++ b/libopie2/opieui/otabwidget.cpp @@ -1,140 +1,140 @@ /* This file is part of the Opie Project Copyright (c) 2002 Dan Williams <williamsdr@acm.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/otabwidget.h> /* OPIE */ #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/resource.h> #include <opie2/otabbar.h> /* QT */ #include <qcombobox.h> #include <qwidgetstack.h> -using namespace Opie; +using namespace Opie::Ui; OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) : QWidget( parent, name ) { if ( s == Global ) { Config config( "qpe" ); config.setGroup( "Appearance" ); s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); if ( s <= Global || s > IconList) { s = IconTab; } QString pos = config.readEntry( "TabPosition", "Top"); if ( pos == "Bottom" ) { p = Bottom; } else { p = Top; } } widgetStack = new QWidgetStack( this, "widgetstack" ); widgetStack->setFrameStyle( QFrame::NoFrame ); widgetStack->setLineWidth( style().defaultFrameWidth() ); tabBarStack = new QWidgetStack( this, "tabbarstack" ); tabBar = new OTabBar( tabBarStack, "tabbar" ); tabBarStack->addWidget( tabBar, 0 ); connect( tabBar, SIGNAL( selected(int) ), this, SLOT( slotTabBarSelected(int) ) ); tabList = new QComboBox( false, tabBarStack, "tablist" ); tabBarStack->addWidget( tabList, 1 ); connect( tabList, SIGNAL( activated(int) ), this, SLOT( slotTabListSelected(int) ) ); tabBarPosition = p; setTabStyle( s ); setTabPosition( p ); currTab= 0x0; } OTabWidget::~OTabWidget() {} void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) { QPixmap iconset = loadSmooth( icon ); QTab *tab = new QTab(); if ( tabBarStyle == IconTab ) { tab->label = QString::null; } else { tab->label = label; } if ( tabBarStyle == IconTab || tabBarStyle == IconList ) { tab->iconset = new QIconSet( iconset ); } int tabid = tabBar->addTab( tab ); if ( tabBarStyle == IconTab || tabBarStyle == IconList ) { tabList->insertItem( iconset, label, -1 ); } else { tabList->insertItem( label ); } widgetStack->addWidget( child, tabid ); widgetStack->raiseWidget( child ); widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); tabs.append( tabinfo ); selectTab( tabinfo ); } void OTabWidget::removePage( QWidget *childwidget ) { if ( childwidget ) { OTabInfo *tab = tabs.first(); while ( tab && tab->control() != childwidget ) { tab = tabs.next(); } if ( tab && tab->control() == childwidget ) { diff --git a/libopie2/opieui/otabwidget.h b/libopie2/opieui/otabwidget.h index 092f22c..6a64b7d 100644 --- a/libopie2/opieui/otabwidget.h +++ b/libopie2/opieui/otabwidget.h @@ -1,145 +1,144 @@ /* This file is part of the Opie Project Copyright (C) 2002 Dan Williams <williamsdr@acm.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTABWIDGET_H #define OTABWIDGET_H /* OPIE */ #include <opie2/otabinfo.h> /* QT */ #include <qwidget.h> #include <qlist.h> -using namespace Opie; class QComboBox; class QPixmap; class QTabBar; class QWidgetStack; -namespace Opie -{ +namespace Opie { +namespace Ui { class OTabBar; /** * @class OTabWidget * @brief The OTabWidget class provides a stack of widgets. * * OTabWidget is a derivation of TrollTech's QTabWidget which provides * a stack of widgets. Widgets can be selected using either a tab bar or * drop down list box. * * The normal way to use OTabWidget is to do the following in the * constructor: * - Create a OTabWidget. * - Create a QWidget for each of the pages in the control, insert * children into it, set up geometry management for it, and use addTab() * to add the widget. */ class OTabWidget : public QWidget { Q_OBJECT public: /** * @enum TabStyle * @brief Defines how the widget selection control is displayed. * * Valid values: * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) * - TextTab: Tabbed widget selection with text labels * - IconTab: Tabbed widget selection with icon labels, text label for active widget * (similar to Opie launcher) * - TextList: Drop down list widget selection with text labels * - IconList: Drop down list widget selection with icon & text labels */ enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; /** * @enum TabPosition * @brief Defines where the widget selection control is drawn. * * Valid values: * - Top: Widget selection control is drawn above widgets * - Bottom: Widget selection control is drawn below widgets */ enum TabPosition { Top, Bottom }; /** * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) * @brief Object constructor. * * @param parent Pointer to parent of this control. * @param name Name of control. * @param s Style of widget selection control. * @param p Position of the widget selection control. * * Constructs a new OTabWidget control with parent and name. The style and position parameters * determine how the widget selection control will be displayed. */ OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); /** * @fn ~OTabWidget() * @brief Object destructor. */ ~OTabWidget(); /** * @fn addTab( QWidget *child, const QString &icon, const QString &label ) * @brief Add new widget to control. * * @param child Widget control. * @param icon Path to icon. * @param label Text label. */ void addTab( QWidget *, const QString &, const QString & ); /** * @fn removePage( QWidget *widget ) * @brief Remove widget from control. Does not delete widget. * * @param widget Widget control to be removed. */ void removePage( QWidget * ); /** * @fn changeTab( QWidget *widget, const QString &icon, const QString &label ) * @brief Change text and/or icon for existing tab * * @param child Widget control. * @param icon Path to icon. * @param label Text label. */ void changeTab( QWidget *, const QString &, const QString & ); /** @@ -194,99 +193,100 @@ class OTabWidget : public QWidget */ void setCurrentTab(int); /** * @fn sizeHint()const * @brief Reimplemented for internal purposes. */ QSize sizeHint() const; /** * @fn currentTab( ) * @brief returns current tab id. */ // ### make const int currentTab()/* const */; /** * @brief returns the current page of the active tab * * @since 1.2 */ QWidget* currentWidget()const; protected: /** * @fn resizeEvent( QResizeEvent * ) * @brief Reimplemented for internal purposes. */ void resizeEvent( QResizeEvent * ); private: OTabInfoList tabs; OTabInfo *currTab; TabStyle tabBarStyle; TabPosition tabBarPosition; QWidgetStack *tabBarStack; OTabBar *tabBar; QComboBox *tabList; QWidgetStack *widgetStack; class Private; Private* d; /** * @fn loadSmooth( const QString &name ) * @brief Loads icon for widget. * * @param name Name of icon image file. */ QPixmap loadSmooth( const QString & ); /** * @fn selectTab( OTabInfo *tab ) * @brief Internal function to select desired widget. * * @param tab Pointer to data for widget. */ void selectTab( OTabInfo * ); /** * @fn setUpLayout() * @brief Internal function to adjust layout. */ void setUpLayout(); signals: /** * @fn currentChanegd( QWidget *widget ) * @brief This signal is emitted whenever the widget has changed. * * @param widget Pointer to new current widget. */ void currentChanged( QWidget * ); private slots: /** * @fn slotTabBarSelected( int id ) * @brief Slot which is called when a tab is selected. * * @param id ID of widget selected. */ void slotTabBarSelected( int ); /** * @fn slotTabListSelected( int index ) * @brief Slot which is called when a drop down selection is made. * * @param id Index of widget selected. */ void slotTabListSelected( int ); }; -}; +} +} #endif diff --git a/libopie2/opieui/otaskbarapplet.cpp b/libopie2/opieui/otaskbarapplet.cpp index a67356d..b5268f0 100644 --- a/libopie2/opieui/otaskbarapplet.cpp +++ b/libopie2/opieui/otaskbarapplet.cpp @@ -1,32 +1,82 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <opie2/otaskbarapplet.h> + +#include <qpe/qpeapplication.h> +#include <qframe.h> + +using namespace Opie::Ui; + + +/** + * \todo no example yet!!! + * If you want to implement an Applet for the Opie Taskbar + * use this interface. + * The only specail thing about applets is that you need to build + * it as plugin/library and do EXPORT_OPIE_APPLET_v1( YourApplet ) + * at the bottom of your application. This takes care of + * the activation and implementing the TaskbarAppletInterface. + * You also need to add a static int position() functions to your + * application. + * \code + * class MyApplet : public OTaskBarApplet { + * public: + * static int position() { return 3: } + * void doStuff() { + * popup( myWidget ); + * } + * }; + * EXPORT_OPIE_APPLET_v1( MyApplet ) + * \endcode + * + * @author Michael Lauer + * @version 0.5 + * @see TaskbarAppletInterface + */ +OTaskbarApplet::OTaskbarApplet( QWidget* parent, const char* name ) + :QWidget( parent, name ){ + setFixedHeight( 18 ); + setFixedWidth( 14 ); +} + +OTaskbarApplet::~OTaskbarApplet(){ +} + +void OTaskbarApplet::popup( QWidget* widget ){ + QPoint curPos = mapToGlobal( QPoint( 0, 0 ) ); + int w = widget->sizeHint().width(); + int x = curPos.x() - (w/2 ); + if ( (x+w) > QPEApplication::desktop()->width() ) + x = QPEApplication::desktop()->width()-w; + widget->move( x, curPos.y()-widget->sizeHint().height() ); + widget->show(); +} -// Empty on purpose until we shipped Opie 1.0 (see otaskbarapplet.h for explanation) diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h index 074367f..0c85ee7 100644 --- a/libopie2/opieui/otaskbarapplet.h +++ b/libopie2/opieui/otaskbarapplet.h @@ -1,130 +1,129 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTASKBARAPPLET_H #define OTASKBARAPPLET_H #include <qpe/taskbarappletinterface.h> +#include <qpe/qcom.h> +#include <qwidget.h> + +class QMouseEvent; + +namespace Opie { +namespace Ui { +namespace Private { /*====================================================================================== * OTaskbarAppletWrapper *======================================================================================*/ +class OTaskbarAppletWrapperPrivate; template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface { public: OTaskbarAppletWrapper():_applet( 0 ) { } virtual ~OTaskbarAppletWrapper() { delete _applet; } QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) { qDebug( "OTaskbarAppletWrapper::queryInterface()" ); *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_TaskbarApplet ) *iface = this; else return QS_FALSE; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT virtual T* applet( QWidget* parent ) { if ( !_applet ) _applet = new T( parent ); return _applet; } virtual int position() const { return T::position(); } private: T* _applet; + OTaskbarAppletWrapperPrivate *d; }; -#include <qframe.h> -#include <qwidget.h> -#include <qpe/qpeapplication.h> - -class QMouseEvent; - +} /*====================================================================================== * OTaskbarApplet *======================================================================================*/ // Must be inline until after we shipped Opie 1.0 // Having OTaskBarApplet reside in libopieui2 is not possible // until we link the launcher binary against libopieui2 - // otherwise the necessary symbols are not present, when // the dynamic loader [dlopen] tries to resolve an applet which // inherits OTaskbarApplet class OTaskbarApplet : public QWidget { public: - OTaskbarApplet( QWidget* parent, const char* name = 0 ):QWidget( parent, name ) - { - setFixedHeight( 18 ); - setFixedWidth( 14 ); - } - - virtual ~OTaskbarApplet() - { - } + OTaskbarApplet( QWidget* parent, const char* name = 0 ); + virtual ~OTaskbarApplet(); protected: - virtual void popup( QWidget* widget ) - { - QPoint curPos = mapToGlobal( QPoint( 0, 0 ) ); - int w = widget->sizeHint().width(); - int x = curPos.x() - (w/2 ); - if ( (x+w) > QPEApplication::desktop()->width() ) - x = QPEApplication::desktop()->width()-w; - widget->move( x, curPos.y()-widget->sizeHint().height() ); - widget->show(); - } + virtual void popup( QWidget* widget ); +private: + class Private; + Private *d; }; +} +} + +#define EXPORT_OPIE_APPLET_v1( AppLet ) \ + Q_EXPORT_INTERFACE() { \ + Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<AppLet> ) \ + } #endif diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp index 66f9ce0..7de0fd3 100644 --- a/libopie2/opieui/otimepicker.cpp +++ b/libopie2/opieui/otimepicker.cpp @@ -1,292 +1,301 @@ /* This file is part of the Opie Project Copyright (C) Stefan Eilers <eilers.stefan@epost.de> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* OPIE */ +#include <opie2/otimepicker.h> + /* QT */ +#include <qgroupbox.h> #include <qlayout.h> #include <qlineedit.h> -/* OPIE */ -#include <opie2/otimepicker.h> -using namespace Opie; + +namespace Opie { +namespace Ui { /** * Constructs the widget * @param parent The parent of the OTimePicker * @param name The name of the object * @param fl Window Flags */ OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) :QWidget(parent,name,fl) { QVBoxLayout *vbox=new QVBoxLayout(this); OClickableLabel *r; QString s; // Hour Row QWidget *row=new QWidget(this); QHBoxLayout *l=new QHBoxLayout(row); vbox->addWidget(row); for (int i=0; i<24; i++) { r=new OClickableLabel(row); hourLst.append(r); s.sprintf("%.2d",i); r->setText(s); r->setToggleButton(true); r->setAlignment(AlignHCenter | AlignVCenter); l->addWidget(r); connect(r, SIGNAL(toggled(bool)), this, SLOT(slotHour(bool))); if (i==11) { // Second row row=new QWidget(this); l=new QHBoxLayout(row); vbox->addWidget(row); } } // Minute Row row=new QWidget(this); l=new QHBoxLayout(row); vbox->addWidget(row); for (int i=0; i<60; i+=5) { r=new OClickableLabel(row); minuteLst.append(r); s.sprintf("%.2d",i); r->setText(s); r->setToggleButton(true); r->setAlignment(AlignHCenter | AlignVCenter); l->addWidget(r); connect(r, SIGNAL(toggled(bool)), this, SLOT(slotMinute(bool))); } } /** * This method return the current time * @return the time */ QTime OTimePicker::time()const { return tm; } void OTimePicker::slotHour(bool b) { OClickableLabel *r = (OClickableLabel *) sender(); if (b) { QValueListIterator<OClickableLabel *> it; for (it=hourLst.begin(); it!=hourLst.end(); it++) { if (*it != r) (*it)->setOn(false); else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); } emit timeChanged(tm); } else { r->setOn(true); } } void OTimePicker::slotMinute(bool b) { OClickableLabel *r = (OClickableLabel *) sender(); if (b) { QValueListIterator<OClickableLabel *> it; for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { if (*it != r) (*it)->setOn(false); else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); } emit timeChanged(tm); } else { r->setOn(true); } } /** * Method to set the time. No signal gets emitted during this method call * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) * @param t The time to be set */ void OTimePicker::setTime( const QTime& t) { setTime( t.hour(), t.minute() ); } /** * Method to set the time. No signal gets emitted during this method call * @param h The hour * @param m The minute. Minutes need to set by 5 minute steps */ void OTimePicker::setTime( int h, int m ) { setHour(h); setMinute(m); } /* * FIXME round minutes to the 5 minute arrangement -zecke */ /** * Method to set the minutes * @param m minutes */ void OTimePicker::setMinute(int m) { QString minute; minute.sprintf("%.2d",m); QValueListIterator<OClickableLabel *> it; for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { if ((*it)->text() == minute) (*it)->setOn(true); else (*it)->setOn(false); } tm.setHMS(tm.hour(),m,0); } /** * Method to set the hour */ void OTimePicker::setHour(int h) { QString hour; hour.sprintf("%.2d",h); QValueListIterator<OClickableLabel *> it; for (it=hourLst.begin(); it!=hourLst.end(); it++) { if ((*it)->text() == hour) (*it)->setOn(true); else (*it)->setOn(false); } tm.setHMS(h,tm.minute(),0); } /** * This is a modal Dialog. * * @param parent The parent widget * @param name The name of the object * @param fl Possible window flags */ OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) : OTimePickerDialogBase (parent , name, true , fl) { + m_timePicker = new OTimePicker( GroupBox1, "m_timePicker" ); + GroupBox1Layout->addWidget( m_timePicker, 0, 0 ); connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ), this, SLOT( setTime(const QTime&) ) ); connect ( minuteField, SIGNAL( textChanged(const QString&) ), this, SLOT ( setMinute(const QString&) ) ); connect ( hourField, SIGNAL( textChanged(const QString&) ), this, SLOT ( setHour(const QString&) ) ); } /** * @return the time */ QTime OTimePickerDialog::time()const { return m_time; } /** * Set the time to time * @param time The time to be set */ void OTimePickerDialog::setTime( const QTime& time ) { m_time = time; m_timePicker->setHour ( time.hour() ); m_timePicker->setMinute( time.minute() ); // Set Textfields if ( time.hour() < 10 ) hourField->setText( "0" + QString::number( time.hour() ) ); else hourField->setText( QString::number( time.hour() ) ); if ( time.minute() < 10 ) minuteField->setText( "0" + QString::number( time.minute() ) ); else minuteField->setText( QString::number( time.minute() ) ); } /** * This method takes the current minute and tries to set hour * to hour. This succeeds if the resulting date is valid * @param hour The hour as a string */ void OTimePickerDialog::setHour ( const QString& hour ) { if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) { m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); setTime ( m_time ); } } /** * Method to set a new minute. It tries to convert the string to int and * if the resulting date is valid a new date is set. * @see setHour */ void OTimePickerDialog::setMinute ( const QString& minute ) { if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) { m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); setTime ( m_time ); } } + +} +} diff --git a/libopie2/opieui/otimepicker.h b/libopie2/opieui/otimepicker.h index 2da7773..01bb557 100644 --- a/libopie2/opieui/otimepicker.h +++ b/libopie2/opieui/otimepicker.h @@ -1,125 +1,132 @@ /* This file is part of the Opie Project Copyright (C) Stefan Eilers <eilers.stefan@epost.de> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTIMEPICKER_H #define OTIMEPICKER_H /* OPIE */ #include <opie2/oclickablelabel.h> -#include "otimepickerbase.h" +#include <opie2/otimepickerbase.h> /* QT */ #include <qwidget.h> #include <qvaluelist.h> #include <qdatetime.h> #include <qdialog.h> -using namespace Opie; -// namespace Opie -// { +namespace Opie { +namespace Ui { /** * A class to pick time. It uses clickable labels * internally to allow a quick selection of a time. * A time can be selected by two clicks of a user * * @short A widget to quickly pick a QTime * @version 1.0 * @see QWidget * @see QTime * @author Hakan Ardo, Stefan Eilers */ -class OTimePicker: public QWidget +class OTimePicker : public QWidget { Q_OBJECT public: OTimePicker(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); public slots: void setHour(int h); void setMinute(int m); void setTime( const QTime& ); void setTime( int h, int m ); public: QTime time()const; private: QValueList<OClickableLabel *> hourLst; QValueList<OClickableLabel *> minuteLst; QTime tm; struct Private; Private *d; private slots: void slotHour(bool b); void slotMinute(bool b); signals: /** * gets emitted when the time got changed by the user */ void timeChanged(const QTime &); }; /** * * @short A small dialog to pick a time * @version 1.0 * @author Stefan Eilers * **/ class OTimePickerDialog: public OTimePickerDialogBase { Q_OBJECT public: OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 ); ~OTimePickerDialog() { }; QTime time()const; public slots: void setTime( const QTime& time ); void setHour( const QString& hour ); void setMinute( const QString& minute ); private: + OTimePicker *m_timePicker; QTime m_time; class Private; Private* d; }; -// }; +} +} +/* for Qt2 */ +#if ( QT_VERSION-0 >= 0x030000 ) +#error "Fix the UI File to use namespaces" +#else +typedef Opie::Ui::OTimePicker OUIOTimePicker; +#endif #endif diff --git a/libopie2/opieui/otimepickerbase.ui b/libopie2/opieui/otimepickerbase.ui index 3e7f2fb..c2eb7c5 100644 --- a/libopie2/opieui/otimepickerbase.ui +++ b/libopie2/opieui/otimepickerbase.ui @@ -1,110 +1,110 @@ <!DOCTYPE UI><UI> <class>OTimePickerDialogBase</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>OTimePickerDialogBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>210</width> + <width>182</width> <height>137</height> </rect> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>3</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>caption</name> <string>OTimePickerDialogBase</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>4</number> </property> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame10</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>1</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Raised</enum> </property> <property> <name>layoutMargin</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <spacer> <property> <name>name</name> <cstring>Spacer4</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>MinimumExpanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame4</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>4</hsizetype> <vsizetype>4</vsizetype> </sizepolicy> </property> @@ -156,137 +156,101 @@ </sizepolicy> </property> <property stdset="1"> <name>alignment</name> <set>AlignHCenter</set> </property> <property> <name>hAlign</name> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>font</name> <font> <bold>1</bold> </font> </property> <property stdset="1"> <name>text</name> <string>:</string> </property> </widget> <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>minuteField</cstring> </property> <property stdset="1"> <name>alignment</name> <set>AlignHCenter</set> </property> <property> <name>hAlign</name> </property> </widget> </hbox> </widget> <spacer> <property> <name>name</name> <cstring>Spacer5</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>MinimumExpanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </hbox> </widget> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>3</hsizetype> <vsizetype>3</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>title</name> <string>Pick Time:</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget row="0" column="0" > - <class>OTimePicker</class> - <property stdset="1"> - <name>name</name> - <cstring>m_timePicker</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>3</hsizetype> - <vsizetype>3</vsizetype> - </sizepolicy> - </property> - </widget> </grid> </widget> </vbox> </widget> -<customwidgets> - <customwidget> - <class>OTimePicker</class> - <header location="local">otimepicker.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>7</hordata> - <verdata>1</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> </UI> diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp index 78154b7..f6c6410 100644 --- a/libopie2/opieui/oversatileview.cpp +++ b/libopie2/opieui/oversatileview.cpp @@ -1,317 +1,320 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/odebug.h> #include <opie2/oversatileview.h> #include <opie2/oversatileviewitem.h> #include <opie2/olistview.h> /* QT */ #include <qaction.h> #include <qpopupmenu.h> +using namespace Opie::Core; +using namespace Opie::Ui; + /* XPM */ static const char * view_icon_xpm[] = { "16 16 16 1", " c None", ". c #87BD88", "+ c #8BBE8B", "@ c #81BA81", "# c #6DAF6D", "$ c #87BD87", "% c #FCFDFC", "& c #AED0AE", "* c #4E9C4C", "= c #91BD91", "- c #72B172", "; c #448643", "> c #519F50", ", c #499247", "' c #356A35", ") c #686868", " ", " .+@# .+@# ", " $%&* $%&* ", " @=-; @=-; ", " #>,' #>,' ", " ", " )))))) )))))) ", " ", " ", " .+@# .+@# ", " $%&* $%&* ", " @=-; @=-; ", " #>,' #>,' ", " ", " )))))) )))))) ", " "}; /* XPM */ static const char * view_tree_xpm[] = { "16 16 17 1", " c None", ". c #3A3A3A", "+ c #87BD88", "@ c #8BBE8B", "# c #81BA81", "$ c #6DAF6D", "% c #87BD87", "& c #FCFDFC", "* c #AED0AE", "= c #4E9C4C", "- c #91BD91", "; c #72B172", "> c #448643", ", c #686868", "' c #519F50", ") c #499247", "! c #356A35", " . ", " . ", " . +@#$ ", " . %&*= ", " .. #-;> ,, ,,,", " . $')! ", " . ", " . ", " . ", " . +@#$ ", " . %&*= ", " .. #-;> ,, ,,,", " $')! ", " ", " ", " "}; OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) :QWidgetStack( parent, name ), _viewmode( mode ), _warningpolicy( None ), _treeleaf(), _treeopened(), _treeclosed(), _iconleaf(), _iconopened(), _iconclosed() { // // Create child widgets and set some reasonable default styles // _listview = new OListView( this, "oversatileview embedded listview" ); _iconview = new QIconView( this, "oversatileview embedded iconview" ); _listview->setAllColumnsShowFocus( true ); _listview->setRootIsDecorated( true ); _listview->setShowSortIndicator( true ); _iconview->setGridX( 90 ); _iconview->setGridY( 42 ); _iconview->setAutoArrange( true ); - + #ifdef QWS // TODO: Let this depend on current geometry (rotation) _iconview->setArrangement( QIconView::TopToBottom ); #else _iconview->setArrangement( QIconView::LeftToRight ); #endif - + _iconview->setResizeMode( QIconView::Adjust ); - + // qt-embedded: map stylus right on hold to right button press #ifdef QWS ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); #endif setViewMode( mode ); // TODO: Read last style from config // setSynchronization( true ); // TODO: Implement this // create context menu allowing to switch between the views _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); _contextmenu->setCaption( "Style" ); _contextmenu->setCheckable( true ); QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), "View Icons", 0, ag, "viewicon action", true ); QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), "View Tree", 0, ag, "viewtree action", true ); ag->addTo( _contextmenu ); if ( mode == Icons ) a1->setOn( true ); else if ( mode == Tree ) a2->setOn( true ); connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); - + #if (QT_VERSION >= 0x030000) connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); #else connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); #endif - + // // signal forwarders // // unfortunately we can't short-circuit all the QListView and QIconView signals // to OVersatileView signals, because the signal/slot mechanism doesn't allow // type-conversion :-( // common signals for listview - + connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) ); - connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); + connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) ); connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) ); - + connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) ); connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) ); - + connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) ); connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); // common signals for iconview - + connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) ); - connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); + connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) ); connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) ); - + connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) ); connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) ); - + connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) ); connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); - + // listview only signals - + connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) ); connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) ); - + // iconview only signals - + connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); } OVersatileView::~OVersatileView() { } QPopupMenu* OVersatileView::contextMenu() const { return _contextmenu; } void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) { // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, // do not inherit from QObject - assuming here the programmer is // disciplined enough to only add OVersatileViewItems to an OVersatileView popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); } void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) { // see above popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); } void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) { if ( !item ) _contextmenu->exec( pos ); else emit( contextMenuRequested( item, pos, col ) ); } void OVersatileView::setSynchronization( bool sync ) { _synchronization = sync; } bool OVersatileView::synchronization() { return _synchronization; } void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) { if ( mode == Tree ) { _treeleaf = leaf; _treeopened = opened; _treeclosed = closed; } else if ( mode == Icons ) { _iconleaf = leaf; _iconopened = opened; _iconclosed = closed; } else { odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; } } QIconView* OVersatileView::iconView() const { return _iconview; } OListView* OVersatileView::listView() const { return _listview; } void OVersatileView::setViewMode( int mode ) { if ( mode == Tree ) { _viewmode = mode; raiseWidget( _listview ); } else if ( mode == Icons ) { _viewmode = mode; raiseWidget( _iconview ); } else { odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; } } void OVersatileView::setIconViewMode() { setViewMode( Icons ); } @@ -327,226 +330,226 @@ bool OVersatileView::isValidViewMode( int mode ) const { case OVersatileView::None: { return true; } case OVersatileView::Warn: { if ( _viewmode != mode ) { odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; return true; } } case OVersatileView::WarnReturn: { if ( _viewmode != mode ) { odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; return false; } } default: { owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; return true; } } } void OVersatileView::setWarningPolicy( int policy ) const { _warningpolicy = policy; } bool OVersatileView::warningPolicy() const { return _warningpolicy; } //==============================================================================================// // Stupid Signal forwarders... // Folks, this is why I like python with its dynamic typing: // I can code the following dozens of lines C++ in four Python lines... //==============================================================================================// void OVersatileView::selectionChanged( QListViewItem * item ) { emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::selectionChanged( QIconViewItem * item ) { emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::currentChanged( QListViewItem * item ) { emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::currentChanged( QIconViewItem * item ) { emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::clicked( QListViewItem * item ) { emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::clicked( QIconViewItem * item ) { emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::pressed( QListViewItem * item ) { emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::pressed( QIconViewItem * item ) { emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::doubleClicked( QListViewItem * item ) { emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::doubleClicked( QIconViewItem * item ) { emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::returnPressed( QListViewItem * item ) { emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); } - + void OVersatileView::returnPressed( QIconViewItem * item ) { emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::onItem( QListViewItem * item ) { emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::onItem( QIconViewItem * item ) { emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::expanded( QListViewItem *item ) // QListView { //odebug << "OVersatileView::expanded(): opening tree..." << oendl; if ( !_treeopened.isNull() ) item->setPixmap( 0, _treeopened ); emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::collapsed( QListViewItem *item ) // QListView { if ( !_treeclosed.isNull() ) item->setPixmap( 0, _treeclosed ); emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); } //=============================================================================================// // OVersatileView Case I - API only existing in QListView or QIconView but not in both! //==============================================================================================// - + int OVersatileView::treeStepSize() const // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->treeStepSize(); } void OVersatileView::setTreeStepSize( int size ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setTreeStepSize( size ); } QHeader * OVersatileView::header() const // QListView { if ( !isValidViewMode( Tree ) ) { return 0; } return _listview->header(); } int OVersatileView::addColumn( const QString &label, int size ) // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->addColumn( label, size ); } int OVersatileView::addColumn( const QIconSet& iconset, const QString &label, int size ) // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->addColumn( iconset, label, size ); } void OVersatileView::removeColumn( int index ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->removeColumn( index ); } void OVersatileView::setColumnText( int column, const QString &label ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setColumnText( column, label ); } void OVersatileView::setColumnText( int column, const QIconSet& iconset, const QString &label ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setColumnText( column, iconset, label ); } QString OVersatileView::columnText( int column ) const // QListView { if ( !isValidViewMode( Tree ) ) { return QString::null; } return _listview->columnText( column ); } void OVersatileView::setColumnWidth( int column, int width ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setColumnWidth( column, width ); } int OVersatileView::columnWidth( int column ) const // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->columnWidth( column ); } void OVersatileView::setColumnWidthMode( int column, WidthMode mode ) // QListView { if ( !isValidViewMode( Tree ) ) { @@ -652,193 +655,193 @@ OVersatileViewItem * OVersatileView::firstChild() const // QListView { if ( !isValidViewMode( Tree ) ) { return 0; } return static_cast<OVersatileViewItem*>( _listview->firstChild() ); } int OVersatileView::childCount() const // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->childCount(); } void OVersatileView::setAllColumnsShowFocus( bool focus ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setAllColumnsShowFocus( focus ); } bool OVersatileView::allColumnsShowFocus() const // QListView { if ( !isValidViewMode( Tree ) ) { return false; } return _listview->allColumnsShowFocus(); } void OVersatileView::setItemMargin( int margin ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setItemMargin( margin ); } int OVersatileView::itemMargin() const // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->itemMargin(); } void OVersatileView::setRootIsDecorated( bool decorate ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setRootIsDecorated( decorate ); } bool OVersatileView::rootIsDecorated() const // QListView { if ( !isValidViewMode( Tree ) ) { return false; } return _listview->rootIsDecorated(); } void OVersatileView::setShowSortIndicator( bool show ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setShowSortIndicator( show ); } bool OVersatileView::showSortIndicator() const // QListView { if ( !isValidViewMode( Tree ) ) { return false; } return _listview->showSortIndicator(); } void OVersatileView::triggerUpdate() // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->triggerUpdate(); } // // only in QIconView // - + uint OVersatileView::count() const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return _iconview->count(); } int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return -1; } return _iconview->index( item ); } OVersatileViewItem* OVersatileView::firstItem() const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->firstItem() ); } OVersatileViewItem* OVersatileView::lastItem() const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->lastItem() ); } OVersatileViewItem* OVersatileView::findItem( const QPoint &pos ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->findItem( pos ) ); } OVersatileViewItem* OVersatileView::findItem( const QString &text ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->findItem( text ) ); } OVersatileViewItem* OVersatileView::findFirstVisibleItem( const QRect &r ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->findFirstVisibleItem( r ) ); } OVersatileViewItem* OVersatileView::findLastVisibleItem( const QRect &r ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return static_cast<OVersatileViewItem*>( _iconview->findLastVisibleItem( r ) ); } void OVersatileView::setGridX( int rx ) // QIconView { if ( !isValidViewMode( Icons ) ) { return; } _iconview->setGridX( rx ); } void OVersatileView::setGridY( int ry ) // QIconView { if ( !isValidViewMode( Icons ) ) { return; } _iconview->setGridY( ry ); } int OVersatileView::gridX() const // QIconView { if ( !isValidViewMode( Icons ) ) { return -1; } return _iconview->gridX(); } int OVersatileView::gridY() const // QIconView { if ( !isValidViewMode( Icons ) ) diff --git a/libopie2/opieui/oversatileview.h b/libopie2/opieui/oversatileview.h index 8af21dc..61b61db 100644 --- a/libopie2/opieui/oversatileview.h +++ b/libopie2/opieui/oversatileview.h @@ -1,394 +1,399 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OVERSATILEVIEW_H #define OVERSATILEVIEW_H /* QT */ #include <qwidgetstack.h> #include <qiconview.h> /* OPIE */ #include <opie2/oapplication.h> /* FORWARDS */ class QHeader; class QIconSet; class QIconViewItem; -class OListView; class QListViewItem; class QPopupMenu; class QString; #ifndef QT_NO_DRAGANDDROP class QIconDragItem; #endif +namespace Opie { +namespace Ui { +class OListView; + class OVersatileView : public QWidgetStack { Q_OBJECT - + friend class OVersatileViewItem; //==============================================================================================// // OVersatileView High Level API //==============================================================================================// public: OVersatileView( QWidget* parent = 0, const char* name = 0, int mode = 0 ); ~OVersatileView(); QPopupMenu* contextMenu() const; - + void setSynchronization( bool sync ); bool synchronization(); - + enum ViewMode { Tree = 0, Icons }; int viewMode(); - + QIconView* iconView() const; OListView* listView() const; - + enum WarningPolicy { None = 0, Warn, WarnReturn }; - + void setWarningPolicy( int ) const; // warn, if calling a method which doesn't apply to the current viewmode bool warningPolicy() const; - + void setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ); - + public slots: void setViewMode( int mode ); void setIconViewMode(); void setTreeViewMode(); protected: virtual bool isValidViewMode( int mode ) const; virtual void popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col = 0 ); - + private: int _viewmode; bool _synchronization; mutable int _warningpolicy; - + OListView* _listview; QIconView* _iconview; - + QPixmap _treeleaf; QPixmap _treeopened; QPixmap _treeclosed; QPixmap _iconleaf; QPixmap _iconopened; QPixmap _iconclosed; - + QPopupMenu* _contextmenu; - + int _iconstyle; int _treestyle; - + private slots: - + void contextMenuRequested( QListViewItem*, const QPoint&, int ); void contextMenuRequested( QIconViewItem*, const QPoint& ); // type converting signal forwarders - + void selectionChanged( QListViewItem * ); void currentChanged( QListViewItem * ); void clicked( QListViewItem * ); void pressed( QListViewItem * ); void doubleClicked( QListViewItem * ); void returnPressed( QListViewItem * ); void onItem( QListViewItem * ); - + void selectionChanged( QIconViewItem * ); void currentChanged( QIconViewItem * ); void clicked( QIconViewItem * ); void pressed( QIconViewItem * ); void doubleClicked( QIconViewItem * ); void returnPressed( QIconViewItem * ); void onItem( QIconViewItem * ); - + void expanded( QListViewItem * item ); // QListView void collapsed( QListViewItem * item ); // QListView signals: - + void contextMenuRequested( OVersatileViewItem * item, const QPoint& pos, int col ); - + /*#ifndef QT_NO_DRAGANDDROP void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView #endif void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView void itemRenamed( OVersatileViewItem *item ); // QIconView */ //==============================================================================================// // "Derived" API - Case 1: Methods existing either only in QListView or only in QIconView //==============================================================================================// public: /* enum Arrangement { // QIconView LeftToRight = 0, TopToBottom }; enum ResizeMode { // QIconView Fixed = 0, Adjust }; enum ItemTextPos { // QIconView Bottom = 0, Right }; */ - + // // only in QListView // - + int treeStepSize() const; // QListView virtual void setTreeStepSize( int ); // QListView QHeader * header() const; // QListView virtual int addColumn( const QString &label, int size = -1); // QListView virtual int addColumn( const QIconSet& iconset, const QString &label, int size = -1); // QListView void removeColumn( int index ); // #### make virtual in next major release! // QListView virtual void setColumnText( int column, const QString &label ); // QListView virtual void setColumnText( int column, const QIconSet& iconset, const QString &label ); // QListView QString columnText( int column ) const; // QListView virtual void setColumnWidth( int column, int width ); // QListView int columnWidth( int column ) const; // QListView enum WidthMode { Manual, Maximum }; // QListView virtual void setColumnWidthMode( int column, WidthMode ); // QListView WidthMode columnWidthMode( int column ) const; // QListView int columns() const; // QListView virtual void setColumnAlignment( int, int ); // QListView int columnAlignment( int ) const; // QListView OVersatileViewItem * itemAt( const QPoint & screenPos ) const; // QListView QRect itemRect( const OVersatileViewItem * ) const; // QListView int itemPos( const OVersatileViewItem * ); // QListView bool isSelected( const OVersatileViewItem * ) const; // QListView // also in QIconViewItem but not in QIconView *shrug* virtual void setMultiSelection( bool enable ); // QListView bool isMultiSelection() const; // QListView OVersatileViewItem * selectedItem() const; // QListView virtual void setOpen( OVersatileViewItem *, bool ); // QListView bool isOpen( const OVersatileViewItem * ) const; // QListView OVersatileViewItem * firstChild() const; // QListView int childCount() const; // QListView virtual void setAllColumnsShowFocus( bool ); // QListView bool allColumnsShowFocus() const; // QListView virtual void setItemMargin( int ); // QListView int itemMargin() const; // QListView virtual void setRootIsDecorated( bool ); // QListView bool rootIsDecorated() const; // QListView void setShowSortIndicator( bool show ); // QListView bool showSortIndicator() const; // QListView - + int index( const OVersatileViewItem *item ) const; // QIconView public slots: void triggerUpdate(); // QListView signals: void expanded( OVersatileViewItem *item ); // QListView void collapsed( OVersatileViewItem *item ); // QListView // // only in QIconView // - public: + public: uint count() const; // QIconView - + OVersatileViewItem *firstItem() const; // QIconView OVersatileViewItem *lastItem() const; // QIconView OVersatileViewItem *findItem( const QPoint &pos ) const; // QIconView OVersatileViewItem *findItem( const QString &text ) const; // QIconView OVersatileViewItem* findFirstVisibleItem( const QRect &r ) const; // QIconView OVersatileViewItem* findLastVisibleItem( const QRect &r ) const; // QIconView virtual void setGridX( int rx ); // QIconView virtual void setGridY( int ry ); // QIconView int gridX() const; // QIconView int gridY() const; // QIconView virtual void setSpacing( int sp ); // QIconView int spacing() const; // QIconView virtual void setItemTextPos( QIconView::ItemTextPos pos ); // QIconView QIconView::ItemTextPos itemTextPos() const; // QIconView virtual void setItemTextBackground( const QBrush &b ); // QIconView QBrush itemTextBackground() const; // QIconView virtual void setArrangement( QIconView::Arrangement am ); // QIconView QIconView::Arrangement arrangement() const; // QIconView virtual void setResizeMode( QIconView::ResizeMode am ); // QIconView QIconView::ResizeMode resizeMode() const; // QIconView virtual void setMaxItemWidth( int w ); // QIconView int maxItemWidth() const; // QIconView virtual void setMaxItemTextLength( int w ); // QIconView int maxItemTextLength() const; // QIconView virtual void setAutoArrange( bool b ); // QIconView bool autoArrange() const; // QIconView virtual void setShowToolTips( bool b ); // QIconView bool showToolTips() const; // QIconView bool sorting() const; // QIconView bool sortDirection() const; // QIconView virtual void setItemsMovable( bool b ); // QIconView bool itemsMovable() const; // QIconView virtual void setWordWrapIconText( bool b ); // QIconView bool wordWrapIconText() const; // QIconView public slots: virtual void arrangeItemsInGrid( const QSize &grid, bool update = TRUE ); // QIconView virtual void arrangeItemsInGrid( bool update = TRUE ); // QIconView virtual void updateContents(); // QIconView - + signals: /*#ifndef QT_NO_DRAGANDDROP void dropped( QDropEvent *e, const QValueList<QIconDragItem> &lst ); // QIconView #endif */ void moved(); // QIconView void itemRenamed( OVersatileViewItem *item, const QString & ); // QIconView void itemRenamed( OVersatileViewItem *item ); // QIconView //==============================================================================================// // "Derived" API - Case 2: Methods existing in QListView and QIconView with the same signatures //==============================================================================================// public: enum SelectionMode { Single = 0, Multi, Extended, NoSelection }; virtual void clear(); virtual void setFont( const QFont & ); virtual void setPalette( const QPalette & ); virtual void takeItem( OVersatileViewItem * ); void setSelectionMode( SelectionMode mode ); SelectionMode selectionMode() const; virtual void selectAll( bool select ); virtual void clearSelection(); virtual void invertSelection(); - + void ensureItemVisible( const OVersatileViewItem * ); virtual void repaintItem( const OVersatileViewItem * ) const; virtual void setCurrentItem( OVersatileViewItem * ); OVersatileViewItem * currentItem() const; // bool eventFilter( QObject * o, QEvent * ); // use QWidgetStack implementation // QSize minimumSizeHint() const; // use QWidgetStack implementation // QSizePolicy sizePolicy() const; // use QWidgetStack implementation // QSize sizeHint() const; // use QWidgetStack implementation signals: void selectionChanged(); void selectionChanged( OVersatileViewItem * ); void currentChanged( OVersatileViewItem * ); void clicked( OVersatileViewItem * ); void pressed( OVersatileViewItem * ); void doubleClicked( OVersatileViewItem * ); void returnPressed( OVersatileViewItem * ); - + void onItem( OVersatileViewItem * ); void onViewport(); - + //==============================================================================================// // "Derived" API - Case 2: Methods existing in QListView and QIconView with differing signatures //==============================================================================================// - + /* - + public: virtual void insertItem( OVersatileViewItem * ); // QListView virtual void insertItem( OVersatileViewItem *item, OVersatileViewItem *after = 0L ); // QIconView virtual void setSelected( OVersatileViewItem *, bool ); // QListView virtual void setSelected( OVersatileViewItem *item, bool s, bool cb = FALSE ); // QIconView virtual void setSorting( int column, bool increasing = TRUE ); // QListView void setSorting( bool sort, bool ascending = TRUE ); // QIconView void sort(); // #### make virtual in next major release // QListView virtual void sort( bool ascending = TRUE ); // QIconView */ - + signals: void clicked( OVersatileViewItem *, const QPoint &, int ); // QListView void clicked( OVersatileViewItem *, const QPoint & ); // QIconView - + void pressed( OVersatileViewItem *, const QPoint &, int ); // QListView void pressed( OVersatileViewItem *, const QPoint & ); // QIconView - + void rightButtonClicked( OVersatileViewItem* item, const QPoint& pos ); // QIconView void rightButtonClicked( OVersatileViewItem *, const QPoint&, int ); // QListView - - void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView + + void rightButtonPressed( OVersatileViewItem* item, const QPoint& pos ); // QIconView void rightButtonPressed( OVersatileViewItem *, const QPoint&, int ); // QListView - + void mouseButtonPressed( int, OVersatileViewItem *, const QPoint& , int ); // QListView void mouseButtonPressed( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView - + void mouseButtonClicked( int, OVersatileViewItem *, const QPoint&, int ); // QListView void mouseButtonClicked( int button, OVersatileViewItem* item, const QPoint& pos ); // QIconView }; +} +} #endif diff --git a/libopie2/opieui/oversatileviewitem.cpp b/libopie2/opieui/oversatileviewitem.cpp index 66de8eb..03c6738 100644 --- a/libopie2/opieui/oversatileviewitem.cpp +++ b/libopie2/opieui/oversatileviewitem.cpp @@ -1,129 +1,131 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/oversatileviewitem.h> #include <opie2/oversatileview.h> +using namespace Opie::Ui; + OVersatileViewItem::OVersatileViewItem( OVersatileView * parent ) :OListViewItem( parent->_listview ), QIconViewItem( parent->_iconview ), _versatileview( parent ) { init(); } OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after ) :OListViewItem( parent->_listview, after ), QIconViewItem( parent->_iconview, after ), _versatileview( parent ) { init(); } OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, QString a, QString b, QString c, QString d, QString e, QString f, QString g, QString h ) :OListViewItem( parent->_listview, a, b, c, d, e, f, g, h ), QIconViewItem( parent->_iconview, a ), _versatileview( parent ) { init(); } OVersatileViewItem::OVersatileViewItem( OVersatileView * parent, OVersatileViewItem* after, QString a, QString b, QString c, QString d, QString e, QString f, QString g, QString h ) :OListViewItem( parent->_listview, after, a, b, c, d, e, f, g, h ), QIconViewItem( parent->_iconview, after, a ), _versatileview( parent ) { init(); } OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, QString a, QString b, QString c, QString d, QString e, QString f, QString g, QString h ) :OListViewItem( parent, a, b, c, d, e, f, g, h ), QIconViewItem( parent->_versatileview->_iconview, a ), _versatileview( parent->_versatileview ) { init(); } OVersatileViewItem::OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem* after, QString a, QString b, QString c, QString d, QString e, QString f, QString g, QString h ) :OListViewItem( parent, after, a, b, c, d, e, f, g, h ), QIconViewItem( parent->_versatileview->_iconview, after, a ), _versatileview( parent->_versatileview ) { init(); } OVersatileViewItem::~OVersatileViewItem() { } OVersatileView* OVersatileViewItem::versatileView() const { return _versatileview; } void OVersatileViewItem::init() { if ( !firstChild() ) { // I'm a sweet yellow and browne autumn leaf OListViewItem::setPixmap( 0, _versatileview->_treeleaf ); QIconViewItem::setPixmap( _versatileview->_iconleaf ); } else { // I'm a node and I have a little baby child if ( isOpen() ) { OListViewItem::setPixmap( 0, _versatileview->_treeopened ); QIconViewItem::setPixmap( _versatileview->_iconopened ); } else { OListViewItem::setPixmap( 0, _versatileview->_treeclosed ); QIconViewItem::setPixmap( _versatileview->_iconclosed ); } } } void OVersatileViewItem::setRenameEnabled( bool allow ) { #if (QT_VERSION >= 0x030000) OListViewItem::setRenameEnabled( 0, allow ); // TODO: Backport to Qt-Embedded 2.x? #endif QIconViewItem::setRenameEnabled( allow ); diff --git a/libopie2/opieui/oversatileviewitem.h b/libopie2/opieui/oversatileviewitem.h index ee8ee20..c4977af 100644 --- a/libopie2/opieui/oversatileviewitem.h +++ b/libopie2/opieui/oversatileviewitem.h @@ -1,100 +1,105 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OVERSATILEVIEWITEM_H #define OVERSATILEVIEWITEM_H /* QT */ #include <qiconview.h> /* OPIE */ #include <opie2/olistview.h> +namespace Opie { +namespace Ui { + class OVersatileView; class OVersatileViewItem : public OListViewItem, public QIconViewItem { public: OVersatileViewItem( OVersatileView * parent ); OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after ); OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after ); OVersatileViewItem( OVersatileView * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OVersatileViewItem( OVersatileViewItem * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OVersatileViewItem( OVersatileView * parent, OVersatileViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OVersatileViewItem( OVersatileViewItem * parent, OVersatileViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); virtual ~OVersatileViewItem(); OVersatileView* versatileView() const; // TODO: Implement the remaining constructors from QIconView /* OIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon ); OIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon ); */ virtual void setRenameEnabled( bool ); // TODO: Implement the remaining method multiplexers private: OVersatileView* _versatileview; private: void init(); }; +} +} #endif diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp index 8bb4ed6..9519888 100644 --- a/libopie2/opieui/owait.cpp +++ b/libopie2/opieui/owait.cpp @@ -1,110 +1,112 @@ /* This file is part of the Opie Project Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "owait.h" /* OPIE */ #include <qpe/qpeapplication.h> #include <qpe/resource.h> /* QT */ #include <qlayout.h> #include <qpainter.h> +using namespace Opie::Ui; + static int frame = 0; /** * This will construct a modal dialog. * * The default timer length is 10. * * @param parent The parent of the widget * @param msg The name of the object * @param dispIcon Display Icon? */ OWait::OWait( QWidget *parent, const char* msg, bool dispIcon ) :QDialog( parent, msg, TRUE, WStyle_Customize ) { QHBoxLayout * hbox = new QHBoxLayout( this ); m_lb = new QLabel( this ); m_lb->setBackgroundMode ( NoBackground ); hbox->addWidget( m_lb ); hbox->activate(); m_pix = Resource::loadPixmap( "BigBusy" ); m_aniSize = m_pix.height(); resize( m_aniSize, m_aniSize ); m_timerLength = 10; m_waitTimer = new QTimer( this ); connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); } void OWait::timerEvent( QTimerEvent * ) { frame = ( ++frame ) % 4; repaint(); } void OWait::paintEvent( QPaintEvent * ) { QPainter p( m_lb ); p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); } void OWait::show() { move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) ); startTimer( 300 ); m_waitTimer->start( m_timerLength * 1000, true ); QDialog::show(); } void OWait::hide() { killTimers(); m_waitTimer->stop(); frame = 0; QDialog::hide(); } void OWait::setTimerLength( int length ) { m_timerLength = length; } OWait::~OWait() {} diff --git a/libopie2/opieui/owait.h b/libopie2/opieui/owait.h index 3267064..03c33e4 100644 --- a/libopie2/opieui/owait.h +++ b/libopie2/opieui/owait.h @@ -1,86 +1,90 @@ /* This file is part of the Opie Project Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OWAIT_H #define OWAIT_H /* QT */ #include <qdialog.h> #include <qlabel.h> #include <qpixmap.h> #include <qtimer.h> + +namespace Opie { +namespace Ui { /** * This class displays a animated waiting icon in the middle of the screen. * * @short modal hour glass dialog * @see QDialog * @author Maximilian Reiß */ class OWait : public QDialog { Q_OBJECT public: OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE ); ~OWait(); /** * reimplemented for control reasons */ void show(); /** * Set the time before the icon will be automaticly hidden * The timer will be started once the widget will be shown. * @param length - time in seconds */ void setTimerLength( int length ); public slots: /** * reimplemented for control reasons */ void hide(); private: void timerEvent( QTimerEvent * ); void paintEvent( QPaintEvent * ); QPixmap m_pix; QLabel *m_lb; QTimer *m_waitTimer; int m_timerLength; int m_aniSize; class Private; Private *d; }; - +} +} #endif |