source: golgotha/src/i4/window/style.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.8 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "window/style.hh"
10#include "palette/pal.hh"
11#include "arch.hh"
12#include "loaders/load.hh"
13#include "font/plain.hh"
14#include "font/anti_prop.hh"
15
16i4_style_manager_class i4_style_man;
17
18i4_icon_hint_class::i4_icon_hint_class()
19{
20  close_icon=i4_load_image(i4gets("close_icon"));
21  up_icon=i4_load_image(i4gets("up_icon"));
22  down_icon=i4_load_image(i4gets("down_icon"));
23  left_icon=i4_load_image(i4gets("left_icon"));
24  right_icon=i4_load_image(i4gets("right_icon"));
25  plus_icon=i4_load_image(i4gets("plus_icon"));
26  minus_icon=i4_load_image(i4gets("minus_icon"));
27  background_bitmap=i4_load_image(i4gets("background_bitmap"));
28  ok_icon=i4_load_image(i4gets("ok_icon"));
29  cancel_icon=i4_load_image(i4gets("cancel_icon"));
30}
31
32i4_time_hint_class::i4_time_hint_class()
33{
34  i4_const_str::iterator d=i4gets("button_delay").begin();
35  i4_const_str::iterator r=i4gets("button_repeat").begin();
36  i4_const_str::iterator dc=i4gets("double_click").begin();
37  button_delay=d.read_number();
38  button_repeat=r.read_number();
39  double_click=dc.read_number();
40}
41
42void i4_graphical_style_class::cleanup()
43{
44  if (color_hint)
45  {
46    delete color_hint;
47    color_hint=0;
48  }
49
50  if (font_hint)
51  {
52    delete font_hint;
53    font_hint=0;
54  }
55
56  if (cursor_hint)
57  {
58    delete cursor_hint;
59    cursor_hint=0;
60  }
61
62  if (icon_hint)
63  {
64    delete icon_hint;
65    icon_hint=0;
66  }
67
68  if (time_hint)
69  {
70    delete time_hint;
71    time_hint=0;
72  }
73}
74
75void i4_graphical_style_class::uninit()
76{
77  cleanup();
78}
79
80
81void i4_graphical_style_class::init()
82{
83  i4_style_man.add_style(this);
84}
85
86void i4_style_manager_class::add_style(i4_graphical_style_class *which)
87{
88  which->next=list;
89  list=which;
90}
91
92i4_graphical_style_class *i4_style_manager_class::find_style(char *name)
93{
94  i4_graphical_style_class *f=list;
95  for (;f;f=f->next)
96     if (!strcmp(f->name(),name))
97       return f;
98  return 0;
99}
100
101i4_graphical_style_class *i4_style_manager_class::first_style()
102{ return list; }
103
104i4_graphical_style_class *i4_style_manager_class::next_style(i4_graphical_style_class *last)
105{  return last->next; }
106
107
108i4_color i4_read_color_from_resource(char *name)
109{
110  i4_const_str::iterator i=i4gets(name).begin();
111
112  i4_color red=i.read_number();
113  i4_color grn=i.read_number();
114  i4_color blue=i.read_number();
115
116  return (red<<16)|(grn<<8)|(blue);
117}
118
119
120
121i4_color_hint_class::i4_color_hint_class()
122{
123  window.active.bright=i4_read_color_from_resource("window_active_bright");
124  window.active.medium=i4_read_color_from_resource("window_active_medium");
125  window.active.dark=i4_read_color_from_resource("window_active_dark");
126
127  window.passive.bright=i4_read_color_from_resource("window_passive_bright");
128  window.passive.medium=i4_read_color_from_resource("window_passive_medium");
129  window.passive.dark=i4_read_color_from_resource("window_passive_dark");
130
131  button=window;
132
133  text_foreground=i4_read_color_from_resource("text_foreground");
134  text_background=i4_read_color_from_resource("text_background");
135
136  selected_text_foreground=i4_read_color_from_resource("selected_text_foreground");
137  selected_text_background=i4_read_color_from_resource("selected_text_background");
138
139  black = 0;
140  white = 0xffffff;
141}
142
143i4_font_hint_class::i4_font_hint_class()
144{
145  i4_image_class *im=i4_load_image(i4gets("small_font"));
146  normal_font=small_font=new i4_anti_proportional_font_class(im, '!');
147  delete im;
148}
149
150
151i4_cursor_hint_class::i4_cursor_hint_class()
152{
153  normal=i4_load_cursor("normal_cursor", &i4_string_man);
154  text=i4_load_cursor("text_cursor", &i4_string_man);
155}
156
157
158void i4_graphical_style_class::prepare_for_mode(const i4_pal *pal,
159                                                i4_display_class::mode *mode)
160{
161  cleanup();
162
163  time_hint=new i4_time_hint_class();
164  color_hint=new i4_color_hint_class();
165  font_hint=new i4_font_hint_class();
166  cursor_hint=new i4_cursor_hint_class();
167  icon_hint=new i4_icon_hint_class();
168
169}
170
171i4_font_hint_class::~i4_font_hint_class()
172
173  delete normal_font; 
174  if (small_font && small_font!=normal_font)
175    delete small_font;
176}
177
178i4_icon_hint_class::~i4_icon_hint_class()
179{
180  delete close_icon;
181  delete up_icon;
182  delete down_icon;
183  delete left_icon;
184  delete right_icon;
185  delete plus_icon;
186  delete minus_icon;
187  delete background_bitmap;
188  delete ok_icon;
189  delete cancel_icon;
190}
Note: See TracBrowser for help on using the repository browser.