* The "no theme available" string is now resized as needed.
* Rewrote header, cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19170 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: ControlTheme.h
|
||||
/
|
||||
/ Description: A BMediaTheme is something which can live in an add-on and is
|
||||
/ responsible for creating BViews or BControls from a BParameterWeb and its
|
||||
/ set of BMControls. This way, different "looks" for Media Kit control panels
|
||||
/ can be achieved.
|
||||
/
|
||||
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
#if !defined(_CONTROL_THEME_H)
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _CONTROL_THEME_H
|
||||
#define _CONTROL_THEME_H
|
||||
|
||||
|
||||
@@ -21,30 +12,22 @@
|
||||
class BParameterWeb;
|
||||
|
||||
|
||||
class BMediaTheme
|
||||
{
|
||||
public:
|
||||
virtual ~BMediaTheme();
|
||||
class BMediaTheme {
|
||||
public:
|
||||
virtual ~BMediaTheme();
|
||||
|
||||
const char * Name();
|
||||
const char * Info();
|
||||
const char* Name();
|
||||
const char* Info();
|
||||
int32 ID();
|
||||
bool GetRef(
|
||||
entry_ref * out_ref);
|
||||
bool GetRef(entry_ref* ref);
|
||||
|
||||
static BView * ViewFor(
|
||||
BParameterWeb * web,
|
||||
const BRect * hintRect = NULL,
|
||||
BMediaTheme * using_theme = NULL);
|
||||
static BView* ViewFor(BParameterWeb* web, const BRect* hintRect = NULL,
|
||||
BMediaTheme* usingTheme = NULL);
|
||||
|
||||
/* This function takes possession of default_theme, even it if returns error */
|
||||
static status_t SetPreferredTheme(
|
||||
BMediaTheme * default_theme = NULL);
|
||||
static status_t SetPreferredTheme(BMediaTheme* defaultTheme = NULL);
|
||||
static BMediaTheme* PreferredTheme();
|
||||
|
||||
static BMediaTheme * PreferredTheme();
|
||||
|
||||
virtual BControl * MakeControlFor(
|
||||
BParameter * control) = 0;
|
||||
virtual BControl* MakeControlFor(BParameter* control) = 0;
|
||||
|
||||
enum bg_kind {
|
||||
B_GENERAL_BG = 0,
|
||||
@@ -63,60 +46,50 @@ virtual BControl * MakeControlFor(
|
||||
B_HILITE_FG
|
||||
};
|
||||
|
||||
virtual BBitmap * BackgroundBitmapFor(
|
||||
bg_kind bg = B_GENERAL_BG);
|
||||
virtual rgb_color BackgroundColorFor(
|
||||
bg_kind bg = B_GENERAL_BG);
|
||||
virtual rgb_color ForegroundColorFor(
|
||||
fg_kind fg = B_GENERAL_FG);
|
||||
virtual BBitmap* BackgroundBitmapFor(bg_kind bg = B_GENERAL_BG);
|
||||
virtual rgb_color BackgroundColorFor(bg_kind bg = B_GENERAL_BG);
|
||||
virtual rgb_color ForegroundColorFor(fg_kind fg = B_GENERAL_FG);
|
||||
|
||||
protected:
|
||||
BMediaTheme(
|
||||
const char * name,
|
||||
const char * info,
|
||||
const entry_ref * add_on = 0,
|
||||
int32 theme_id = 0);
|
||||
protected:
|
||||
BMediaTheme(const char* name, const char* info,
|
||||
const entry_ref* addOn = NULL, int32 themeID = 0);
|
||||
|
||||
virtual BView * MakeViewFor(
|
||||
BParameterWeb * web,
|
||||
const BRect * hintRect = NULL) = 0;
|
||||
virtual BView* MakeViewFor(BParameterWeb* web,
|
||||
const BRect* hintRect = NULL) = 0;
|
||||
|
||||
static BControl * MakeFallbackViewFor(
|
||||
BParameter * control);
|
||||
|
||||
private:
|
||||
static BControl* MakeFallbackViewFor(BParameter* control);
|
||||
|
||||
private:
|
||||
BMediaTheme(); /* private unimplemented */
|
||||
BMediaTheme(
|
||||
const BMediaTheme & clone);
|
||||
BMediaTheme & operator=(
|
||||
const BMediaTheme & clone);
|
||||
BMediaTheme(const BMediaTheme& other);
|
||||
BMediaTheme& operator=(const BMediaTheme& other);
|
||||
|
||||
/* Mmmh, stuffing! */
|
||||
virtual status_t _Reserved_ControlTheme_0(void *);
|
||||
virtual status_t _Reserved_ControlTheme_1(void *);
|
||||
virtual status_t _Reserved_ControlTheme_2(void *);
|
||||
virtual status_t _Reserved_ControlTheme_3(void *);
|
||||
virtual status_t _Reserved_ControlTheme_4(void *);
|
||||
virtual status_t _Reserved_ControlTheme_5(void *);
|
||||
virtual status_t _Reserved_ControlTheme_6(void *);
|
||||
virtual status_t _Reserved_ControlTheme_7(void *);
|
||||
virtual status_t _Reserved_ControlTheme_0(void *);
|
||||
virtual status_t _Reserved_ControlTheme_1(void *);
|
||||
virtual status_t _Reserved_ControlTheme_2(void *);
|
||||
virtual status_t _Reserved_ControlTheme_3(void *);
|
||||
virtual status_t _Reserved_ControlTheme_4(void *);
|
||||
virtual status_t _Reserved_ControlTheme_5(void *);
|
||||
virtual status_t _Reserved_ControlTheme_6(void *);
|
||||
virtual status_t _Reserved_ControlTheme_7(void *);
|
||||
|
||||
char * _mName;
|
||||
char * _mInfo;
|
||||
int32 _mID;
|
||||
bool _mAddOn;
|
||||
entry_ref _mAddOnRef;
|
||||
uint32 _reserved_control_theme_[8];
|
||||
char* fName;
|
||||
char* fInfo;
|
||||
int32 fID;
|
||||
bool fIsAddOn;
|
||||
entry_ref fAddOnRef;
|
||||
|
||||
static BMediaTheme * _mDefaultTheme;
|
||||
uint32 _reserved[8];
|
||||
|
||||
static BMediaTheme* sDefaultTheme;
|
||||
};
|
||||
|
||||
/* Theme add-ons should export the functions: */
|
||||
#if defined(_BUILDING_THEME_ADDON)
|
||||
extern "C" _EXPORT BMediaTheme * make_theme(int32 id, image_id you);
|
||||
extern "C" _EXPORT status_t get_theme_at(int32 n, const char ** out_name, const char ** out_info, int32 * out_id);
|
||||
#endif /* _BUILDING_THEME_ADDON */
|
||||
|
||||
#endif /* _CONTROL_THEME_H */
|
||||
// Theme add-ons should export these functions:
|
||||
#if defined(_BUILDING_THEME_ADDON)
|
||||
extern "C" BMediaTheme* make_theme(int32 id, image_id you);
|
||||
extern "C" status_t get_theme_at(int32 index, const char** _name,
|
||||
const char** _info, int32* _id);
|
||||
#endif // _BUILDING_THEME_ADDON
|
||||
|
||||
#endif // _CONTROL_THEME_H
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
/* Author: Marcus Overhagen
|
||||
** Axel Dörfler, [email protected]
|
||||
**
|
||||
** This file may be used under the terms of the OpenBeOS License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Marcus Overhagen
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "DefaultMediaTheme.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <MediaTheme.h>
|
||||
#include <StringView.h>
|
||||
@@ -11,87 +18,76 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "DefaultMediaTheme.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
static BLocker sLock;
|
||||
|
||||
/*************************************************************
|
||||
* static BMediaTheme variables
|
||||
*************************************************************/
|
||||
BMediaTheme* BMediaTheme::sDefaultTheme;
|
||||
|
||||
BMediaTheme * BMediaTheme::_mDefaultTheme;
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* public BMediaTheme
|
||||
*************************************************************/
|
||||
|
||||
BMediaTheme::~BMediaTheme()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
free(_mName);
|
||||
free(_mInfo);
|
||||
free(fName);
|
||||
free(fInfo);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
BMediaTheme::Name()
|
||||
{
|
||||
return _mName;
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
BMediaTheme::Info()
|
||||
{
|
||||
return _mInfo;
|
||||
return fInfo;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BMediaTheme::ID()
|
||||
{
|
||||
return _mID;
|
||||
return fID;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BMediaTheme::GetRef(entry_ref *out_ref)
|
||||
BMediaTheme::GetRef(entry_ref* ref)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
if (!fIsAddOn || ref == NULL)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
*ref = fAddOnRef;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
BMediaTheme::ViewFor(BParameterWeb *web, const BRect *hintRect, BMediaTheme *usingTheme)
|
||||
BMediaTheme::ViewFor(BParameterWeb* web, const BRect* hintRect,
|
||||
BMediaTheme* usingTheme)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// use default theme if none was specified
|
||||
if (usingTheme == NULL)
|
||||
usingTheme = PreferredTheme();
|
||||
|
||||
if (usingTheme == NULL) {
|
||||
BAutolock locker(sLock);
|
||||
|
||||
if (_mDefaultTheme == NULL)
|
||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||
|
||||
usingTheme = _mDefaultTheme;
|
||||
BStringView* view = new BStringView(BRect(0, 0, 200, 30), "",
|
||||
"No BMediaTheme available, sorry!");
|
||||
view->ResizeToPreferred();
|
||||
return view;
|
||||
}
|
||||
|
||||
if (usingTheme == NULL)
|
||||
return new BStringView(BRect(0, 0, 200, 30), "", "No BMediaTheme available, sorry!");
|
||||
|
||||
return usingTheme->MakeViewFor(web, hintRect);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaTheme::SetPreferredTheme(BMediaTheme *defaultTheme)
|
||||
BMediaTheme::SetPreferredTheme(BMediaTheme* defaultTheme)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
@@ -103,18 +99,18 @@ BMediaTheme::SetPreferredTheme(BMediaTheme *defaultTheme)
|
||||
if (defaultTheme == NULL) {
|
||||
// if the current preferred theme is not the default media theme,
|
||||
// delete it, and set it back to the default
|
||||
if (dynamic_cast<BPrivate::DefaultMediaTheme *>(_mDefaultTheme) == NULL)
|
||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||
if (dynamic_cast<BPrivate::DefaultMediaTheme *>(sDefaultTheme) == NULL)
|
||||
sDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// this method takes possession of the BMediaTheme passed, even
|
||||
// if it fails, so it has to delete it
|
||||
if (defaultTheme != _mDefaultTheme)
|
||||
delete _mDefaultTheme;
|
||||
if (defaultTheme != sDefaultTheme)
|
||||
delete sDefaultTheme;
|
||||
|
||||
_mDefaultTheme = defaultTheme;
|
||||
sDefaultTheme = defaultTheme;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -131,10 +127,10 @@ BMediaTheme::PreferredTheme()
|
||||
// add-on and load this from disk - in the meantime, just use
|
||||
// the default theme
|
||||
|
||||
if (_mDefaultTheme == NULL)
|
||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||
if (sDefaultTheme == NULL)
|
||||
sDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||
|
||||
return _mDefaultTheme;
|
||||
return sDefaultTheme;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,9 +146,7 @@ rgb_color
|
||||
BMediaTheme::BackgroundColorFor(bg_kind bg)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
rgb_color dummy = {0, 0, 0};
|
||||
|
||||
return dummy;
|
||||
return ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,25 +160,22 @@ BMediaTheme::ForegroundColorFor(fg_kind fg)
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* protected BMediaTheme
|
||||
*************************************************************/
|
||||
|
||||
|
||||
BMediaTheme::BMediaTheme(const char *name, const char *info, const entry_ref *ref, int32 id)
|
||||
//! protected BMediaTheme
|
||||
BMediaTheme::BMediaTheme(const char* name, const char* info,
|
||||
const entry_ref* ref, int32 id)
|
||||
:
|
||||
_mID(id)
|
||||
fID(id)
|
||||
{
|
||||
_mName = strdup(name);
|
||||
_mInfo = strdup(info);
|
||||
fName = strdup(name);
|
||||
fInfo = strdup(info);
|
||||
|
||||
// ToDo: is there something else here, which has to be done?
|
||||
|
||||
if (ref) {
|
||||
_mAddOn = true;
|
||||
_mAddOnRef = *ref;
|
||||
fIsAddOn = true;
|
||||
fAddOnRef = *ref;
|
||||
} else
|
||||
_mAddOn = false;
|
||||
fIsAddOn = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -198,10 +189,6 @@ BMediaTheme::MakeFallbackViewFor(BParameter *parameter)
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* private BMediaTheme
|
||||
*************************************************************/
|
||||
|
||||
/*
|
||||
private unimplemented
|
||||
BMediaTheme::BMediaTheme()
|
||||
|
||||
Reference in New Issue
Block a user