Merge branch 'colour_dialogs_alpha_generic' of https://github.com/a-wi/wxWidgets into wip

Add support for alpha channel to wxGenericColourDialog.

See #14127.
This commit is contained in:
Vadim Zeitlin
2015-11-15 00:49:01 +01:00
7 changed files with 306 additions and 75 deletions

View File

@@ -26,6 +26,8 @@ public:
void SetChooseFull(bool flag) { m_chooseFull = flag; }
bool GetChooseFull() const { return m_chooseFull; }
void SetChooseAlpha(bool flag) { m_chooseAlpha = flag; }
bool GetChooseAlpha() const { return m_chooseAlpha; }
void SetColour(const wxColour& colour) { m_dataColour = colour; }
const wxColour& GetColour() const { return m_dataColour; }
wxColour& GetColour() { return m_dataColour; }
@@ -45,6 +47,9 @@ public:
wxColour m_custColours[NUM_CUSTOM];
bool m_chooseFull;
protected:
bool m_chooseAlpha;
wxDECLARE_DYNAMIC_CLASS(wxColourData);
};

View File

@@ -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;
@@ -75,10 +85,7 @@ protected:
wxRect m_singleCustomColourRect;
// Size of each colour rectangle
wxPoint m_smallRectangleSize;
// For single customizable colour
wxPoint m_customRectangleSize;
wxSize m_smallRectangleSize;
// Grid spacing (between rectangles)
int m_gridSpacing;
@@ -100,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;