2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
Theme.h
|
|
|
|
|
|
|
|
James Crook
|
|
|
|
|
|
|
|
Audacity is free software.
|
|
|
|
This file is licensed under the wxWidgets license, see License.txt
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_THEME__
|
|
|
|
#define __AUDACITY_THEME__
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-02 18:24:53 +00:00
|
|
|
#include <vector>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/defs.h>
|
2018-11-11 19:38:47 +00:00
|
|
|
#include <wx/window.h> // to inherit
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-11-12 00:47:44 +00:00
|
|
|
class wxArrayString;
|
2018-11-14 19:10:04 +00:00
|
|
|
class wxBitmap;
|
2018-11-14 20:01:44 +00:00
|
|
|
class wxColour;
|
|
|
|
class wxFont;
|
2018-11-14 20:23:25 +00:00
|
|
|
class wxImage;
|
2018-11-14 18:50:12 +00:00
|
|
|
class wxPen;
|
2018-11-12 00:47:44 +00:00
|
|
|
|
2020-05-26 18:08:25 +00:00
|
|
|
class ChoiceSetting;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
// JKC: will probably change name from 'teBmps' to 'tIndexBmp';
|
2020-05-26 17:31:32 +00:00
|
|
|
using teBmps = int; /// The index of a bitmap resource in Theme Resources.
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
enum teResourceType
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
resTypeColour,
|
|
|
|
resTypeBitmap,
|
|
|
|
resTypeImage = resTypeBitmap,
|
|
|
|
resTypeCursor,
|
|
|
|
resTypeFont
|
|
|
|
};
|
|
|
|
|
|
|
|
enum teResourceFlags
|
|
|
|
{
|
|
|
|
resFlagNone =0x00,
|
|
|
|
resFlagPaired =0x01,
|
|
|
|
resFlagCursor =0x02,
|
|
|
|
resFlagNewLine = 0x04,
|
2017-05-13 17:34:48 +00:00
|
|
|
resFlagInternal = 0x08, // For image manipulation. Don't save or load.
|
|
|
|
resFlagSkip = 0x10
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2017-04-02 22:07:13 +00:00
|
|
|
enum teThemeType
|
|
|
|
{
|
|
|
|
themeClassic,
|
|
|
|
themeDark,
|
|
|
|
themeLight,
|
2017-04-10 11:09:38 +00:00
|
|
|
themeHiContrast,
|
2017-04-02 22:07:13 +00:00
|
|
|
themeFromFile,
|
|
|
|
};
|
|
|
|
|
2017-05-04 15:56:32 +00:00
|
|
|
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
class AUDACITY_DLL_API FlowPacker
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FlowPacker(){;};
|
|
|
|
~FlowPacker(){;};
|
|
|
|
void Init(int width);
|
|
|
|
void GetNextPosition( int xSize, int ySize );
|
|
|
|
void SetNewGroup( int iGroupSize );
|
2016-09-11 12:03:37 +00:00
|
|
|
void SetColourGroup( );
|
2010-01-23 19:44:49 +00:00
|
|
|
wxRect Rect();
|
2017-05-04 20:41:18 +00:00
|
|
|
wxRect RectInner();
|
2010-01-23 19:44:49 +00:00
|
|
|
void RectMid( int &x, int &y );
|
|
|
|
|
|
|
|
// These 4 should become private again...
|
|
|
|
int mFlags;
|
|
|
|
int mxPos;
|
|
|
|
int myPos;
|
|
|
|
int myHeight;
|
2017-05-04 20:41:18 +00:00
|
|
|
int mBorderWidth;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
private:
|
2014-06-03 20:30:19 +00:00
|
|
|
int iImageGroupSize;
|
2010-01-23 19:44:49 +00:00
|
|
|
int iImageGroupIndex;
|
|
|
|
int mOldFlags;
|
|
|
|
int myPosBase;
|
|
|
|
int mxWidth;
|
|
|
|
int mxCacheWidth;
|
|
|
|
|
|
|
|
int mComponentWidth;
|
|
|
|
int mComponentHeight;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class AUDACITY_DLL_API ThemeBase /* not final */
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ThemeBase(void);
|
2020-05-26 20:20:10 +00:00
|
|
|
ThemeBase ( const ThemeBase & ) = delete;
|
|
|
|
ThemeBase &operator =( const ThemeBase & ) = delete;
|
2010-01-23 19:44:49 +00:00
|
|
|
public:
|
|
|
|
virtual ~ThemeBase(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void EnsureInitialised()=0;
|
2017-04-02 22:07:13 +00:00
|
|
|
void LoadTheme( teThemeType Theme );
|
2010-01-23 19:44:49 +00:00
|
|
|
void RegisterImage( int &iIndex,char const** pXpm, const wxString & Name);
|
|
|
|
void RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name );
|
|
|
|
void RegisterColour( int &iIndex, const wxColour &Clr, const wxString & Name );
|
|
|
|
|
2017-04-02 22:07:13 +00:00
|
|
|
teThemeType GetFallbackThemeType();
|
|
|
|
teThemeType ThemeTypeOfTypeName( const wxString & Name );
|
2010-01-23 19:44:49 +00:00
|
|
|
void CreateImageCache(bool bBinarySave = true);
|
2017-04-02 22:07:13 +00:00
|
|
|
bool ReadImageCache( teThemeType type = themeFromFile, bool bOkIfNotFound=false);
|
2010-01-23 19:44:49 +00:00
|
|
|
void LoadComponents( bool bOkIfNotFound =false);
|
|
|
|
void SaveComponents();
|
|
|
|
void SaveThemeAsCode();
|
|
|
|
void WriteImageDefs( );
|
|
|
|
void WriteImageMap( );
|
2017-04-02 22:07:13 +00:00
|
|
|
static bool LoadPreferredTheme();
|
2017-10-19 17:08:04 +00:00
|
|
|
bool IsUsingSystemTextColour(){ return bIsUsingSystemTextColour;};
|
2017-04-08 13:49:10 +00:00
|
|
|
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
|
|
|
void RecolourTheme();
|
2017-04-02 22:07:13 +00:00
|
|
|
|
2017-04-26 15:28:41 +00:00
|
|
|
int ColourDistance( wxColour & From, wxColour & To );
|
2010-01-23 19:44:49 +00:00
|
|
|
wxColour & Colour( int iIndex );
|
|
|
|
wxBitmap & Bitmap( int iIndex );
|
2014-06-03 20:30:19 +00:00
|
|
|
wxImage & Image( int iIndex );
|
2010-01-23 19:44:49 +00:00
|
|
|
wxCursor & Cursor( int iIndex );
|
|
|
|
wxFont & Font( int iIndex );
|
|
|
|
wxSize ImageSize( int iIndex );
|
2017-04-26 14:35:57 +00:00
|
|
|
bool bRecolourOnLoad; // Request to recolour.
|
Bug 1630 - Accessibility of the length/end radio buttons
For Light and Classic themes that use black text, we'll use the length/end buttons because Windows uses black for text.
For Dark and HiContrast themes that use a light colour for text, we'll use the length/end buttons IF the OS is set to use the exact same colour for text.
That for example happens if we use Microsoft's HiContrast2 and our HiContrast theme.
If the OS and theme text colour differ, then if we set blend theme colours option, which is the default, we might still use the OS colour for text in Audacity. That will happen if the OS colour has decent contrast to our theme's background colour. Decent is defined as more than 250 difference in RGB values. If we use the OS colour for text, then we get the proper length/end buttons.
Note that this adds a new feature to the theme blending, in that the text colour will often adapt. Useful when using custom text colours with HiContrast2. When the text colour adapts, we will continue to get proper length/end buttons.
Advice to users is to match OS and Audacity themes, and use the blend option. When themes don't match, it may be desirable to disable blending.
2017-04-28 14:42:33 +00:00
|
|
|
bool bIsUsingSystemTextColour;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void ReplaceImage( int iIndex, wxImage * pImage );
|
2017-05-01 10:46:12 +00:00
|
|
|
void RotateImageInto( int iTo, int iFrom, bool bClockwise );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void SetBrushColour( wxBrush & Brush, int iIndex );
|
|
|
|
void SetPenColour( wxPen & Pen, int iIndex );
|
|
|
|
void SetFlags( int flags ){ mFlow.mFlags = flags;};
|
|
|
|
|
|
|
|
// Utility function that combines a bitmap and a mask, both in XPM format.
|
|
|
|
wxImage MaskedImage( char const ** pXpm, char const ** pMask );
|
2020-04-11 07:08:33 +00:00
|
|
|
// Utility function that takes a 32 bit bitmap and makes it into an image.
|
2010-01-23 19:44:49 +00:00
|
|
|
wxImage MakeImageWithAlpha( wxBitmap & Bmp );
|
|
|
|
|
|
|
|
protected:
|
2018-02-02 18:24:53 +00:00
|
|
|
// wxImage, wxBitmap copy cheaply using reference counting
|
|
|
|
std::vector<wxImage> mImages;
|
|
|
|
std::vector<wxBitmap> mBitmaps;
|
2010-01-23 19:44:49 +00:00
|
|
|
wxArrayString mBitmapNames;
|
2018-02-02 19:49:46 +00:00
|
|
|
std::vector<int> mBitmapFlags;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-02 18:24:53 +00:00
|
|
|
std::vector<wxColour> mColours;
|
2010-01-23 19:44:49 +00:00
|
|
|
wxArrayString mColourNames;
|
|
|
|
FlowPacker mFlow;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class AUDACITY_DLL_API Theme final : public ThemeBase
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Theme(void);
|
|
|
|
public:
|
|
|
|
~Theme(void);
|
|
|
|
public:
|
2016-02-24 06:06:47 +00:00
|
|
|
void EnsureInitialised() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
void RegisterImages();
|
|
|
|
void RegisterColours();
|
|
|
|
bool mbInitialised;
|
|
|
|
};
|
|
|
|
|
2017-08-12 20:49:38 +00:00
|
|
|
// A bit cheeky - putting a themable wxStaticText control into
|
|
|
|
// theme, rather than in a new file. Saves sorting out makefiles (for now).
|
|
|
|
class wxWindow;
|
|
|
|
class wxString;
|
|
|
|
class wxPaintEvent;
|
|
|
|
|
2020-09-28 12:50:18 +00:00
|
|
|
class AUDACITY_DLL_API auStaticText : public wxWindow
|
2017-08-12 20:49:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
auStaticText(wxWindow* parent, wxString text);
|
|
|
|
void OnPaint(wxPaintEvent & evt);
|
2017-08-16 12:39:16 +00:00
|
|
|
bool AcceptsFocus() const override { return false; }
|
2018-04-14 20:38:53 +00:00
|
|
|
void OnErase(wxEraseEvent& event) {
|
|
|
|
static_cast<void>(event);
|
|
|
|
};
|
2017-08-12 20:49:38 +00:00
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
extern AUDACITY_DLL_API Theme theTheme;
|
|
|
|
|
2020-09-28 12:50:18 +00:00
|
|
|
extern AUDACITY_DLL_API ChoiceSetting
|
2020-05-26 18:08:25 +00:00
|
|
|
GUITheme
|
|
|
|
;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#endif // __AUDACITY_THEME__
|