2 * Copyright 2001-2006, Haiku.
3 * Distributed under the terms of the MIT License.
7 * Axel Dörfler, axeld@pinc-software.de
11 #include "DefaultMediaTheme.h"
14 #include <MediaTheme.h>
15 #include <StringView.h>
22 static BLocker
sLock("media theme lock");
24 BMediaTheme
* BMediaTheme::sDefaultTheme
;
27 BMediaTheme::~BMediaTheme()
58 BMediaTheme::GetRef(entry_ref
* ref
)
60 if (!fIsAddOn
|| ref
== NULL
)
69 BMediaTheme::ViewFor(BParameterWeb
* web
, const BRect
* hintRect
,
70 BMediaTheme
* usingTheme
)
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();
85 return usingTheme
->MakeViewFor(web
, hintRect
);
90 BMediaTheme::SetPreferredTheme(BMediaTheme
* defaultTheme
)
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();
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
;
120 BMediaTheme::PreferredTheme()
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
130 if (sDefaultTheme
== NULL
)
131 sDefaultTheme
= new BPrivate::DefaultMediaTheme();
133 return sDefaultTheme
;
138 BMediaTheme::BackgroundBitmapFor(bg_kind bg
)
146 BMediaTheme::BackgroundColorFor(bg_kind bg
)
149 return ui_color(B_PANEL_BACKGROUND_COLOR
);
154 BMediaTheme::ForegroundColorFor(fg_kind fg
)
157 rgb_color dummy
= {255, 255, 255};
163 //! protected BMediaTheme
164 BMediaTheme::BMediaTheme(const char* name
, const char* info
,
165 const entry_ref
* ref
, int32 id
)
169 fName
= strdup(name
);
170 fInfo
= strdup(info
);
172 // ToDo: is there something else here, which has to be done?
183 BMediaTheme::MakeFallbackViewFor(BParameter
*parameter
)
185 if (parameter
== 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
; }