Add alpha channel support to wxGenericColourDialog.
Added opacity slider and custom colours (with alpha) previews (implemented with wxStaticBitmap controls). This feature is controlled by wxColourData::GetChooseAlpha().
This commit is contained in:
@@ -14,18 +14,18 @@
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/dialog.h"
|
||||
|
||||
#define wxID_ADD_CUSTOM 3000
|
||||
|
||||
#if wxUSE_SLIDER
|
||||
|
||||
#define wxID_RED_SLIDER 3001
|
||||
#define wxID_GREEN_SLIDER 3002
|
||||
#define wxID_BLUE_SLIDER 3003
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxSlider;
|
||||
|
||||
#endif // wxUSE_SLIDER
|
||||
|
||||
// Preview with opacity is possible only
|
||||
// if wxGCDC and wxStaticBitmap are available.
|
||||
#define wxCLRDLGG_USE_PREVIEW_WITH_ALPHA (wxUSE_GRAPHICS_CONTEXT && wxUSE_STATBMP)
|
||||
|
||||
#if wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
class wxStaticBitmap;
|
||||
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGenericColourDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
@@ -43,13 +43,18 @@ public:
|
||||
// Internal functions
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
#if wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
void OnCustomColourMouseClick(wxMouseEvent& event);
|
||||
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
|
||||
virtual void CalculateMeasurements();
|
||||
virtual void CreateWidgets();
|
||||
virtual void InitializeColours();
|
||||
|
||||
virtual void PaintBasicColours(wxDC& dc);
|
||||
virtual void PaintCustomColours(wxDC& dc);
|
||||
#if !wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
virtual void PaintCustomColours(wxDC& dc, int clrIndex = -1);
|
||||
#endif // !wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
virtual void PaintCustomColour(wxDC& dc);
|
||||
virtual void PaintHighlight(wxDC& dc, bool draw);
|
||||
|
||||
@@ -62,10 +67,15 @@ public:
|
||||
void OnRedSlider(wxCommandEvent& event);
|
||||
void OnGreenSlider(wxCommandEvent& event);
|
||||
void OnBlueSlider(wxCommandEvent& event);
|
||||
void OnAlphaSlider(wxCommandEvent& event);
|
||||
#endif // wxUSE_SLIDER
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
#if wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
void DoPreviewBitmap(wxBitmap& bmp, const wxColour& colour);
|
||||
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
|
||||
protected:
|
||||
wxColourData m_colourData;
|
||||
|
||||
@@ -97,7 +107,14 @@ protected:
|
||||
wxSlider *m_redSlider;
|
||||
wxSlider *m_greenSlider;
|
||||
wxSlider *m_blueSlider;
|
||||
wxSlider *m_alphaSlider;
|
||||
#endif // wxUSE_SLIDER
|
||||
#if wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
// Bitmap to preview selected colour (with alpha channel)
|
||||
wxStaticBitmap *m_customColourBmp;
|
||||
// Bitmaps to preview custom colours (with alpha channel)
|
||||
wxStaticBitmap *m_customColoursBmp[16];
|
||||
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
|
||||
|
||||
int m_buttonY;
|
||||
|
||||
|
Reference in New Issue
Block a user