1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 PALETTE.H                                 */
4 /*                                                                           */
5 /* (C) 1993-95  Ullrich von Bassewitz                                        */
6 /*              Zwehrenbuehlstrasse 33                                       */
7 /*              D-72070 Tuebingen                                            */
8 /* EMail:       uz@ibb.schwaben.com                                          */
9 /*                                                                           */
10 /*****************************************************************************/
11 
12 
13 
14 // $Id$
15 //
16 // $Log$
17 //
18 //
19 
20 
21 
22 #ifndef __PALETTE_H
23 #define __PALETTE_H
24 
25 
26 
27 #include "coll.h"
28 
29 
30 
31 // Instance of class Palette
32 extern class Palette* Pal;
33 
34 
35 
36 /*****************************************************************************/
37 /*                               Palette stuff                               */
38 /*****************************************************************************/
39 
40 
41 
42 // Indices into the palette arrays
43 static const int atFrameInactive    =   0;  // passive frame
44 static const int atFrameActive      =   1;  // active frame
45 static const int atFrameResizing    =   2;  // resizing frame
46 static const int atTextNormal       =   3;  // normal text
47 static const int atTextInvers       =   4;  // inverted text
48 static const int atTextSelected     =   5;  // selected static text
49 static const int atTextHigh         =   6;  // selected text (i.e. hotkeys)
50 static const int atTextHighInvers   =   7;  // inverted selected text
51 static const int atTextGrayed       =   8;  // grey (inactive) text
52 static const int atTextGrayedInvers =   9;  // dito inverted
53 static const int atEditNormal       =  10;  // normal text in an edit window
54 static const int atEditHigh         =  11;  // i.e. left/right arrows
55 static const int atEditBar          =  12;  // scroll bar (use atEditNormal for text)
56 
57 
58 // Palette numbers
59 static const u16 paBlue         =  0;   // blue palette
60 static const u16 paGray         =  1;   // grey palette (standard)
61 static const u16 paCyan         =  2;   // cyan palette
62 static const u16 paRed          =  3;   // red palette
63 static const u16 paBlack        =  4;   // black palette
64 static const u16 paError        =  5;   // errorwindow palette
65 static const u16 paRoot         =  6;   // root window palette
66 static const u16 paHelp         =  7;   // help window palette
67 static const u16 paFSel         =  8;   // file selector palette
68 
69 
70 
71 /*****************************************************************************/
72 /*                               class Palette                               */
73 /*****************************************************************************/
74 
75 
76 
77 class Palette: private Collection<unsigned char> {
78 
79 protected:
80     virtual void FreeItem (void* Item);
81     virtual void* GetItem (Stream& S);
82     virtual void PutItem (Stream& S, void* Item) const;
83 
84 
85     Palette (StreamableInit);
86     // Build constructor
87 
88 public:
89     i16         Debug;
90 
91 public:
92     Palette ();
93 
94     // Derived from class Streamable
95     virtual void Load (Stream& S);
96     virtual void Store (Stream& S) const;
97     virtual u16 StreamableID () const;
98     static Streamable* Build ();
99 
100     // Function to add a palette entry, returns the palette number
101     unsigned Add (const unsigned char *Mono, const unsigned char *Color);
102 
103     // Functions to build palette entries
104     u16 BuildAttr (unsigned PalNum, unsigned AttrIndex, unsigned char C);
105     static u16 BuildAttr (u16 Attr, unsigned char C);
106     static u16 BuildAttr (unsigned char Attr, unsigned char C = '\0');
107 };
108 
109 
110 
Palette(StreamableInit)111 inline Palette::Palette (StreamableInit) :
112         Collection<unsigned char> (Empty)
113 {
114 }
115 
116 
117 
BuildAttr(u16 Attr,unsigned char C)118 inline u16 Palette::BuildAttr (u16 Attr, unsigned char C)
119 // Builds an attribute char with the given attribute char and new char C
120 {
121     return (u16) ((Attr & 0xFF00) | u16 (C));
122 }
123 
124 
125 
BuildAttr(unsigned char Attr,unsigned char C)126 inline u16 Palette::BuildAttr (unsigned char Attr, unsigned char C)
127 // Builds an attribute char with the given attribute and char.
128 {
129     return (u16) ((((u16) Attr) << 8) | C);
130 }
131 
132 
133 
134 // End of PALETTE.H
135 
136 #endif
137 
138