tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / media / MediaTheme.cpp
blobbf18b6a92d000c9ee75c289d02779a900beb115f
1 /*
2 * Copyright 2001-2006, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Marcus Overhagen
7 * Axel Dörfler, axeld@pinc-software.de
8 */
11 #include "DefaultMediaTheme.h"
12 #include "debug.h"
14 #include <MediaTheme.h>
15 #include <StringView.h>
16 #include <Locker.h>
17 #include <Autolock.h>
19 #include <string.h>
22 static BLocker sLock("media theme lock");
24 BMediaTheme* BMediaTheme::sDefaultTheme;
27 BMediaTheme::~BMediaTheme()
29 CALLED();
31 free(fName);
32 free(fInfo);
36 const char *
37 BMediaTheme::Name()
39 return fName;
43 const char *
44 BMediaTheme::Info()
46 return fInfo;
50 int32
51 BMediaTheme::ID()
53 return fID;
57 bool
58 BMediaTheme::GetRef(entry_ref* ref)
60 if (!fIsAddOn || ref == NULL)
61 return false;
63 *ref = fAddOnRef;
64 return true;
68 BView *
69 BMediaTheme::ViewFor(BParameterWeb* web, const BRect* hintRect,
70 BMediaTheme* usingTheme)
72 CALLED();
74 // use default theme if none was specified
75 if (usingTheme == NULL)
76 usingTheme = PreferredTheme();
78 if (usingTheme == NULL) {
79 BStringView* view = new BStringView(BRect(0, 0, 200, 30), "",
80 "No BMediaTheme available, sorry!");
81 view->ResizeToPreferred();
82 return view;
85 return usingTheme->MakeViewFor(web, hintRect);
89 status_t
90 BMediaTheme::SetPreferredTheme(BMediaTheme* defaultTheme)
92 CALLED();
94 // ToDo: this method should probably set some global settings file
95 // to make the new preferred theme available to all applications
97 BAutolock locker(sLock);
99 if (defaultTheme == NULL) {
100 // if the current preferred theme is not the default media theme,
101 // delete it, and set it back to the default
102 if (dynamic_cast<BPrivate::DefaultMediaTheme *>(sDefaultTheme) == NULL)
103 sDefaultTheme = new BPrivate::DefaultMediaTheme();
105 return B_OK;
108 // this method takes possession of the BMediaTheme passed, even
109 // if it fails, so it has to delete it
110 if (defaultTheme != sDefaultTheme)
111 delete sDefaultTheme;
113 sDefaultTheme = defaultTheme;
115 return B_OK;
119 BMediaTheme *
120 BMediaTheme::PreferredTheme()
122 CALLED();
124 BAutolock locker(sLock);
126 // ToDo: should look in the global prefs file for the preferred
127 // add-on and load this from disk - in the meantime, just use
128 // the default theme
130 if (sDefaultTheme == NULL)
131 sDefaultTheme = new BPrivate::DefaultMediaTheme();
133 return sDefaultTheme;
137 BBitmap *
138 BMediaTheme::BackgroundBitmapFor(bg_kind bg)
140 UNIMPLEMENTED();
141 return NULL;
145 rgb_color
146 BMediaTheme::BackgroundColorFor(bg_kind bg)
148 UNIMPLEMENTED();
149 return ui_color(B_PANEL_BACKGROUND_COLOR);
153 rgb_color
154 BMediaTheme::ForegroundColorFor(fg_kind fg)
156 UNIMPLEMENTED();
157 rgb_color dummy = {255, 255, 255};
159 return dummy;
163 //! protected BMediaTheme
164 BMediaTheme::BMediaTheme(const char* name, const char* info,
165 const entry_ref* ref, int32 id)
167 fID(id)
169 fName = strdup(name);
170 fInfo = strdup(info);
172 // ToDo: is there something else here, which has to be done?
174 if (ref) {
175 fIsAddOn = true;
176 fAddOnRef = *ref;
177 } else
178 fIsAddOn = false;
182 BControl *
183 BMediaTheme::MakeFallbackViewFor(BParameter *parameter)
185 if (parameter == NULL)
186 return NULL;
188 return BPrivate::DefaultMediaTheme::MakeViewFor(parameter);
193 private unimplemented
194 BMediaTheme::BMediaTheme()
195 BMediaTheme::BMediaTheme(const BMediaTheme &clone)
196 BMediaTheme & BMediaTheme::operator=(const BMediaTheme &clone)
199 status_t BMediaTheme::_Reserved_ControlTheme_0(void *) { return B_ERROR; }
200 status_t BMediaTheme::_Reserved_ControlTheme_1(void *) { return B_ERROR; }
201 status_t BMediaTheme::_Reserved_ControlTheme_2(void *) { return B_ERROR; }
202 status_t BMediaTheme::_Reserved_ControlTheme_3(void *) { return B_ERROR; }
203 status_t BMediaTheme::_Reserved_ControlTheme_4(void *) { return B_ERROR; }
204 status_t BMediaTheme::_Reserved_ControlTheme_5(void *) { return B_ERROR; }
205 status_t BMediaTheme::_Reserved_ControlTheme_6(void *) { return B_ERROR; }
206 status_t BMediaTheme::_Reserved_ControlTheme_7(void *) { return B_ERROR; }