* 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 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
/ File: ControlTheme.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: A BMediaTheme is something which can live in an add-on and is
|
#ifndef _CONTROL_THEME_H
|
||||||
/ 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)
|
|
||||||
#define _CONTROL_THEME_H
|
#define _CONTROL_THEME_H
|
||||||
|
|
||||||
|
|
||||||
@@ -21,30 +12,22 @@
|
|||||||
class BParameterWeb;
|
class BParameterWeb;
|
||||||
|
|
||||||
|
|
||||||
class BMediaTheme
|
class BMediaTheme {
|
||||||
{
|
public:
|
||||||
public:
|
virtual ~BMediaTheme();
|
||||||
virtual ~BMediaTheme();
|
|
||||||
|
|
||||||
const char * Name();
|
const char* Name();
|
||||||
const char * Info();
|
const char* Info();
|
||||||
int32 ID();
|
int32 ID();
|
||||||
bool GetRef(
|
bool GetRef(entry_ref* ref);
|
||||||
entry_ref * out_ref);
|
|
||||||
|
|
||||||
static BView * ViewFor(
|
static BView* ViewFor(BParameterWeb* web, const BRect* hintRect = NULL,
|
||||||
BParameterWeb * web,
|
BMediaTheme* usingTheme = NULL);
|
||||||
const BRect * hintRect = NULL,
|
|
||||||
BMediaTheme * using_theme = NULL);
|
|
||||||
|
|
||||||
/* This function takes possession of default_theme, even it if returns error */
|
static status_t SetPreferredTheme(BMediaTheme* defaultTheme = NULL);
|
||||||
static status_t SetPreferredTheme(
|
static BMediaTheme* PreferredTheme();
|
||||||
BMediaTheme * default_theme = NULL);
|
|
||||||
|
|
||||||
static BMediaTheme * PreferredTheme();
|
virtual BControl* MakeControlFor(BParameter* control) = 0;
|
||||||
|
|
||||||
virtual BControl * MakeControlFor(
|
|
||||||
BParameter * control) = 0;
|
|
||||||
|
|
||||||
enum bg_kind {
|
enum bg_kind {
|
||||||
B_GENERAL_BG = 0,
|
B_GENERAL_BG = 0,
|
||||||
@@ -63,60 +46,50 @@ virtual BControl * MakeControlFor(
|
|||||||
B_HILITE_FG
|
B_HILITE_FG
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual BBitmap * BackgroundBitmapFor(
|
virtual BBitmap* BackgroundBitmapFor(bg_kind bg = B_GENERAL_BG);
|
||||||
bg_kind bg = B_GENERAL_BG);
|
virtual rgb_color BackgroundColorFor(bg_kind bg = B_GENERAL_BG);
|
||||||
virtual rgb_color BackgroundColorFor(
|
virtual rgb_color ForegroundColorFor(fg_kind fg = B_GENERAL_FG);
|
||||||
bg_kind bg = B_GENERAL_BG);
|
|
||||||
virtual rgb_color ForegroundColorFor(
|
|
||||||
fg_kind fg = B_GENERAL_FG);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BMediaTheme(
|
BMediaTheme(const char* name, const char* info,
|
||||||
const char * name,
|
const entry_ref* addOn = NULL, int32 themeID = 0);
|
||||||
const char * info,
|
|
||||||
const entry_ref * add_on = 0,
|
|
||||||
int32 theme_id = 0);
|
|
||||||
|
|
||||||
virtual BView * MakeViewFor(
|
virtual BView* MakeViewFor(BParameterWeb* web,
|
||||||
BParameterWeb * web,
|
const BRect* hintRect = NULL) = 0;
|
||||||
const BRect * hintRect = NULL) = 0;
|
|
||||||
|
|
||||||
static BControl * MakeFallbackViewFor(
|
static BControl* MakeFallbackViewFor(BParameter* control);
|
||||||
BParameter * control);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
BMediaTheme(); /* private unimplemented */
|
BMediaTheme(); /* private unimplemented */
|
||||||
BMediaTheme(
|
BMediaTheme(const BMediaTheme& other);
|
||||||
const BMediaTheme & clone);
|
BMediaTheme& operator=(const BMediaTheme& other);
|
||||||
BMediaTheme & operator=(
|
|
||||||
const BMediaTheme & clone);
|
|
||||||
|
|
||||||
/* Mmmh, stuffing! */
|
virtual status_t _Reserved_ControlTheme_0(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_0(void *);
|
virtual status_t _Reserved_ControlTheme_1(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_1(void *);
|
virtual status_t _Reserved_ControlTheme_2(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_2(void *);
|
virtual status_t _Reserved_ControlTheme_3(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_3(void *);
|
virtual status_t _Reserved_ControlTheme_4(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_4(void *);
|
virtual status_t _Reserved_ControlTheme_5(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_5(void *);
|
virtual status_t _Reserved_ControlTheme_6(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_6(void *);
|
virtual status_t _Reserved_ControlTheme_7(void *);
|
||||||
virtual status_t _Reserved_ControlTheme_7(void *);
|
|
||||||
|
|
||||||
char * _mName;
|
char* fName;
|
||||||
char * _mInfo;
|
char* fInfo;
|
||||||
int32 _mID;
|
int32 fID;
|
||||||
bool _mAddOn;
|
bool fIsAddOn;
|
||||||
entry_ref _mAddOnRef;
|
entry_ref fAddOnRef;
|
||||||
uint32 _reserved_control_theme_[8];
|
|
||||||
|
|
||||||
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]
|
* Copyright 2001-2006, Haiku.
|
||||||
**
|
* Distributed under the terms of the MIT License.
|
||||||
** This file may be used under the terms of the OpenBeOS License.
|
*
|
||||||
*/
|
* Authors:
|
||||||
|
* Marcus Overhagen
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DefaultMediaTheme.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include <MediaTheme.h>
|
#include <MediaTheme.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
@@ -11,87 +18,76 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "DefaultMediaTheme.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
|
|
||||||
static BLocker sLock;
|
static BLocker sLock;
|
||||||
|
|
||||||
/*************************************************************
|
BMediaTheme* BMediaTheme::sDefaultTheme;
|
||||||
* static BMediaTheme variables
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
BMediaTheme * BMediaTheme::_mDefaultTheme;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* public BMediaTheme
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
BMediaTheme::~BMediaTheme()
|
BMediaTheme::~BMediaTheme()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
free(_mName);
|
free(fName);
|
||||||
free(_mInfo);
|
free(fInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BMediaTheme::Name()
|
BMediaTheme::Name()
|
||||||
{
|
{
|
||||||
return _mName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BMediaTheme::Info()
|
BMediaTheme::Info()
|
||||||
{
|
{
|
||||||
return _mInfo;
|
return fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BMediaTheme::ID()
|
BMediaTheme::ID()
|
||||||
{
|
{
|
||||||
return _mID;
|
return fID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
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 *
|
BView *
|
||||||
BMediaTheme::ViewFor(BParameterWeb *web, const BRect *hintRect, BMediaTheme *usingTheme)
|
BMediaTheme::ViewFor(BParameterWeb* web, const BRect* hintRect,
|
||||||
|
BMediaTheme* usingTheme)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// use default theme if none was specified
|
// use default theme if none was specified
|
||||||
|
if (usingTheme == NULL)
|
||||||
|
usingTheme = PreferredTheme();
|
||||||
|
|
||||||
if (usingTheme == NULL) {
|
if (usingTheme == NULL) {
|
||||||
BAutolock locker(sLock);
|
BStringView* view = new BStringView(BRect(0, 0, 200, 30), "",
|
||||||
|
"No BMediaTheme available, sorry!");
|
||||||
if (_mDefaultTheme == NULL)
|
view->ResizeToPreferred();
|
||||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
return view;
|
||||||
|
|
||||||
usingTheme = _mDefaultTheme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingTheme == NULL)
|
|
||||||
return new BStringView(BRect(0, 0, 200, 30), "", "No BMediaTheme available, sorry!");
|
|
||||||
|
|
||||||
return usingTheme->MakeViewFor(web, hintRect);
|
return usingTheme->MakeViewFor(web, hintRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTheme::SetPreferredTheme(BMediaTheme *defaultTheme)
|
BMediaTheme::SetPreferredTheme(BMediaTheme* defaultTheme)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -103,18 +99,18 @@ BMediaTheme::SetPreferredTheme(BMediaTheme *defaultTheme)
|
|||||||
if (defaultTheme == NULL) {
|
if (defaultTheme == NULL) {
|
||||||
// if the current preferred theme is not the default media theme,
|
// if the current preferred theme is not the default media theme,
|
||||||
// delete it, and set it back to the default
|
// delete it, and set it back to the default
|
||||||
if (dynamic_cast<BPrivate::DefaultMediaTheme *>(_mDefaultTheme) == NULL)
|
if (dynamic_cast<BPrivate::DefaultMediaTheme *>(sDefaultTheme) == NULL)
|
||||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
sDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method takes possession of the BMediaTheme passed, even
|
// this method takes possession of the BMediaTheme passed, even
|
||||||
// if it fails, so it has to delete it
|
// if it fails, so it has to delete it
|
||||||
if (defaultTheme != _mDefaultTheme)
|
if (defaultTheme != sDefaultTheme)
|
||||||
delete _mDefaultTheme;
|
delete sDefaultTheme;
|
||||||
|
|
||||||
_mDefaultTheme = defaultTheme;
|
sDefaultTheme = defaultTheme;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -131,10 +127,10 @@ BMediaTheme::PreferredTheme()
|
|||||||
// add-on and load this from disk - in the meantime, just use
|
// add-on and load this from disk - in the meantime, just use
|
||||||
// the default theme
|
// the default theme
|
||||||
|
|
||||||
if (_mDefaultTheme == NULL)
|
if (sDefaultTheme == NULL)
|
||||||
_mDefaultTheme = new BPrivate::DefaultMediaTheme();
|
sDefaultTheme = new BPrivate::DefaultMediaTheme();
|
||||||
|
|
||||||
return _mDefaultTheme;
|
return sDefaultTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,9 +146,7 @@ rgb_color
|
|||||||
BMediaTheme::BackgroundColorFor(bg_kind bg)
|
BMediaTheme::BackgroundColorFor(bg_kind bg)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
rgb_color dummy = {0, 0, 0};
|
return ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
return dummy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,25 +160,22 @@ BMediaTheme::ForegroundColorFor(fg_kind fg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
//! protected BMediaTheme
|
||||||
* protected BMediaTheme
|
BMediaTheme::BMediaTheme(const char* name, const char* info,
|
||||||
*************************************************************/
|
const entry_ref* ref, int32 id)
|
||||||
|
|
||||||
|
|
||||||
BMediaTheme::BMediaTheme(const char *name, const char *info, const entry_ref *ref, int32 id)
|
|
||||||
:
|
:
|
||||||
_mID(id)
|
fID(id)
|
||||||
{
|
{
|
||||||
_mName = strdup(name);
|
fName = strdup(name);
|
||||||
_mInfo = strdup(info);
|
fInfo = strdup(info);
|
||||||
|
|
||||||
// ToDo: is there something else here, which has to be done?
|
// ToDo: is there something else here, which has to be done?
|
||||||
|
|
||||||
if (ref) {
|
if (ref) {
|
||||||
_mAddOn = true;
|
fIsAddOn = true;
|
||||||
_mAddOnRef = *ref;
|
fAddOnRef = *ref;
|
||||||
} else
|
} else
|
||||||
_mAddOn = false;
|
fIsAddOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -198,10 +189,6 @@ BMediaTheme::MakeFallbackViewFor(BParameter *parameter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* private BMediaTheme
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private unimplemented
|
private unimplemented
|
||||||
BMediaTheme::BMediaTheme()
|
BMediaTheme::BMediaTheme()
|
||||||
|
|||||||
Reference in New Issue
Block a user