Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Examples

YEvent.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       YEvent.h
00014 
00015   Author:     Stefan Hundhammer <sh@suse.de>
00016 
00017 /-*/
00018 
00019 #ifndef YEvent_h
00020 #define YEvent_h
00021 
00022 
00023 #include <string>
00024 #include <ycp/YCPValue.h>
00025 #include <ycp/YCPMap.h>
00026 #include <ycp/YCPSymbol.h>
00027 
00028 using std::string;
00029 class YWidget;
00030 
00031 
00036 class YEvent
00037 {
00038 public:
00039     
00040     enum EventType
00041     {
00042         NoEvent = 0,
00043         UnknownEvent,
00044         WidgetEvent,
00045         MenuEvent,
00046         KeyEvent,
00047         CancelEvent,
00048         TimeoutEvent,
00049         DebugEvent
00050     };
00051 
00052 
00053     enum EventReason
00054     {
00055         UnknownReason = 0,
00056         Activated,
00057         SelectionChanged,
00058         ValueChanged
00059     };
00060     
00061 
00065     YEvent( EventType eventType = UnknownEvent );
00066 
00071     virtual ~YEvent();
00072 
00076     EventType eventType() const { return _eventType; }
00077 
00082     unsigned long serial() const { return _serial; }
00083 
00087     static const char * toString( EventType eventType );
00088     
00092     static const char * toString( EventReason reason );
00093     
00097     virtual YCPMap ycpEvent();
00098 
00106     virtual YCPValue userInput();
00107 
00108     
00109 protected:
00110 
00111     EventType                   _eventType;
00112     unsigned long               _serial;
00113     
00114     static unsigned long        _nextSerial;
00115     static int                  _activeEvents;
00116 };
00117 
00118 
00119 
00120 class YWidgetEvent: public YEvent
00121 {
00122 public:
00123     
00127     YWidgetEvent( YWidget *     widget          = 0,
00128                   EventReason   reason          = Activated, 
00129                   EventType     eventType       = WidgetEvent );
00130 
00135     YWidget * widget() const { return _widget; }
00136 
00140     EventReason reason() const { return _reason; }
00141 
00147     virtual YCPMap ycpEvent();
00148 
00155     virtual YCPValue userInput();
00156     
00157 protected:
00158 
00159     YWidget *   _widget;
00160     EventReason _reason;
00161 };
00162 
00163 
00164 class YKeyEvent: public YEvent
00165 {
00166 public:
00167     
00175     YKeyEvent( const string &   keySymbol,
00176                YWidget *        focusWidget = 0 );
00177 
00182     string keySymbol() const { return _keySymbol; }
00183 
00190     YWidget * focusWidget() const { return _focusWidget; }
00191 
00197     virtual YCPMap ycpEvent();
00198 
00205     virtual YCPValue userInput();
00206     
00207 protected:
00208 
00209     string      _keySymbol;
00210     YWidget *   _focusWidget;
00211 };
00212 
00213 
00217 class YSimpleEvent: public YEvent
00218 {
00219 public:
00220     
00224     YSimpleEvent( EventType eventType, const YCPValue &         id );
00225     YSimpleEvent( EventType eventType, const char *             id );
00226     YSimpleEvent( EventType eventType, const string &           id );
00227 
00231     YCPValue id() const { return _id; }
00232 
00238     virtual YCPMap ycpEvent();
00239 
00246     virtual YCPValue userInput();
00247 
00248     
00249 protected:
00250 
00251     YCPValue _id;
00252 };
00253 
00254 
00258 class YMenuEvent: public YSimpleEvent
00259 {
00260 public:
00261     
00262     YMenuEvent( const YCPValue & id )   : YSimpleEvent( MenuEvent, id ) {}
00263     YMenuEvent( const char *     id )   : YSimpleEvent( MenuEvent, id ) {}
00264     YMenuEvent( const string &   id )   : YSimpleEvent( MenuEvent, id ) {}
00265 };
00266 
00267 
00272 class YCancelEvent: public YSimpleEvent
00273 {
00274 public:
00275     
00276     YCancelEvent() : YSimpleEvent( CancelEvent, "cancel" ) {}
00277 };
00278 
00279 
00284 class YDebugEvent: public YSimpleEvent
00285 {
00286 public:
00287     
00288     YDebugEvent() : YSimpleEvent( DebugEvent, "debugHotkey" ) {}
00289 };
00290 
00291 
00296 class YTimeoutEvent: public YSimpleEvent
00297 {
00298 public:
00299     
00300     YTimeoutEvent() : YSimpleEvent( TimeoutEvent, "timeout" ) {}
00301 };
00302 
00303 
00304 
00305 
00306 #endif // YEvent_h

Generated on Fri Nov 9 18:15:23 2007 for yast2-core by doxygen 1.3.6