Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Examples  

settings.h

Go to the documentation of this file.
00001 
00002 //
00003 // YASA settings management
00004 //
00005 // Project: Yasa 2
00006 // Author : Jan Blumenthal
00007 // Start  : 2002/02/28
00008 // $Header: /sources/yasa/yasagui/settings.h,v 1.5 2003/01/24 15:47:42 bj Exp $
00009 //
00011 //
00012 // This program is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU General Public License as published by
00014 // the Free Software Foundation; either version 2 of the License, or
00015 // (at your option) any later version.
00016 //
00017 // This program is distributed in the hope that it will be useful,
00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU General Public License
00023 // along with this program (See the included file COPYING);
00024 // if not, write to the Free Software Foundation, Inc.,
00025 // 675 Mass Ave, Cambridge, MA 02139, USA.
00026 //
00028 #ifndef YASAGUI_SETTINGS_INCLUDE
00029 #define YASAGUI_SETTINGS_INCLUDE
00030 
00031 #include <qobject.h>
00032 #include <qlistview.h>
00033 #include <qstringlist.h>
00034 #include <qtextview.h>
00035 #include <qpixmap.h>
00036 #include <yasa/yasa_types.h>
00037 #include <yasagui/yasagui_customize.h>
00038 #include <qapplication.h>
00039 
00041 class YApplication;
00042 class YPixmap;
00043 class QMainWindow;
00044 class QAction;
00045 class YPainter;
00046 
00047 
00049 #define COLOR_DEFAULT       QColor(250,250,250) //QApplication::desktop()->backgroundColor()
00050 #define COLOR_TIMINGWINDOW  QColor(240,222,208)
00051 //#define COLOR_TIMINGWINDOW    QColor(255,255,255)
00052 #define COLOR_SYSTEM_TASK   QColor(0,120,150)
00053 #define COLOR_TASK          QColor(0,150,0)
00054 #define COLOR_TASK_IDLE     QColor(150,150,150)
00055 #define COLOR_EXCLUDED_TASK QColor(240,222,208)
00056 #define COLOR_MUTEX         QColor(150,150,0)
00057 #define COLOR_JITTER        QColor(200,100,100)
00058 
00059 
00061 class YPixmapArgs
00062 {   bool                warn_if_failed;
00063 public:                 YPixmapArgs(bool w=true) : warn_if_failed(w) {}
00064     bool                GetWarningMode() const                          {   return warn_if_failed;  }
00065 };
00066 
00067 
00069 class YPixmap
00070 {   QString             filename;
00071     QColor              color;
00072     QBrush              brush;
00073     QPixmap             *pixmap;
00074     bool                tried_n_failed;
00075     bool                warn_if_failed;                             // warn if loading failed (e.g. print an output warning)
00076     bool                IsPixmapValid() const                   {   return pixmap;      }
00077     int                 LoadPixmap();
00078 public:                 YPixmap(const QString &f, const QColor &c, const YPixmapArgs &args=YPixmapArgs() ) :
00079                         filename(f),
00080                         color(c),
00081                         brush(c),
00082                         pixmap(0),
00083                         tried_n_failed(false),
00084                         warn_if_failed( args.GetWarningMode() )
00085                         { }
00086                         YPixmap(const QBrush &b, QBrush::BrushStyle s, const YPixmapArgs &args=YPixmapArgs() ) :
00087                         color( COLOR_DEFAULT ),
00088                         brush( b ),
00089                         pixmap(0),
00090                         tried_n_failed(false),
00091                         warn_if_failed( args.GetWarningMode() )
00092                         {
00093                             brush.setStyle(s);
00094                         }
00096                         ~YPixmap()
00097                         {
00098                             if (pixmap)
00099                                 delete pixmap;
00100                         }
00101     const QPixmap *     GetPixmap()
00102                         {   if (this && ! LoadPixmap() )
00103                                 return pixmap;
00104                             return 0;
00105                         }
00106     const QBrush *      GetBrush()
00107                         {   LoadPixmap();
00108                             return &brush;
00109                         }
00110     bool                GetTriedAndFailed() const                   {   return tried_n_failed;      }
00111     void                WarnIfFailed(bool w)                        {   warn_if_failed=w;           }
00112 };
00113 
00114 
00115 
00117 class YPixmapSettings : public QObject
00118 {   Q_OBJECT
00119 protected:
00120     QList<YPixmap>      pixmaps;
00123     void                InsertFigure(const QString &filedir, const QColor &color=COLOR_DEFAULT );
00124     void                InsertBrush(const QBrush &brush, QBrush::BrushStyle style);
00125 public:                 YPixmapSettings()
00126                         {
00127                             pixmaps.setAutoDelete(TRUE);
00128                         }
00129     virtual int         InitInstance()                          {   return 0;               }
00130     virtual YPixmapArgs GetPixmapArgs()                         {   return YPixmapArgs();   }
00131     YPixmap *           GetPixmap(unsigned int index)           {
00132                                                                     if (  index <= pixmaps.count() )
00133                                                                     {
00134                                                                         return pixmaps.at(index);
00135                                                                     }
00136                                                                     return 0;
00137                                                                 }
00138     const QBrush*       GetBrush(unsigned int index)            {
00139                                                                     if ( index <= pixmaps.count() )
00140                                                                     {
00141                                                                         return pixmaps.at(index)->GetBrush();
00142                                                                     }
00143                                                                     return 0;
00144                                                                 }
00145 };
00146 
00147 
00148 
00149 
00152 class YApplicationFigures : public YPixmapSettings
00153 {   Q_OBJECT
00154 public:                 YApplicationFigures() {} //YApplication *app) : YPixmapSettings(app) {}
00155     virtual int         InitInstance()
00156                         {
00157                             InsertFigure( FIGURE_BACKGROUND_OUTPUT );                           // "BACKGROUND_OUTPUT" - set output background image
00158                             InsertFigure( FIGURE_BACKGROUND_HELP );                             // "BACKGROUND_HELP" - set output background of help window
00159                             InsertFigure( FIGURE_BACKGROUND_SOURCES );                          // "BACKGROUND_SOURCES" - set output background of sources view
00160                             InsertFigure( FIGURE_BACKGROUND_LOGFILE );                          // "BACKGROUND_LOGFILE" - set output background of logfile view
00161                             InsertFigure( FIGURE_BACKGROUND_WORKSPACE_TREE );                   // "BACKGROUND_WORKSPACE_TREE" - set output background image
00162                             InsertFigure( FIGURE_BACKGROUND_TIMINGWINDOWS, COLOR_TIMINGWINDOW );// "BACKGROUND_WINDOWS_TREE" - set output background image
00163                             InsertFigure( FIGURE_BACKGROUND_WINDOWS );                          // "BACKGROUND_WINDOWS_TREE" - set output background image
00164                             InsertFigure( FIGURE_ICON_APPLICATION );                            // "ICON_APPLICATION"
00165                             InsertFigure( FIGURE_ICON_MDIWINDOW );                              // "ICON_WINDOW"
00166                             InsertFigure( FIGURE_WORKSPACE_NEW );                               // "WORKSPACE_NEW"
00167                             InsertFigure( FIGURE_WORKSPACE_OPEN );                              // "WORKSPACE_OPEN"
00168                             InsertFigure( FIGURE_WORKSPACE_SAVE );                              // "WORKSPACE_SAVE"
00169                             InsertFigure( FIGURE_EXECUTE );                                     // "EXECUTE"
00170                             InsertFigure( FIGURE_ZOOM_IN );                                     // "ZOOM_IN"
00171                             InsertFigure( FIGURE_ZOOM_OUT );                                    // "ZOOM_OUT"
00172                             InsertFigure( FIGURE_POINTER_HAND );                                // "POINTER_HAND"
00173                             InsertFigure( FIGURE_POINTER_HAND_PUSHED );                         // "POINTER_HAND_PUHSED"
00174                             GetPixmap(BACKGROUND_TIMINGWINDOWS)->WarnIfFailed(false);
00175                             return YPixmapSettings::InitInstance();
00176                         }
00177     enum PIXMAP_TYPE    {   BACKGROUND_OUTPUTVIEW=0,
00178                             BACKGROUND_HELPVIEW,
00179                             BACKGROUND_SOURCESVIEW,
00180                             BACKGROUND_LOGFILEVIEW,
00181                             BACKGROUND_WORKSPACE_TREE,
00182                             BACKGROUND_TIMINGWINDOWS,
00183                             BACKGROUND_WINDOWS,
00184                             ICON_APPLICATION,
00185                             ICON_MDIWINDOW,
00186                             WORKSPACE_NEW,
00187                             WORKSPACE_OPEN,
00188                             WORKSPACE_SAVE,
00189                             EXECUTE,
00190                             ZOOM_IN,
00191                             ZOOM_OUT,
00192                             POINTER_HAND,
00193                             POINTER_HAND_PUSHED,
00194                             MAX_FIGURES };
00195     static void         SetTextViewBackdrop(QTextView &w, YApplicationFigures::PIXMAP_TYPE type);
00196     static void         SetListViewBackdrop(QListView &lv, YApplicationFigures::PIXMAP_TYPE type);
00197     static void         SetIcon(QMainWindow &mv, YApplicationFigures::PIXMAP_TYPE type);
00198     static void         SetIconSet(QAction &a, YApplicationFigures::PIXMAP_TYPE type);
00199     static int          CreateCursor(QCursor **c, YApplicationFigures::PIXMAP_TYPE releasedtype);
00200 };
00201 
00202 
00203 
00204 
00207 class YLogFileFigures : public YPixmapSettings
00208 {   Q_OBJECT
00209 public:                 YLogFileFigures() {} //YApplication *app) : YPixmapSettings(app) {}
00210     virtual int         InitInstance()
00211                         {   // must be the same sequence like the types defined in LOGGING_ACTIONS
00212                             InsertFigure( QString::null );                  // Unknown
00213                             InsertFigure( FIGURE_THREAD_CREATED );          // 1
00214                             InsertFigure( FIGURE_THREAD_ACTIVATE );
00215                             InsertFigure( FIGURE_THREAD_EXIT );
00216                             InsertFigure( FIGURE_THREAD_START );
00217                             InsertFigure( FIGURE_THREAD_CONT );
00218                             InsertFigure( FIGURE_THREAD_SUSPEND );
00219                             InsertFigure( FIGURE_THREAD_TOLERANCE_START );  // 7
00220                             InsertFigure( FIGURE_THREAD_TOLERANCE_CONT );   // 8
00221                             InsertFigure( FIGURE_THREAD_TOLERANCE_SUSPEND );// 9
00222                             InsertFigure( FIGURE_THREAD_SKIPPED );          // 10
00223                             InsertFigure( FIGURE_THREAD_TYPE );             // 11
00224                             InsertFigure( FIGURE_THREAD_EXCLUDED );         // 12
00225                             InsertFigure( FIGURE_DEADLINE_MATCH );
00226                             InsertFigure( FIGURE_DEADLINE_MISS );
00227                             InsertFigure( FIGURE_DEADLINE_MISS_DETECTED );  // 15
00228                             InsertFigure( FIGURE_DEADLINE_TOLERANCE_MISS );
00229                             InsertFigure( FIGURE_TIME_TO_COMPUTE );
00230                             InsertFigure( FIGURE_MUTEX_CREATED );
00231                             InsertFigure( FIGURE_MUTEX_DESTROYED );
00232                             InsertFigure( FIGURE_MUTEX_LOCKED );            // 20
00233                             InsertFigure( FIGURE_MUTEX_TRY_N_BLOCKED );
00234                             InsertFigure( FIGURE_MUTEX_UNLOCKED );
00235                             InsertFigure( FIGURE_MUTEX_RELOCKED );
00236                             InsertFigure( FIGURE_MUTEX_NOT_LOCKED );
00237                             InsertFigure( FIGURE_PRIORITY_CHANGED );        // 25
00238                             InsertFigure( FIGURE_SYSTEM_CEILING_CHANGED );
00239                             InsertFigure( FIGURE_MESSAGE );
00240                             InsertFigure( FIGURE_EMERGENCY_THREAD );
00241                             InsertFigure( FIGURE_SCHEDULER_CHANGED );
00242                             InsertFigure( FIGURE_SCHEDULER_CALLED );        // 30
00243                             InsertFigure( FIGURE_SCHEDULER_FINISHED );
00244                             InsertFigure( FIGURE_SCHEDULER_SWITCH );
00245                             InsertFigure( FIGURE_SCHEDULER_SYNCHRONIZED_START );
00246                             InsertFigure( FIGURE_IDLE_THREAD );
00247                             InsertFigure( FIGURE_JITTER );
00248 #if YASAL_MAX!=35
00249 #error There are inconsistences handling logging types!
00250 #endif
00251                             // insert task, mutex, task excluded brushes
00252                             InsertBrush( COLOR_SYSTEM_TASK  , QBrush::SolidPattern );       // system task
00253                             InsertBrush( COLOR_TASK         , QBrush::SolidPattern );       // task
00254                             InsertBrush( COLOR_TASK_IDLE    , QBrush::SolidPattern );       // idle task
00255                             InsertBrush( COLOR_EXCLUDED_TASK, QBrush::Dense6Pattern );      // excluded
00256                             InsertBrush( COLOR_MUTEX        , QBrush::SolidPattern );       // mutex
00257                             InsertBrush( COLOR_JITTER       , QBrush::Dense4Pattern );      // jitter
00258                             return YPixmapSettings::InitInstance();
00259                         }
00260     enum PIXMAP_TYPE    {   SYSTEM_TASK_BRUSH=YASAL_MAX+1,
00261                             TASK_BRUSH,
00262                             TASK_IDLE_BRUSH,
00263                             TASK_EXCLUDED_BRUSH,
00264                             MUTEX_BRUSH,
00265                             JITTER_BRUSH,
00266                             MAX_LOGGINGFIGURES
00267                             };
00268 
00269     //void              DrawPixmap(YPainter &o, int x, int y, unsigned int type);
00270     const QPixmap*      GetLogFilePixmap(unsigned int type)
00271                         {
00272                             const QPixmap *pixmap=0;
00273                             if (  type <= MAX_LOGGINGFIGURES )
00274                             {
00275                                 pixmaps.at(type);
00276                                 if ( ! pixmaps.current()->GetTriedAndFailed() )
00277                                     pixmap=pixmaps.current()->GetPixmap();
00278                             }
00279                             return pixmap;
00280                         }
00281     const QBrush *      GetLogFileBrush(unsigned int type)
00282                         {
00283                             if (  type <= MAX_LOGGINGFIGURES )
00284                             {
00285                                 return pixmaps.at(type)->GetBrush();
00286                             }
00287                             return 0;
00288                         }
00289     virtual YPixmapArgs GetPixmapArgs()                         {   return YPixmapArgs(false);      }
00290 };
00291 
00292 
00294 class YSettings
00295 {
00296     YApplicationFigures applicationfigures;
00297     YLogFileFigures     logfilefigures;
00298 public:                 YSettings() {}
00299     int                 InitInstance()
00300                         {
00301                             int retvalue;
00302                             retvalue=applicationfigures.InitInstance();
00303                             if (retvalue)
00304                                 return retvalue;
00305                             retvalue=logfilefigures.InitInstance();
00306                             return retvalue;
00307                         }
00308     YApplicationFigures&GetApplicationFigures()                         {   return applicationfigures;      }
00309     YLogFileFigures &   GetLogFileFigures()                             {   return logfilefigures;      }
00310 };
00311 
00312 
00313 
00314 
00315 
00316 
00317 
00318 
00319 
00321 #endif                                                                  // ifndef YASAGUI_SETTINGS_INCLUDE

Generated on Thu Feb 13 23:43:55 2003 for Yasa by doxygen1.3-rc3