1 // Baseresource.hh for fluxter - tools to display resources in X11.
2 //
3 //  Copyright (c) 2002 Steve Cooper, stevencooper@isomedia.com
4 //  Copyright (c) 1998-2000 John Kennis, jkennis@chello.nl
5 //
6 //  This program is free software; you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation; either version 2 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20 // (See the included file COPYING / GPL-2.0)
21 //
22 
23 #ifndef __BASERESOURCE_HH
24 #define __BASERESOURCE_HH
25 
26 #define FLUXTERG 1
27 #define FLUXBOX 2
28 
29 #define FLUXTER_LOCAL ".fluxbox/fluxter.nobb"
30 #define FLUXBOX_LOCAL ".fluxbox/fluxter.bb"
31 
32 #include "Timer.hh"
33 
34 class ToolWindow;
35 class BImageControl;
36 
37 struct STYLE {
38   bool auto_config;
39   char *conf_filename;
40   char *style_filename;
41   time_t  mtime;
42 };
43 
44 class BaseResource : public TimeoutHandler {
45 
46   public:
47     BaseResource(ToolWindow *);
48     virtual ~BaseResource(void);
49 
50     void CopyColor(BColor *,BColor *);
51     void CopyTexture(BTexture ,BTexture *);
52     void Reload(void);
53     STYLE style;
54 
55   protected:
56     void Load(void);
57     void readDatabaseColor(const char *, const char *, BColor *);
58     void readDatabaseTexture(const char *, const char *,BTexture *);
59     void readColor(const char *,const char *, const char *,const char *,
60                    const char *,BColor *);
61     void readTexture(const char *,const char *, const char *,const char *,
62                      const char *,const char *,const char *,
63                      BTexture *);
64 
65     ToolWindow *bbtool;
66     XrmDatabase resource_db;
67     XrmDatabase db;
68 
69     virtual void LoadBBToolResource(void) = 0;
70     virtual void timeout(void);
71   private:
72     bool ReadResourceFromFilename(const char *, const char *);
73     void ReadBBtoolResource(void);
74     void ReadDefaultResource(void);
75     void ReadWMResource(void);
76     BImageControl *image_control;
77     int ResourceType;
78     BTimer *timer;
79     int check_timeout;
80     time_t mtime;
81     struct stat file_status;
82     bool auto_config;
83 };
84 
85 #endif /* __BASERESOURCE_HH */
86