| 1 |
/* |
| 2 |
Copyright (C) 2002 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file gui_resources.cc |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief Provides fonts and Colors used throughout dlgedit. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "gui_resources.h" |
| 27 |
|
| 28 |
/** |
| 29 |
* The font for text output. |
| 30 |
*/ |
| 31 |
PangoLayout *GuiResources::Font; |
| 32 |
|
| 33 |
/** |
| 34 |
* Some pens for line drawing. |
| 35 |
*/ |
| 36 |
GdkColor GuiResources::Color[MAX_GC]; |
| 37 |
|
| 38 |
// create font and pens |
| 39 |
void GuiResources::init (GtkWidget *widget) |
| 40 |
{ |
| 41 |
// font to use on the drawing area |
| 42 |
Font = gtk_widget_create_pango_layout (widget, NULL); |
| 43 |
|
| 44 |
GdkColor *c; |
| 45 |
|
| 46 |
// Black |
| 47 |
c = &(Color[GC_BLACK]); |
| 48 |
c->red = 0; |
| 49 |
c->green = 0; |
| 50 |
c->blue = 0; |
| 51 |
|
| 52 |
// White |
| 53 |
c = &(Color[GC_WHITE]); |
| 54 |
c->red = 65535; |
| 55 |
c->green = 65535; |
| 56 |
c->blue = 65535; |
| 57 |
|
| 58 |
// Grey (for NPC node background) |
| 59 |
c = &(Color[GC_GREY]); |
| 60 |
c->red = 55000; |
| 61 |
c->green = 55000; |
| 62 |
c->blue = 55000; |
| 63 |
|
| 64 |
// Dark Red (for selected nodes) |
| 65 |
c = &(Color[GC_DARK_RED]); |
| 66 |
c->red = 65535; |
| 67 |
c->green = 0; |
| 68 |
c->blue = 0; |
| 69 |
|
| 70 |
// Red |
| 71 |
c = &(Color[GC_RED]); |
| 72 |
c->red = 65535; |
| 73 |
c->green = 16350; |
| 74 |
c->blue = 0; |
| 75 |
|
| 76 |
// Green (for narrator node background) |
| 77 |
c = &(Color[GC_GREEN]); |
| 78 |
c->red = 51117; |
| 79 |
c->green = 65355; |
| 80 |
c->blue = 48496; |
| 81 |
|
| 82 |
// Dark Green (for narrator nodes) |
| 83 |
c = &(Color[GC_DARK_GREEN]); |
| 84 |
c->red = 0; |
| 85 |
c->green = 27300; |
| 86 |
c->blue = 15600; |
| 87 |
|
| 88 |
// Orange (for highlighting nodes) |
| 89 |
c = &(Color[GC_ORANGE]); |
| 90 |
c->red = 62258; |
| 91 |
c->green = 43253; |
| 92 |
c->blue = 9175; |
| 93 |
|
| 94 |
// Dark Blue (for player nodes) |
| 95 |
c = &(Color[GC_DARK_BLUE]); |
| 96 |
c->red = 0; |
| 97 |
c->green = 0; |
| 98 |
c->blue = 60000; |
| 99 |
|
| 100 |
// Blue - like the sky (for player node background) |
| 101 |
c = &(Color[GC_BLUE]); |
| 102 |
c->red = 48496; |
| 103 |
c->green = 50461; |
| 104 |
c->blue = 65535; |
| 105 |
} |
| 106 |
|
| 107 |
// Get a certain predefined Color |
| 108 |
const GdkColor *GuiResources::getColor (int color) |
| 109 |
{ |
| 110 |
if (color < 0 || color > MAX_GC) return (GdkColor*) NULL; |
| 111 |
else return &Color[color]; |
| 112 |
} |
| 113 |
|
| 114 |
// Get the right Color for a (mode, type) combination |
| 115 |
const GdkColor *GuiResources::getColor (mode_type mode, node_type type) |
| 116 |
{ |
| 117 |
switch (mode) |
| 118 |
{ |
| 119 |
// not selected |
| 120 |
case IDLE: |
| 121 |
{ |
| 122 |
if (type == NPC || type == LINK || type == MODULE) |
| 123 |
return &Color[GC_BLACK]; |
| 124 |
else if (type == NARRATOR) return &Color[GC_DARK_GREEN]; |
| 125 |
else if (type == PLAYER) return &Color[GC_DARK_BLUE]; |
| 126 |
else return &Color[GC_BLACK]; |
| 127 |
} |
| 128 |
|
| 129 |
// selected |
| 130 |
case NODE_SELECTED: |
| 131 |
{ |
| 132 |
return &Color[GC_DARK_RED]; |
| 133 |
} |
| 134 |
|
| 135 |
// highlighted |
| 136 |
case NODE_HILIGHTED: |
| 137 |
{ |
| 138 |
return &Color[GC_ORANGE]; |
| 139 |
} |
| 140 |
|
| 141 |
// unknown |
| 142 |
default: |
| 143 |
return &Color[GC_BLACK]; |
| 144 |
} |
| 145 |
|
| 146 |
return (GdkColor*) NULL; |
| 147 |
} |
| 148 |
|
| 149 |
// Get the right Fill Color for a (mode, type) combination |
| 150 |
// This color is going to be filled inside the node cirle |
| 151 |
const GdkColor* GuiResources::getFill (mode_type mode, node_type type) |
| 152 |
{ |
| 153 |
switch (type) |
| 154 |
{ |
| 155 |
case PLAYER: |
| 156 |
return &Color[GC_BLUE]; |
| 157 |
case NPC: |
| 158 |
return &Color[GC_GREY]; |
| 159 |
case NARRATOR: |
| 160 |
return &Color[GC_GREEN]; |
| 161 |
// unknown |
| 162 |
default: |
| 163 |
return &Color[GC_WHITE]; |
| 164 |
} |
| 165 |
|
| 166 |
return (GdkColor*) NULL; |
| 167 |
} |