libopie API Documentation

odevicebutton.cpp

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #include <qpixmap.h>
00022 #include <qstring.h>
00023 
00024 #include <qpe/qcopenvelope_qws.h>
00025 #include <opie/odevicebutton.h>
00026 
00027 using namespace Opie;
00028 
00029 
00030 class OQCopMessageData {
00031 public:
00032     QCString m_channel;
00033     QCString m_message;
00034     QByteArray m_data;
00035 };
00036 
00037 
00038 OQCopMessage::OQCopMessage ( )
00039     : d ( 0 )
00040 {
00041     init ( QCString ( ), QCString ( ), QByteArray ( ));
00042 }
00043 
00044 OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
00045     : d ( 0 )
00046 {
00047     init ( copy. channel ( ), copy. message ( ), copy. data ( ));
00048 }
00049 
00050 OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
00051 {
00052     init ( assign. channel ( ), assign. message ( ), assign. data ( ));
00053     return *this;
00054 }
00055 
00056 OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
00057     : d ( 0 )
00058 {
00059     init ( ch, m, arg );
00060 }
00061 
00062 void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
00063 {
00064     if ( !d )
00065         d = new OQCopMessageData ( );
00066     d-> m_channel = ch;
00067     d-> m_message = m;
00068     d-> m_data = arg;
00069 }
00070 
00071 bool OQCopMessage::send ( )
00072 {
00073     if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
00074         return false;
00075 
00076     QCopEnvelope e ( d-> m_channel, d-> m_message );
00077 
00078     if ( d-> m_data. size ( ))
00079         e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
00080 
00081     return true;
00082 }
00083 
00084 QCString OQCopMessage::channel ( ) const
00085 {
00086     return d-> m_channel;
00087 }
00088 
00089 QCString OQCopMessage::message ( ) const
00090 {
00091     return d-> m_message;
00092 }
00093 
00094 QByteArray OQCopMessage::data ( ) const
00095 {
00096     return d-> m_data;
00097 }
00098 
00099 bool OQCopMessage::isNull() const
00100 {
00101     return d-> m_message.isNull() || d-> m_channel.isNull();
00102 }
00103 void OQCopMessage::setChannel ( const QCString &ch )
00104 {
00105     d-> m_channel = ch;
00106 }
00107 
00108 void OQCopMessage::setMessage ( const QCString &m )
00109 {
00110     d-> m_message = m;
00111 }
00112 
00113 void OQCopMessage::setData ( const QByteArray &data )
00114 {
00115     d-> m_data = data;
00116 }
00117 
00131 ODeviceButton::ODeviceButton()
00132 {
00133 }
00134 
00135 ODeviceButton::~ODeviceButton()
00136 {
00137 }
00138 
00142 ushort ODeviceButton::keycode() const
00143 {
00144     return m_Keycode;
00145 }
00146 
00147 
00151 QString ODeviceButton::userText() const
00152 {
00153     return m_UserText;
00154 }
00155 
00160 QPixmap ODeviceButton::pixmap() const
00161 {
00162     return m_Pixmap;
00163 }
00164 
00169 OQCopMessage ODeviceButton::factoryPresetPressedAction() const
00170 {
00171     return m_FactoryPresetPressedAction;
00172 }
00173 
00178 OQCopMessage ODeviceButton::pressedAction() const
00179 {
00180     if (m_PressedAction.channel().isEmpty())
00181     return factoryPresetPressedAction();
00182     return m_PressedAction;
00183 }
00184 
00189 OQCopMessage ODeviceButton::factoryPresetHeldAction() const
00190 {
00191     return m_FactoryPresetHeldAction;
00192 }
00193 
00198 OQCopMessage ODeviceButton::heldAction() const
00199 {
00200     if (m_HeldAction.channel().isEmpty())
00201     return factoryPresetHeldAction();
00202     return m_HeldAction;
00203 }
00204 
00205 void ODeviceButton::setKeycode(ushort keycode)
00206 {
00207     m_Keycode = keycode;
00208 }
00209 
00210 void ODeviceButton::setUserText(const QString& text)
00211 {
00212     m_UserText = text;
00213 }
00214 
00215 void ODeviceButton::setPixmap(const QPixmap& picture)
00216 {
00217     m_Pixmap = picture;
00218 }
00219 
00220 void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
00221 {
00222     m_FactoryPresetPressedAction = action;
00223 }
00224 
00225 
00226 void ODeviceButton::setPressedAction(const OQCopMessage& action)
00227 {
00228     m_PressedAction = action;
00229 }
00230 
00231 void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
00232 {
00233     m_FactoryPresetHeldAction = action;
00234 }
00235 
00236 void ODeviceButton::setHeldAction(const OQCopMessage& action)
00237 {
00238     m_HeldAction = action;
00239 }
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:43 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001