initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit 7228269764
9653 changed files with 4034514 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/aboutdlgg.h
// Purpose: generic wxAboutBox() implementation
// Author: Vadim Zeitlin
// Created: 2006-10-07
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_ABOUTDLGG_H_
#define _WX_GENERIC_ABOUTDLGG_H_
#include "wx/defs.h"
#if wxUSE_ABOUTDLG
#include "wx/dialog.h"
class WXDLLIMPEXP_FWD_CORE wxAboutDialogInfo;
class WXDLLIMPEXP_FWD_CORE wxPanel;
class WXDLLIMPEXP_FWD_CORE wxSizer;
class WXDLLIMPEXP_FWD_CORE wxSizerFlags;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
// Under GTK and OS X "About" dialogs are not supposed to be modal, unlike MSW
// and, presumably, all the other platforms.
#ifndef wxUSE_MODAL_ABOUT_DIALOG
#if defined(__WXGTK__) || defined(__WXMAC__)
#define wxUSE_MODAL_ABOUT_DIALOG 0
#else
#define wxUSE_MODAL_ABOUT_DIALOG 1
#endif
#endif // wxUSE_MODAL_ABOUT_DIALOG not defined
// ----------------------------------------------------------------------------
// wxGenericAboutDialog: generic "About" dialog implementation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericAboutDialog : public wxDialog
{
public:
// constructors and Create() method
// --------------------------------
// default ctor, you must use Create() to really initialize the dialog
wxGenericAboutDialog() = default;
// ctor which fully initializes the object
wxGenericAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent = nullptr)
{
(void)Create(info, parent);
}
// this method must be called if and only if the default ctor was used
bool Create(const wxAboutDialogInfo& info, wxWindow* parent = nullptr);
protected:
// Return the parent to use for custom controls.
wxWindow* GetCustomControlParent() const { return m_contents; }
// This virtual method may be overridden to add some more controls to the
// dialog. The controls should be created using GetCustomControlParent() as
// the parent and then passed to AddControl().
//
// notice that for this to work you must call Create() from the derived
// class ctor and not use the base class ctor directly as otherwise the
// virtual function of the derived class wouldn't be called
virtual void DoAddCustomControls() { }
// add arbitrary control to the text sizer contents with the specified
// flags
void AddControl(wxWindow *win, const wxSizerFlags& flags);
// add arbitrary control to the text sizer contents and center it
void AddControl(wxWindow *win);
// add the text, if it's not empty, to the text sizer contents
wxStaticText* AddText(const wxString& text);
#if wxUSE_COLLPANE
// add a wxCollapsiblePane containing the given text
void AddCollapsiblePane(const wxString& title, const wxString& text);
#endif // wxUSE_COLLPANE
private:
#if !wxUSE_MODAL_ABOUT_DIALOG
// An explicit handler for deleting the dialog when it's closed is needed
// when we show it non-modally.
void OnCloseWindow(wxCloseEvent& event);
void OnOK(wxCommandEvent& event);
#endif // !wxUSE_MODAL_ABOUT_DIALOG
// The panel containing the dialog contents.
wxWindow *m_contents = nullptr;
wxSizer *m_sizerText = nullptr;
};
// unlike wxAboutBox which can show either the native or generic about dialog,
// this function always shows the generic one
WXDLLIMPEXP_CORE void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = nullptr);
#endif // wxUSE_ABOUTDLG
#endif // _WX_GENERIC_ABOUTDLGG_H_

View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/accel.h
// Purpose: wxAcceleratorTable class
// Author: Robert Roebling
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_ACCEL_H_
#define _WX_GENERIC_ACCEL_H_
class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
// ----------------------------------------------------------------------------
// wxAcceleratorTable
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAcceleratorTable : public wxObject
{
public:
wxAcceleratorTable();
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
bool Ok() const { return IsOk(); }
bool IsOk() const;
void Add(const wxAcceleratorEntry& entry);
void Remove(const wxAcceleratorEntry& entry);
// implementation
// --------------
wxMenuItem *GetMenuItem(const wxKeyEvent& event) const;
int GetCommand(const wxKeyEvent& event) const;
const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const;
protected:
// ref counting code
virtual wxObjectRefData *CreateRefData() const override;
wxNODISCARD virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxAcceleratorTable);
};
#endif // _WX_GENERIC_ACCEL_H_

View File

@@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/activityindicator.h
// Purpose: Declaration of wxActivityIndicatorGeneric.
// Author: Vadim Zeitlin
// Created: 2015-03-06
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_ACTIVITYINDICATOR_H_
#define _WX_GENERIC_ACTIVITYINDICATOR_H_
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
// This is the only implementation we have, so call it accordingly.
#define wxActivityIndicatorGeneric wxActivityIndicator
#endif
// ----------------------------------------------------------------------------
// wxActivityIndicatorGeneric: built-in generic implementation.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxActivityIndicatorGeneric : public wxActivityIndicatorBase
{
public:
wxActivityIndicatorGeneric()
{
m_impl = nullptr;
}
explicit
wxActivityIndicatorGeneric(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxActivityIndicatorNameStr)
{
m_impl = nullptr;
Create(parent, winid, pos, size, style, name);
}
bool Create(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxActivityIndicatorNameStr);
virtual ~wxActivityIndicatorGeneric();
virtual void Start() override;
virtual void Stop() override;
virtual bool IsRunning() const override;
protected:
virtual wxSize DoGetBestClientSize() const override;
private:
class wxActivityIndicatorImpl *m_impl;
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
wxDECLARE_DYNAMIC_CLASS(wxActivityIndicator);
#endif
};
#endif // _WX_GENERIC_ACTIVITYINDICATOR_H_

View File

@@ -0,0 +1,151 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/animate.h
// Purpose: wxGenericAnimationCtrl
// Author: Julian Smart and Guillermo Rodriguez Garcia
// Modified by: Francesco Montorsi
// Created: 13/8/99
// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_ANIMATEH__
#define _WX_GENERIC_ANIMATEH__
#include "wx/bmpbndl.h"
// ----------------------------------------------------------------------------
// wxGenericAnimationCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGenericAnimationCtrl: public wxAnimationCtrlBase
{
public:
wxGenericAnimationCtrl() { Init(); }
wxGenericAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxAnimationCtrlNameStr))
{
Init();
Create(parent, id, anim, pos, size, style, name);
}
void Init();
bool Create(wxWindow *parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxAnimationCtrlNameStr));
~wxGenericAnimationCtrl();
public:
virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY) override;
virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY) override;
virtual void Stop() override;
virtual bool Play() override
{ return Play(true /* looped */); }
virtual bool IsPlaying() const override
{ return m_isPlaying; }
void SetAnimation(const wxAnimationBundle &animations) override;
virtual void SetInactiveBitmap(const wxBitmapBundle &bmp) override;
// override base class method
virtual bool SetBackgroundColour(const wxColour& col) override;
static wxAnimation CreateCompatibleAnimation();
public: // event handlers
void OnPaint(wxPaintEvent& event);
void OnTimer(wxTimerEvent& event);
void OnSize(wxSizeEvent& event);
public: // extended API specific to this implementation of wxAnimateCtrl
// Specify whether the animation's background colour is to be shown (the default),
// or whether the window background should show through
void SetUseWindowBackgroundColour(bool useWinBackground = true)
{ m_useWinBackgroundColour = useWinBackground; }
bool IsUsingWindowBackgroundColour() const
{ return m_useWinBackgroundColour; }
// This overload of Play() lets you specify if the animation must loop or not
bool Play(bool looped);
// Draw the current frame of the animation into given DC.
// This is fast as current frame is always cached.
void DrawCurrentFrame(wxDC& dc);
// Returns a wxBitmap with the current frame drawn in it
wxBitmap& GetBackingStore()
{ return m_backingStore; }
protected: // internal utilities
virtual wxAnimationImpl* DoCreateAnimationImpl() const override;
// resize this control to fit m_animation
void FitToAnimation();
// Draw the background; use this when e.g. previous frame had wxANIM_TOBACKGROUND disposal.
void DisposeToBackground();
void DisposeToBackground(wxDC& dc);
void DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz);
void IncrementalUpdateBackingStore();
bool RebuildBackingStoreUpToFrame(unsigned int);
void DrawFrame(wxDC &dc, unsigned int);
virtual void DisplayStaticImage() override;
virtual wxSize DoGetBestSize() const override;
// This function can be used as event handler for wxEVT_DPI_CHANGED event
// and simply calls UpdateStaticImage() to refresh the m_bmpStaticReal when it happens.
void WXHandleDPIChanged(wxDPIChangedEvent& event)
{
UpdateStaticImage();
event.Skip();
}
// Helpers to safely access methods in the wxAnimationGenericImpl that are
// specific to the generic implementation
wxPoint AnimationImplGetFramePosition(unsigned int frame) const;
wxSize AnimationImplGetFrameSize(unsigned int frame) const;
wxAnimationDisposal AnimationImplGetDisposalMethod(unsigned int frame) const;
wxColour AnimationImplGetTransparentColour(unsigned int frame) const;
wxColour AnimationImplGetBackgroundColour() const;
protected:
unsigned int m_currentFrame; // Current frame
bool m_looped; // Looped, or not
wxTimer m_timer; // The timer
bool m_isPlaying; // Is the animation playing?
bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour?
wxBitmap m_backingStore; // The frames are drawn here and then blitted
// on the screen
private:
// True if we need to show the next frame after painting the current one.
bool m_needToShowNextFrame = false;
typedef wxAnimationCtrlBase base_type;
wxDECLARE_DYNAMIC_CLASS(wxGenericAnimationCtrl);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_GENERIC_ANIMATEH__

View File

@@ -0,0 +1,137 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/bmpcbox.h
// Purpose: wxBitmapComboBox
// Author: Jaakko Salli
// Created: Aug-30-2006
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_BMPCBOX_H_
#define _WX_GENERIC_BMPCBOX_H_
#define wxGENERIC_BITMAPCOMBOBOX 1
#include "wx/odcombo.h"
// ----------------------------------------------------------------------------
// wxBitmapComboBox: a wxComboBox that allows images to be shown
// in front of string items.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxOwnerDrawnComboBox,
public wxBitmapComboBoxBase
{
public:
// ctors and such
wxBitmapComboBox() : wxOwnerDrawnComboBox(), wxBitmapComboBoxBase()
{
Init();
}
wxBitmapComboBox(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxBitmapComboBoxNameStr))
: wxOwnerDrawnComboBox(),
wxBitmapComboBoxBase()
{
Init();
(void)Create(parent, id, value, pos, size, n,
choices, style, validator, name);
}
wxBitmapComboBox(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxBitmapComboBoxNameStr));
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n,
const wxString choices[],
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxBitmapComboBoxNameStr));
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxBitmapComboBoxNameStr));
virtual ~wxBitmapComboBox();
virtual wxString GetStringSelection() const override;
// Adds item with image to the end of the combo box.
int Append(const wxString& item, const wxBitmapBundle& bitmap = wxBitmapBundle());
int Append(const wxString& item, const wxBitmapBundle& bitmap, void *clientData);
int Append(const wxString& item, const wxBitmapBundle& bitmap, wxClientData *clientData);
// Inserts item with image into the list before pos. Not valid for wxCB_SORT
// styles, use Append instead.
int Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos);
int Insert(const wxString& item, const wxBitmapBundle& bitmap,
unsigned int pos, void *clientData);
int Insert(const wxString& item, const wxBitmapBundle& bitmap,
unsigned int pos, wxClientData *clientData);
// Sets the image for the given item.
virtual void SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) override;
virtual bool SetFont(const wxFont& font) override;
protected:
virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const override;
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
virtual wxCoord OnMeasureItem(size_t item) const override;
virtual wxCoord OnMeasureItemWidth(size_t item) const override;
// Event handlers
void OnSize(wxSizeEvent& event);
virtual wxSize DoGetBestSize() const override;
virtual wxItemContainer* GetItemContainer() override { return this; }
virtual wxWindow* GetControl() override { return this; }
// wxItemContainer implementation
virtual int DoInsertItems(const wxArrayStringsAdapter & items,
unsigned int pos,
void **clientData, wxClientDataType type) override;
virtual void DoClear() override;
virtual void DoDeleteOneItem(unsigned int n) override;
private:
bool m_inResize;
void Init();
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxBitmapComboBox);
};
#endif // _WX_GENERIC_BMPCBOX_H_

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/busyinfo.h
// Purpose: Information window (when app is busy)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUSYINFO_H_
#define _WX_BUSYINFO_H_
#include "wx/defs.h"
#if wxUSE_BUSYINFO
#include "wx/object.h"
class WXDLLIMPEXP_FWD_CORE wxFrame;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxControl;
//--------------------------------------------------------------------------------
// wxBusyInfo
// Displays progress information
// Can be used in exactly same way as wxBusyCursor
//--------------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBusyInfo : public wxObject
{
public:
wxBusyInfo(const wxBusyInfoFlags& flags)
{
Init(flags);
}
wxBusyInfo(const wxString& message, wxWindow *parent = nullptr)
{
Init(wxBusyInfoFlags().Parent(parent).Label(message));
}
void UpdateText(const wxString& str);
void UpdateLabel(const wxString& str);
virtual ~wxBusyInfo();
private:
void Init(const wxBusyInfoFlags& flags);
wxFrame *m_InfoFrame;
wxControl *m_text;
wxDECLARE_NO_COPY_CLASS(wxBusyInfo);
};
#endif // wxUSE_BUSYINFO
#endif // _WX_BUSYINFO_H_

View File

@@ -0,0 +1,122 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/buttonbar.h
// Purpose: wxButtonToolBar declaration
// Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech
// Created: 2006-04-13
// Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin,
// SciTech Software, Inc.
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTONBAR_H_
#define _WX_BUTTONBAR_H_
#include "wx/bmpbuttn.h"
#include "wx/toolbar.h"
class WXDLLIMPEXP_FWD_CORE wxButtonToolBarTool;
// ----------------------------------------------------------------------------
// wxButtonToolBar
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxButtonToolBar : public wxToolBarBase
{
public:
// construction/destruction
wxButtonToolBar() { Init(); }
wxButtonToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxToolBarNameStr))
{
Init();
Create(parent, id, pos, size, style, name);
}
bool Create( wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxToolBarNameStr) );
virtual ~wxButtonToolBar();
virtual bool Realize() override;
virtual void SetToolShortHelp(int id, const wxString& helpString) override;
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const override;
protected:
// common part of all ctors
void Init();
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) override;
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) override;
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) override;
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) override;
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) override;
virtual wxToolBarToolBase *CreateTool(int id,
const wxString& label,
const wxBitmapBundle& bmpNormal,
const wxBitmapBundle& bmpDisabled,
wxItemKind kind,
wxObject *clientData,
const wxString& shortHelp,
const wxString& longHelp) override;
virtual wxToolBarToolBase *CreateTool(wxControl *control,
const wxString& label) override;
virtual wxSize DoGetBestClientSize() const override;
// calculate layout
void DoLayout();
// get the bounding rect for the given tool
wxRect GetToolRect(wxToolBarToolBase *tool) const;
// get the rect limits depending on the orientation: top/bottom for a
// vertical toolbar, left/right for a horizontal one
void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const;
// receives button commands
void OnCommand(wxCommandEvent& event);
// paints a border
void OnPaint(wxPaintEvent& event);
// detects mouse clicks outside buttons
void OnLeftUp(wxMouseEvent& event);
private:
// have we calculated the positions of our tools?
bool m_needsLayout;
// the width of a separator
wxCoord m_widthSeparator;
// the total size of all toolbar elements
wxCoord m_maxWidth,
m_maxHeight;
// the height of a label
int m_labelHeight;
// the space above the label
int m_labelMargin;
private:
wxDECLARE_DYNAMIC_CLASS(wxButtonToolBar);
wxDECLARE_EVENT_TABLE();
};
#endif
// _WX_BUTTONBAR_H_

View File

@@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/calctrlg.h
// Purpose: generic implementation of date-picker control
// Author: Vadim Zeitlin
// Created: 29.12.99
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_CALCTRLG_H
#define _WX_GENERIC_CALCTRLG_H
#include "wx/control.h" // the base class
#include "wx/dcclient.h" // for wxPaintDC
class WXDLLIMPEXP_FWD_CORE wxChoice;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
class WXDLLIMPEXP_FWD_CORE wxSpinEvent;
// ----------------------------------------------------------------------------
// wxGenericCalendarCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGenericCalendarCtrl : public wxCalendarCtrlBase
{
public:
// construction
wxGenericCalendarCtrl() { Init(); }
wxGenericCalendarCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS,
const wxString& name = wxASCII_STR(wxCalendarNameStr));
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS,
const wxString& name = wxASCII_STR(wxCalendarNameStr));
virtual ~wxGenericCalendarCtrl();
virtual bool Destroy() override;
// set/get the current date
// ------------------------
virtual bool SetDate(const wxDateTime& date) override;
virtual wxDateTime GetDate() const override { return m_date; }
// set/get the range in which selection can occur
// ---------------------------------------------
virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
const wxDateTime& upperdate = wxDefaultDateTime) override;
virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const override;
// these functions are for generic version only, don't use them but use the
// Set/GetDateRange() above instead
bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
const wxDateTime& GetLowerDateLimit() const { return m_lowdate; }
bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
const wxDateTime& GetUpperDateLimit() const { return m_highdate; }
// calendar mode
// -------------
// some calendar styles can't be changed after the control creation by
// just using SetWindowStyle() and Refresh() and the functions below
// should be used instead for them
// corresponds to wxCAL_NO_MONTH_CHANGE bit
virtual bool EnableMonthChange(bool enable = true) override;
// corresponds to wxCAL_NO_YEAR_CHANGE bit, deprecated, generic only
void EnableYearChange(bool enable = true);
// customization
// -------------
virtual void Mark(size_t day, bool mark) override;
// all other functions in this section are for generic version only
// header colours are used for painting the weekdays at the top
virtual void SetHeaderColours(const wxColour& colFg, const wxColour& colBg) override
{
m_colHeaderFg = colFg;
m_colHeaderBg = colBg;
}
virtual const wxColour& GetHeaderColourFg() const override { return m_colHeaderFg; }
virtual const wxColour& GetHeaderColourBg() const override { return m_colHeaderBg; }
// highlight colour is used for the currently selected date
virtual void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) override
{
m_colHighlightFg = colFg;
m_colHighlightBg = colBg;
}
virtual const wxColour& GetHighlightColourFg() const override { return m_colHighlightFg; }
virtual const wxColour& GetHighlightColourBg() const override { return m_colHighlightBg; }
// holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
virtual void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) override
{
m_colHolidayFg = colFg;
m_colHolidayBg = colBg;
}
virtual const wxColour& GetHolidayColourFg() const override { return m_colHolidayFg; }
virtual const wxColour& GetHolidayColourBg() const override { return m_colHolidayBg; }
virtual wxCalendarDateAttr *GetAttr(size_t day) const override
{
wxCHECK_MSG( day > 0 && day < 32, nullptr, wxT("invalid day") );
return m_attrs[day - 1];
}
virtual void SetAttr(size_t day, wxCalendarDateAttr *attr) override
{
wxCHECK_RET( day > 0 && day < 32, wxT("invalid day") );
delete m_attrs[day - 1];
m_attrs[day - 1] = attr;
}
virtual void ResetAttr(size_t day) override { SetAttr(day, nullptr); }
virtual void SetHoliday(size_t day) override;
virtual wxCalendarHitTestResult HitTest(const wxPoint& pos,
wxDateTime *date = nullptr,
wxDateTime::WeekDay *wd = nullptr) override;
// implementation only from now on
// -------------------------------
// forward these functions to all subcontrols
virtual bool Enable(bool enable = true) override;
virtual bool Show(bool show = true) override;
virtual void SetWindowStyleFlag(long style) override;
virtual wxVisualAttributes GetDefaultAttributes() const override
{ return GetClassDefaultAttributes(GetWindowVariant()); }
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
// override some base class virtuals
virtual wxSize DoGetBestSize() const override;
virtual void DoMoveWindow(int x, int y, int width, int height) override;
virtual void DoGetSize(int *width, int *height) const override;
private:
// common part of all ctors
void Init();
// startup colours and reinitialization after colour changes in system
void InitColours();
// event handlers
void OnPaint(wxPaintEvent& event);
void OnClick(wxMouseEvent& event);
void OnDClick(wxMouseEvent& event);
void OnWheel(wxMouseEvent& event);
void OnChar(wxKeyEvent& event);
void OnMonthChange(wxCommandEvent& event);
void HandleYearChange(wxCommandEvent& event);
void OnYearChange(wxSpinEvent& event);
void OnYearTextChange(wxCommandEvent& event);
// (re)calc m_widthCol and m_heightRow
void RecalcGeometry();
// set the date and send the notification
void SetDateAndNotify(const wxDateTime& date);
// get the week (row, in range 1..6) for the given date
size_t GetWeek(const wxDateTime& date) const;
// get the date from which we start drawing days
wxDateTime GetStartDate() const;
// get the first/last days of the week corresponding to the current style
wxDateTime::WeekDay GetWeekStart() const
{
return WeekStartsOnMonday() ? wxDateTime::Mon
: wxDateTime::Sun;
}
wxDateTime::WeekDay GetWeekEnd() const
{
return WeekStartsOnMonday() ? wxDateTime::Sun
: wxDateTime::Sat;
}
// is this date shown?
bool IsDateShown(const wxDateTime& date) const;
// is this date in the currently allowed range?
bool IsDateInRange(const wxDateTime& date) const;
// adjust the date to the currently allowed range, return true if it was
// changed
bool AdjustDateToRange(wxDateTime *date) const;
// redraw the given date
void RefreshDate(const wxDateTime& date);
// change the date inside the same month/year
void ChangeDay(const wxDateTime& date);
// deprecated
bool AllowYearChange() const
{
return !(GetWindowStyle() & wxCAL_NO_YEAR_CHANGE);
}
// show the correct controls
void ShowCurrentControls();
// create the month choice and year spin controls
void CreateMonthChoice();
void CreateYearSpinCtrl();
public:
// get the currently shown control for month/year
wxControl *GetMonthControl() const;
wxControl *GetYearControl() const;
private:
virtual void ResetHolidayAttrs() override;
virtual void RefreshHolidays() override { Refresh(); }
// OnPaint helper-methods
// Highlight the [fromdate : todate] range using pen and brush
void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pen, const wxBrush* brush);
// Get the "coordinates" for the date relative to the month currently displayed.
// using (day, week): upper left coord is (1, 1), lower right coord is (7, 6)
// if the date isn't visible (-1, -1) is put in (day, week) and false is returned
bool GetDateCoord(const wxDateTime& date, int *day, int *week) const;
// Set the flag for SetDate(): otherwise it would overwrite the year
// typed in by the user
void SetUserChangedYear() { m_userChangedYear = true; }
// the subcontrols
wxStaticText *m_staticMonth;
wxChoice *m_choiceMonth;
wxStaticText *m_staticYear;
wxSpinCtrl *m_spinYear;
// the current selection
wxDateTime m_date;
// the date-range
wxDateTime m_lowdate;
wxDateTime m_highdate;
// default attributes
wxColour m_colHighlightFg,
m_colHighlightBg,
m_colHolidayFg,
m_colHolidayBg,
m_colHeaderFg,
m_colHeaderBg,
m_colBackground,
m_colSurrounding;
// the attributes for each of the month days
wxCalendarDateAttr *m_attrs[31];
// the width and height of one column/row in the calendar
wxCoord m_widthCol,
m_heightRow,
m_rowOffset,
m_calendarWeekWidth;
wxRect m_leftArrowRect,
m_rightArrowRect;
// the week day names
wxString m_weekdays[7];
// true if SetDate() is being called as the result of changing the year in
// the year control
bool m_userChangedYear;
wxDECLARE_DYNAMIC_CLASS(wxGenericCalendarCtrl);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxGenericCalendarCtrl);
};
#endif // _WX_GENERIC_CALCTRLG_H

View File

@@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/caret.h
// Purpose: generic wxCaret class
// Author: Vadim Zeitlin (original code by Robert Roebling)
// Created: 25.05.99
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CARET_H_
#define _WX_CARET_H_
#include "wx/timer.h"
#include "wx/dc.h"
#include "wx/overlay.h"
class WXDLLIMPEXP_FWD_CORE wxCaret;
class WXDLLIMPEXP_CORE wxCaretTimer : public wxTimer
{
public:
wxCaretTimer(wxCaret *caret);
virtual void Notify() override;
private:
wxCaret *m_caret;
};
class WXDLLIMPEXP_CORE wxCaret : public wxCaretBase
{
public:
// ctors
// -----
// default - use Create()
wxCaret() : m_timer(this) { InitGeneric(); }
// creates a block caret associated with the given window
wxCaret(wxWindowBase *window, int width, int height)
: wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); }
wxCaret(wxWindowBase *window, const wxSize& size)
: wxCaretBase(window, size), m_timer(this) { InitGeneric(); }
virtual ~wxCaret();
// implementation
// --------------
// called by wxWindow (not using the event tables)
virtual void OnSetFocus() override;
virtual void OnKillFocus() override;
// called by wxCaretTimer
void OnTimer();
protected:
virtual void DoShow() override;
virtual void DoHide() override;
virtual void DoMove() override;
virtual void DoSize() override;
// blink the caret once
void Blink();
// refresh the caret
void Refresh();
// draw the caret on the given DC
void DoDraw(wxDC *dc, wxWindow* win);
private:
// GTK specific initialization
void InitGeneric();
// the overlay for displaying the caret
wxOverlay m_overlay;
// the bitmap holding the part of window hidden by the caret when it was
// at (m_xOld, m_yOld)
wxBitmap m_bmpUnderCaret;
int m_xOld,
m_yOld;
wxCaretTimer m_timer;
bool m_blinkedOut, // true => caret hidden right now
m_hasFocus; // true => our window has focus
};
#endif // _WX_CARET_H_

View File

@@ -0,0 +1,361 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/choicdgg.h
// Purpose: Generic choice dialogs
// Author: Julian Smart
// Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
// Created: 01/02/97
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_CHOICDGG_H_
#define _WX_GENERIC_CHOICDGG_H_
#include "wx/dynarray.h"
#include "wx/dialog.h"
class WXDLLIMPEXP_FWD_CORE wxListBoxBase;
// ----------------------------------------------------------------------------
// some constants
// ----------------------------------------------------------------------------
// These constants are no longer used and only remain here for compatibility.
#define wxCHOICE_HEIGHT 150
#define wxCHOICE_WIDTH 200
// Default style for choice dialogs.
#define wxCHOICEDLG_STYLE \
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
// ----------------------------------------------------------------------------
// wxAnyChoiceDialog: a base class for dialogs containing a listbox
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnyChoiceDialog : public wxDialog
{
public:
wxAnyChoiceDialog() : m_listbox(nullptr) { }
wxAnyChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
long styleDlg = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition,
long styleLbox = wxLB_ALWAYS_SB)
{
(void)Create(parent, message, caption, n, choices,
styleDlg, pos, styleLbox);
}
wxAnyChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
long styleDlg = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition,
long styleLbox = wxLB_ALWAYS_SB)
{
(void)Create(parent, message, caption, choices,
styleDlg, pos, styleLbox);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
long styleDlg = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition,
long styleLbox = wxLB_ALWAYS_SB);
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
long styleDlg = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition,
long styleLbox = wxLB_ALWAYS_SB);
protected:
wxListBoxBase *m_listbox;
virtual wxListBoxBase *CreateList(int n,
const wxString *choices,
long styleLbox);
wxDECLARE_NO_COPY_CLASS(wxAnyChoiceDialog);
};
// ----------------------------------------------------------------------------
// wxSingleChoiceDialog: a dialog with single selection listbox
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSingleChoiceDialog : public wxAnyChoiceDialog
{
public:
wxSingleChoiceDialog()
{
m_selection = -1;
}
wxSingleChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n,
const wxString *choices,
void **clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition)
{
Create(parent, message, caption, n, choices, clientData, style, pos);
}
wxSingleChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void **clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition)
{
Create(parent, message, caption, choices, clientData, style, pos);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n,
const wxString *choices,
void **clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void **clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
void SetSelection(int sel);
int GetSelection() const { return m_selection; }
wxString GetStringSelection() const { return m_stringSelection; }
void* GetSelectionData() const { return m_clientData; }
// implementation from now on
void OnOK(wxCommandEvent& event);
void OnListBoxDClick(wxCommandEvent& event);
protected:
int m_selection;
wxString m_stringSelection;
void DoChoice();
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog);
wxDECLARE_EVENT_TABLE();
};
// ----------------------------------------------------------------------------
// wxMultiChoiceDialog: a dialog with multi selection listbox
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMultiChoiceDialog : public wxAnyChoiceDialog
{
public:
wxMultiChoiceDialog() = default;
wxMultiChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n,
const wxString *choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition)
{
(void)Create(parent, message, caption, n, choices, style, pos);
}
wxMultiChoiceDialog(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition)
{
(void)Create(parent, message, caption, choices, style, pos);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
int n,
const wxString *choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
void SetSelections(const wxArrayInt& selections);
wxArrayInt GetSelections() const { return m_selections; }
// implementation from now on
virtual bool TransferDataFromWindow() override;
protected:
#if wxUSE_CHECKLISTBOX
virtual wxListBoxBase *CreateList(int n,
const wxString *choices,
long styleLbox) override;
#endif // wxUSE_CHECKLISTBOX
wxArrayInt m_selections;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog);
};
// ----------------------------------------------------------------------------
// wrapper functions which can be used to get selection(s) from the user
// ----------------------------------------------------------------------------
// get the user selection as a string
WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
int initialSelection,
wxWindow *parent = nullptr);
WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
int initialSelection,
wxWindow *parent = nullptr);
// Same as above but gets position in list of strings, instead of string,
// or -1 if no selection
WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
int initialSelection,
wxWindow *parent = nullptr);
WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
int initialSelection,
wxWindow *parent = nullptr);
// Return client data instead or nullptr if canceled
WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void **client_data,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
void **client_data,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void **client_data,
int initialSelection,
wxWindow *parent = nullptr);
WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
void **client_data,
int initialSelection,
wxWindow *parent = nullptr);
// fill the array with the indices of the chosen items, it will be empty
// if no items were selected or Cancel was pressed - return the number of
// selections or -1 if cancelled
WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
wxWindow *parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
#endif // _WX_GENERIC_CHOICDGG_H_

View File

@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/clrpickerg.h
// Purpose: wxGenericColourButton header
// Author: Francesco Montorsi (based on Vadim Zeitlin's code)
// Created: 14/4/2006
// Copyright: (c) Vadim Zeitlin, Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLRPICKER_H_
#define _WX_CLRPICKER_H_
#include "wx/button.h"
#include "wx/bmpbuttn.h"
#include "wx/colourdata.h"
class wxColourDialogEvent;
//-----------------------------------------------------------------------------
// wxGenericColourButton: a button which brings up a wxColourDialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericColourButton : public wxBitmapButton,
public wxColourPickerWidgetBase
{
public:
wxGenericColourButton() = default;
wxGenericColourButton(wxWindow *parent,
wxWindowID id,
const wxColour& col = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxColourPickerWidgetNameStr))
{
Create(parent, id, col, pos, size, style, validator, name);
}
virtual ~wxGenericColourButton() = default;
public: // API extensions specific for wxGenericColourButton
// user can override this to init colour data in a different way
virtual void InitColourData();
// returns the colour data shown in wxColourDialog
wxColourData *GetColourData() { return &ms_data; }
public:
bool Create(wxWindow *parent,
wxWindowID id,
const wxColour& col = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxColourPickerWidgetNameStr));
void OnButtonClick(wxCommandEvent &);
protected:
wxBitmap m_bitmap;
wxSize DoGetBestSize() const override;
void UpdateColour() override;
void OnDPIChanged(wxDPIChangedEvent& event);
// the colour data shown in wxColourPickerCtrlGeneric
// controls. This member is static so that all colour pickers
// in the program share the same set of custom colours.
static wxColourData ms_data;
private:
void OnColourChanged(wxColourDialogEvent& event);
wxDECLARE_DYNAMIC_CLASS(wxGenericColourButton);
};
#endif // _WX_CLRPICKER_H_

View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/collheaderctrl.h
// Purpose: wxGenericCollapsibleHeaderCtrl
// Author: Tobias Taschner
// Created: 2015-09-19
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_
#define _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_
class WXDLLIMPEXP_CORE wxGenericCollapsibleHeaderCtrl
: public wxCollapsibleHeaderCtrlBase
{
public:
wxGenericCollapsibleHeaderCtrl() { Init(); }
wxGenericCollapsibleHeaderCtrl(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsibleHeaderCtrlNameStr))
{
Init();
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsibleHeaderCtrlNameStr));
virtual void SetCollapsed(bool collapsed = true) override;
virtual bool IsCollapsed() const override
{ return m_collapsed; }
virtual bool HasTransparentBackground() override { return true; }
protected:
virtual wxSize DoGetBestClientSize() const override;
private:
bool m_collapsed;
bool m_inWindow;
bool m_mouseDown;
void Init();
void OnPaint(wxPaintEvent& event);
// Handle set/kill focus events (invalidate for painting focus rect)
void OnFocus(wxFocusEvent& event);
// Handle click
void OnLeftUp(wxMouseEvent& event);
// Handle pressed state
void OnLeftDown(wxMouseEvent& event);
// Handle current state
void OnEnterWindow(wxMouseEvent& event);
void OnLeaveWindow(wxMouseEvent& event);
// Toggle on space
void OnChar(wxKeyEvent& event);
void DoSetCollapsed(bool collapsed);
wxDECLARE_NO_COPY_CLASS(wxGenericCollapsibleHeaderCtrl);
};
#endif // _WX_GENERIC_COLLAPSIBLEHEADER_CTRL_H_

View File

@@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/collpaneg.h
// Purpose: wxGenericCollapsiblePane
// Author: Francesco Montorsi
// Created: 8/10/2006
// Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLLAPSABLE_PANE_H_GENERIC_
#define _WX_COLLAPSABLE_PANE_H_GENERIC_
// forward declared
class WXDLLIMPEXP_FWD_CORE wxCollapsibleHeaderCtrl;
#include "wx/containr.h"
// ----------------------------------------------------------------------------
// wxGenericCollapsiblePane
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericCollapsiblePane :
public wxNavigationEnabled<wxCollapsiblePaneBase>
{
public:
wxGenericCollapsiblePane() { Init(); }
wxGenericCollapsiblePane(wxWindow *parent,
wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsiblePaneNameStr))
{
Init();
Create(parent, winid, label, pos, size, style, val, name);
}
virtual ~wxGenericCollapsiblePane();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsiblePaneNameStr));
// public wxCollapsiblePane API
virtual void Collapse(bool collapse = true) override;
virtual void SetLabel(const wxString &label) override;
virtual bool IsCollapsed() const override
{ return m_pPane==nullptr || !m_pPane->IsShown(); }
virtual wxWindow *GetPane() const override
{ return m_pPane; }
virtual wxString GetLabel() const override;
virtual bool Layout() override;
// for the generic collapsible pane only:
wxControl* GetControlWidget() const
{ return (wxControl*)m_pButton; }
// implementation only, don't use
void OnStateChange(const wxSize& sizeNew);
protected:
// overridden methods
virtual wxSize DoGetBestClientSize() const override;
int GetBorder() const;
// child controls
wxCollapsibleHeaderCtrl *m_pButton;
wxWindow *m_pPane;
wxSizer *m_sz;
private:
void Init();
// event handlers
void OnButton(wxCommandEvent &ev);
void OnSize(wxSizeEvent &ev);
wxDECLARE_DYNAMIC_CLASS(wxGenericCollapsiblePane);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_COLLAPSABLE_PANE_H_GENERIC_

View File

@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/colour.h
// Purpose: wxColour class
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_COLOUR_H_
#define _WX_GENERIC_COLOUR_H_
#include "wx/object.h"
// Colour
class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour: public wxColourBase
{
public:
// constructors
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// copy ctors and assignment operators
wxColour(const wxColour& col)
{
*this = col;
}
wxColour& operator=(const wxColour& col);
// accessors
virtual bool IsOk() const { return m_isInit; }
unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; }
unsigned char Alpha() const { return m_alpha; }
// comparison
bool operator==(const wxColour& colour) const
{
return (m_red == colour.m_red &&
m_green == colour.m_green &&
m_blue == colour.m_blue &&
m_alpha == colour.m_alpha &&
m_isInit == colour.m_isInit);
}
bool operator!=(const wxColour& colour) const { return !(*this == colour); }
protected:
// Helper function
void Init();
virtual void
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
private:
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
unsigned char m_alpha;
private:
wxDECLARE_DYNAMIC_CLASS(wxColour);
};
#endif // _WX_GENERIC_COLOUR_H_

View File

@@ -0,0 +1,132 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/colrdlgg.h
// Purpose: wxGenericColourDialog
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLORDLGG_H_
#define _WX_COLORDLGG_H_
#include "wx/gdicmn.h"
#include "wx/dialog.h"
#if wxUSE_SLIDER
class WXDLLIMPEXP_FWD_CORE wxSlider;
#endif // wxUSE_SLIDER
// Preview with opacity is possible only if wxGCDC and wxStaticBitmap are
// available and currently it only works in wxOSX and wxMSW as it uses wxBitmap
// UseAlpha() and HasAlpha() methods which only these ports provide.
#if ((wxUSE_GRAPHICS_CONTEXT && wxUSE_STATBMP) && \
(defined(__WXMSW__) || defined(__WXOSX__)))
#define wxCLRDLGG_USE_PREVIEW_WITH_ALPHA 1
#else
#define wxCLRDLGG_USE_PREVIEW_WITH_ALPHA 0
#endif
#if wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
class wxStaticBitmap;
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
class WXDLLIMPEXP_CORE wxGenericColourDialog : public wxDialog
{
public:
wxGenericColourDialog();
wxGenericColourDialog(wxWindow *parent,
const wxColourData *data = nullptr);
virtual ~wxGenericColourDialog();
bool Create(wxWindow *parent, const wxColourData *data = nullptr);
wxColourData &GetColourData() { return m_colourData; }
virtual int ShowModal() override;
// Internal functions
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
void OnDPIChanged(wxDPIChangedEvent& 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);
#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);
virtual void OnBasicColourClick(int which);
virtual void OnCustomColourClick(int which);
void OnAddCustom(wxCommandEvent& event);
#if wxUSE_SLIDER
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
virtual void CreateCustomBitmaps();
void DoPreviewBitmap(wxBitmap& bmp, const wxColour& colour);
#endif // wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
protected:
wxColourData m_colourData;
// Area reserved for grids of colours
wxRect m_standardColoursRect;
wxRect m_customColoursRect;
wxRect m_singleCustomColourRect;
// Size of each colour rectangle
wxSize m_smallRectangleSize;
// Grid spacing (between rectangles)
int m_gridSpacing;
// Section spacing (between left and right halves of dialog box)
int m_sectionSpacing;
// 48 'standard' colours
wxColour m_standardColours[48];
// 16 'custom' colours
wxColour m_customColours[16];
// Which colour is selected? An index into one of the two areas.
int m_colourSelection;
int m_whichKind; // 1 for standard colours, 2 for custom colours,
#if wxUSE_SLIDER
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
// static bool colourDialogCancelled;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericColourDialog);
};
#endif // _WX_COLORDLGG_H_

View File

@@ -0,0 +1,153 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/combo.h
// Purpose: Generic wxComboCtrl
// Author: Jaakko Salli
// Created: Apr-30-2006
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_COMBOCTRL_H_
#define _WX_GENERIC_COMBOCTRL_H_
#if wxUSE_COMBOCTRL
// Only define generic if native doesn't have all the features
#if !defined(wxCOMBOCONTROL_FULLY_FEATURED)
#include "wx/containr.h"
// ----------------------------------------------------------------------------
// Generic wxComboCtrl
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
// all actions of single line text controls are supported
// popup/dismiss the choice window
#define wxACTION_COMBOBOX_POPUP wxT("popup")
#define wxACTION_COMBOBOX_DISMISS wxT("dismiss")
#endif
extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
class WXDLLIMPEXP_CORE wxGenericComboCtrl
: public wxNavigationEnabled<wxComboCtrlBase>
{
public:
// ctors and such
wxGenericComboCtrl() { Init(); }
wxGenericComboCtrl(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr))
{
Init();
(void)Create(parent, id, value, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr));
virtual ~wxGenericComboCtrl();
void SetCustomPaintWidth( int width );
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const override;
static int GetFeatures() { return wxComboCtrlFeatures::All; }
#if defined(__WXUNIVERSAL__)
// we have our own input handler and our own actions
virtual bool PerformAction(const wxControlAction& action,
long numArg = 0l,
const wxString& strArg = wxEmptyString);
#endif
protected:
// Dummies for platform-specific wxTextEntry implementations
#if defined(__WXUNIVERSAL__)
// Looks like there's nothing we need to override here
#elif defined(__WXGTK__)
virtual GtkEditable *GetEditable() const override { return nullptr; }
virtual GtkEntry *GetEntry() const override { return nullptr; }
#elif defined(__WXOSX__)
virtual wxTextWidgetImpl * GetTextPeer() const override;
#endif
// For better transparent background rendering
virtual bool HasTransparentBackground() override;
// Mandatory virtuals
virtual void OnResize() override;
// Event handlers
void OnPaintEvent( wxPaintEvent& event );
void OnMouseEvent( wxMouseEvent& event );
private:
void Init();
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericComboCtrl);
};
#ifndef _WX_COMBOCONTROL_H_
// If native wxComboCtrl was not defined, then prepare a simple
// front-end so that wxRTTI works as expected.
class WXDLLIMPEXP_CORE wxComboCtrl : public wxGenericComboCtrl
{
public:
wxComboCtrl() : wxGenericComboCtrl() {}
wxComboCtrl(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr))
: wxGenericComboCtrl()
{
(void)Create(parent, id, value, pos, size, style, validator, name);
}
virtual ~wxComboCtrl() = default;
protected:
private:
wxDECLARE_DYNAMIC_CLASS(wxComboCtrl);
};
#endif // _WX_COMBOCONTROL_H_
#else
#define wxGenericComboCtrl wxComboCtrl
#endif // !defined(wxCOMBOCONTROL_FULLY_FEATURED)
#endif // wxUSE_COMBOCTRL
#endif
// _WX_GENERIC_COMBOCTRL_H_

View File

@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/creddlgg.h
// Purpose: wxGenericCredentialEntryDialog interface
// Author: Tobias Taschner
// Created: 2018-10-23
// Copyright: (c) 2018 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CREDDLGG_H_BASE
#define _WX_CREDDLGG_H_BASE
#include "wx/defs.h"
#if wxUSE_CREDENTIALDLG
#include "wx/dialog.h"
#include "wx/webrequest.h"
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_CORE wxGenericCredentialEntryDialog : public wxDialog
{
public:
wxGenericCredentialEntryDialog();
wxGenericCredentialEntryDialog(wxWindow* parent, const wxString& message,
const wxString& title,
const wxWebCredentials& cred = wxWebCredentials());
bool Create(wxWindow* parent, const wxString& message,
const wxString& title,
const wxWebCredentials& cred = wxWebCredentials());
void SetUser(const wxString& user);
void SetPassword(const wxString& password);
wxWebCredentials GetCredentials() const;
private:
wxTextCtrl* m_userTextCtrl;
wxTextCtrl* m_passwordTextCtrl;
void Init(const wxString& message, const wxWebCredentials& cred);
wxDECLARE_NO_COPY_CLASS(wxGenericCredentialEntryDialog);
};
// Add this typedef as long as the generic version is the only one available
typedef wxGenericCredentialEntryDialog wxCredentialEntryDialog;
#endif // wxUSE_CREDENTIALDLG
#endif // _WX_CREDDLGG_H_BASE

View File

@@ -0,0 +1,122 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/ctrlsub.h
// Purpose: common functionality of wxItemContainer-derived controls
// Author: Vadim Zeitlin
// Created: 2007-07-25
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_CTRLSUB_H_
#define _WX_GENERIC_CTRLSUB_H_
#include "wx/dynarray.h"
// ----------------------------------------------------------------------------
// wxControlWithItemsGeneric: generic implementation of item client data
// ----------------------------------------------------------------------------
class wxControlWithItemsGeneric : public wxControlWithItemsBase
{
public:
wxControlWithItemsGeneric() = default;
virtual void DoInitItemClientData()
{
m_itemsClientData.resize(GetCount(), nullptr);
}
virtual void DoSetItemClientData(unsigned int n, void *clientData)
{
m_itemsClientData[n] = clientData;
}
virtual void *DoGetItemClientData(unsigned int n) const
{
return m_itemsClientData[n];
}
virtual void DoClear() { m_itemsClientData.clear(); }
virtual void DoDeleteOneItem(unsigned int pos)
{
if ( HasClientData() )
m_itemsClientData.RemoveAt(pos);
}
protected:
// preallocate memory for numItems new items: this should be called from
// the derived classes DoInsertItems() to speed up appending big numbers of
// items with client data; it is safe to call even if we don't use client
// data at all and does nothing in this case
void AllocClientData(unsigned int numItems)
{
if ( HasClientData() )
m_itemsClientData.reserve(m_itemsClientData.size() + numItems);
}
// this must be called by derived classes when a new item is added to the
// control to add storage for the corresponding client data pointer (before
// inserting many items, call AllocClientData())
void InsertNewItemClientData(unsigned int pos,
void **clientData,
unsigned int n,
wxClientDataType type)
{
if ( InitClientDataIfNeeded(type) )
m_itemsClientData.Insert(clientData[n], pos);
}
// the same as InsertNewItemClientData() but for numItems consecutive items
// (this can only be used if the control doesn't support sorting as
// otherwise the items positions wouldn't be consecutive any more)
void InsertNewItemsClientData(unsigned int pos,
unsigned int numItems,
void **clientData,
wxClientDataType type)
{
if ( InitClientDataIfNeeded(type) )
{
// it's more efficient to insert everything at once and then update
// for big number of items to avoid moving the array contents
// around (which would result in O(N^2) algorithm)
m_itemsClientData.Insert(nullptr, pos, numItems);
for ( unsigned int n = 0; n < numItems; ++n, ++pos )
m_itemsClientData[pos] = clientData[n];
}
}
// vector containing the client data pointers: it is either empty (if
// client data is not used) or has the same number of elements as the
// control
wxArrayPtrVoid m_itemsClientData;
private:
// initialize client data if needed, return false if we don't have any
// client data and true otherwise
bool InitClientDataIfNeeded(wxClientDataType type)
{
if ( !HasClientData() )
{
if ( type == wxClientData_None )
{
// we didn't have the client data before and are not asked to
// store it now either
return false;
}
// this is the first time client data is used with this control
DoInitItemClientData();
SetClientDataType(type);
}
//else: we already have client data
return true;
}
wxDECLARE_NO_COPY_CLASS(wxControlWithItemsGeneric);
};
#endif // _WX_GENERIC_CTRLSUB_H_

View File

@@ -0,0 +1,98 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/custombgwin.h
// Purpose: Generic implementation of wxCustomBackgroundWindow.
// Author: Vadim Zeitlin
// Created: 2011-10-10
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_CUSTOMBGWIN_H_
#define _WX_GENERIC_CUSTOMBGWIN_H_
#include "wx/bitmap.h"
#include "wx/dc.h"
#include "wx/event.h"
#include "wx/window.h"
// A helper to avoid template bloat: this class contains all type-independent
// code of wxCustomBackgroundWindow<> below.
class wxCustomBackgroundWindowGenericBase : public wxCustomBackgroundWindowBase
{
public:
wxCustomBackgroundWindowGenericBase() = default;
protected:
void DoEraseBackground(wxEraseEvent& event, wxWindow* win)
{
wxDC& dc = *event.GetDC();
const wxSize clientSize = win->GetClientSize();
const wxSize bitmapSize = m_bitmapBg.GetSize();
for ( int x = 0; x < clientSize.x; x += bitmapSize.x )
{
for ( int y = 0; y < clientSize.y; y += bitmapSize.y )
{
dc.DrawBitmap(m_bitmapBg, x, y);
}
}
}
// The bitmap used for painting the background if valid.
wxBitmap m_bitmapBg;
wxDECLARE_NO_COPY_CLASS(wxCustomBackgroundWindowGenericBase);
};
// ----------------------------------------------------------------------------
// wxCustomBackgroundWindow
// ----------------------------------------------------------------------------
template <class W>
class wxCustomBackgroundWindow : public W,
public wxCustomBackgroundWindowGenericBase
{
public:
typedef W BaseWindowClass;
wxCustomBackgroundWindow() = default;
protected:
virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) override
{
m_bitmapBg = bmp;
if ( m_bitmapBg.IsOk() )
{
BaseWindowClass::Bind
(
wxEVT_ERASE_BACKGROUND,
&wxCustomBackgroundWindow::OnEraseBackground, this
);
}
else
{
BaseWindowClass::Unbind
(
wxEVT_ERASE_BACKGROUND,
&wxCustomBackgroundWindow::OnEraseBackground, this
);
}
}
private:
// Event handler for erasing the background which is only used when we have
// a valid background bitmap.
void OnEraseBackground(wxEraseEvent& event)
{
DoEraseBackground(event, this);
}
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCustomBackgroundWindow, W);
};
#endif // _WX_GENERIC_CUSTOMBGWIN_H_

View File

@@ -0,0 +1,482 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dataview.h
// Purpose: wxDataViewCtrl generic implementation header
// Author: Robert Roebling
// Modified By: Bo Yang
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GENERICDATAVIEWCTRLH__
#define __GENERICDATAVIEWCTRLH__
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/compositewin.h"
#include "wx/control.h"
#include "wx/scrolwin.h"
#include "wx/icon.h"
#include "wx/vector.h"
#if wxUSE_ACCESSIBILITY
#include "wx/access.h"
#endif // wxUSE_ACCESSIBILITY
class WXDLLIMPEXP_FWD_CORE wxDataViewMainWindow;
class WXDLLIMPEXP_FWD_CORE wxDataViewHeaderWindow;
#if wxUSE_ACCESSIBILITY
class WXDLLIMPEXP_FWD_CORE wxDataViewCtrlAccessible;
#endif // wxUSE_ACCESSIBILITY
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewColumn : public wxDataViewColumnBase
{
public:
wxDataViewColumn(const wxString& title,
wxDataViewRenderer *renderer,
unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE)
: wxDataViewColumnBase(renderer, model_column),
m_title(title)
{
Init(width, align, flags);
}
wxDataViewColumn(const wxBitmapBundle& bitmap,
wxDataViewRenderer *renderer,
unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE)
: wxDataViewColumnBase(bitmap, renderer, model_column)
{
Init(width, align, flags);
}
// implement wxHeaderColumnBase methods
virtual void SetTitle(const wxString& title) override
{
m_title = title;
UpdateWidth();
}
virtual wxString GetTitle() const override
{
return m_title;
}
virtual void SetWidth(int width) override
{
// Call the actual update method, used for both automatic and "manual"
// width changes.
WXUpdateWidth(width);
// Do remember the last explicitly set width: this is used to prevent
// UpdateColumnSizes() from resizing the last column to be smaller than
// this size.
m_manuallySetWidth = width;
}
virtual int GetWidth() const override;
virtual void SetMinWidth(int minWidth) override
{
m_minWidth = minWidth;
UpdateWidth();
}
virtual int GetMinWidth() const override
{
return m_minWidth;
}
virtual void SetAlignment(wxAlignment align) override
{
m_align = align;
UpdateDisplay();
}
virtual wxAlignment GetAlignment() const override
{
return m_align;
}
virtual void SetFlags(int flags) override
{
m_flags = flags;
UpdateDisplay();
}
virtual int GetFlags() const override
{
return m_flags;
}
virtual bool IsSortKey() const override
{
return m_sort;
}
virtual void UnsetAsSortKey() override;
virtual void SetSortOrder(bool ascending) override;
virtual bool IsSortOrderAscending() const override
{
return m_sortAscending;
}
virtual void SetBitmap( const wxBitmapBundle& bitmap ) override
{
wxDataViewColumnBase::SetBitmap(bitmap);
UpdateWidth();
}
// This method is specific to the generic implementation and is used only
// by wxWidgets itself.
void WXUpdateWidth(int width)
{
if ( width == m_width )
return;
m_width = width;
UpdateWidth();
}
// This method is also internal and called when the column is resized by
// user interactively.
void WXOnResize(int width);
virtual int WXGetSpecifiedWidth() const override;
private:
// common part of all ctors
void Init(int width, wxAlignment align, int flags);
// These methods forward to wxDataViewCtrl::OnColumnChange() and
// OnColumnWidthChange() respectively, i.e. the latter is stronger than the
// former.
void UpdateDisplay();
void UpdateWidth();
// Return the effective value corresponding to the given width, handling
// its negative values such as wxCOL_WIDTH_DEFAULT.
int DoGetEffectiveWidth(int width) const;
wxString m_title;
int m_width,
m_manuallySetWidth,
m_minWidth;
wxAlignment m_align;
int m_flags;
bool m_sort,
m_sortAscending;
friend class wxDataViewHeaderWindowBase;
friend class wxDataViewHeaderWindow;
friend class wxDataViewHeaderWindowMSW;
};
// ---------------------------------------------------------
// wxDataViewCtrl
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxCompositeWindow<wxDataViewCtrlBase>,
public wxScrollHelper
{
friend class wxDataViewMainWindow;
friend class wxDataViewHeaderWindowBase;
friend class wxDataViewHeaderWindow;
friend class wxDataViewHeaderWindowMSW;
friend class wxDataViewColumn;
#if wxUSE_ACCESSIBILITY
friend class wxDataViewCtrlAccessible;
#endif // wxUSE_ACCESSIBILITY
typedef wxCompositeWindow<wxDataViewCtrlBase> BaseType;
public:
wxDataViewCtrl() : wxScrollHelper(this)
{
Init();
}
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxDataViewCtrlNameStr) )
: wxScrollHelper(this)
{
Create(parent, id, pos, size, style, validator, name);
}
virtual ~wxDataViewCtrl();
void Init();
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxDataViewCtrlNameStr));
virtual bool AssociateModel( wxDataViewModel *model ) override;
virtual bool AppendColumn( wxDataViewColumn *col ) override;
virtual bool PrependColumn( wxDataViewColumn *col ) override;
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ) override;
virtual void DoSetExpanderColumn() override;
virtual void DoSetIndent() override;
virtual unsigned int GetColumnCount() const override;
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const override;
virtual bool DeleteColumn( wxDataViewColumn *column ) override;
virtual bool ClearColumns() override;
virtual int GetColumnPosition( const wxDataViewColumn *column ) const override;
virtual wxDataViewColumn *GetSortingColumn() const override;
virtual wxVector<wxDataViewColumn *> GetSortingColumns() const override;
virtual wxDataViewItem GetTopItem() const override;
virtual int GetCountPerPage() const override;
virtual int GetSelectedItemsCount() const override;
virtual int GetSelections( wxDataViewItemArray & sel ) const override;
virtual void SetSelections( const wxDataViewItemArray & sel ) override;
virtual void Select( const wxDataViewItem & item ) override;
virtual void Unselect( const wxDataViewItem & item ) override;
virtual bool IsSelected( const wxDataViewItem & item ) const override;
virtual void SelectAll() override;
virtual void UnselectAll() override;
virtual void EnsureVisible( const wxDataViewItem & item,
const wxDataViewColumn *column = nullptr ) override;
virtual void HitTest( const wxPoint & point, wxDataViewItem & item,
wxDataViewColumn* &column ) const override;
virtual wxRect GetItemRect( const wxDataViewItem & item,
const wxDataViewColumn *column = nullptr ) const override;
virtual bool SetRowHeight( int rowHeight ) override;
virtual void Collapse( const wxDataViewItem & item ) override;
virtual bool IsExpanded( const wxDataViewItem & item ) const override;
virtual void SetFocus() override;
virtual bool SetFont(const wxFont & font) override;
virtual bool SetForegroundColour(const wxColour& colour) override;
virtual bool SetBackgroundColour(const wxColour& colour) override;
#if wxUSE_ACCESSIBILITY
virtual bool Show(bool show = true) override;
virtual void SetName(const wxString &name) override;
virtual bool Reparent(wxWindowBase *newParent) override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Enable(bool enable = true) override;
virtual bool AllowMultiColumnSort(bool allow) override;
virtual bool IsMultiColumnSortAllowed() const override { return m_allowMultiColumnSort; }
virtual void ToggleSortByColumn(int column) override;
#if wxUSE_DRAG_AND_DROP
virtual bool EnableDragSource( const wxDataFormat &format ) override;
virtual bool DoEnableDropTarget(const wxVector<wxDataFormat>& formats) override;
#endif // wxUSE_DRAG_AND_DROP
virtual wxBorder GetDefaultBorder() const override;
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) override;
virtual bool SetHeaderAttr(const wxItemAttr& attr) override;
virtual bool SetAlternateRowColour(const wxColour& colour) override;
// This method is specific to generic wxDataViewCtrl implementation and
// should not be used in portable code.
wxColour GetAlternateRowColour() const { return m_alternateRowColour; }
// The returned pointer is null if the control has wxDV_NO_HEADER style.
//
// This method is only available in the generic versions.
wxHeaderCtrl* GenericGetHeader() const;
protected:
void EnsureVisibleRowCol( int row, int column );
// Notice that row here may be invalid (i.e. >= GetRowCount()), this is not
// an error and this function simply returns an invalid item in this case.
wxDataViewItem GetItemByRow( unsigned int row ) const;
int GetRowByItem( const wxDataViewItem & item ) const;
// Mark the column as being used or not for sorting.
void UseColumnForSorting(int idx);
void DontUseColumnForSorting(int idx);
// Return true if the given column is sorted
bool IsColumnSorted(int idx) const;
// Reset all columns currently used for sorting.
void ResetAllSortColumns();
virtual void DoEnableSystemTheme(bool enable, wxWindow* window) override;
void OnDPIChanged(wxDPIChangedEvent& event);
public: // utility functions not part of the API
// returns the "best" width for the idx-th column
unsigned int GetBestColumnWidth(int idx) const;
// called by header window after reorder
void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos );
// update the display after a change to an individual column
void OnColumnChange(unsigned int idx);
// update after the column width changes due to interactive resizing
void OnColumnResized();
// update after the column width changes because of e.g. title or bitmap
// change, invalidates the column best width and calls OnColumnChange()
void OnColumnWidthChange(unsigned int idx);
// update after a change to the number of columns
void OnColumnsCountChanged();
wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; }
// return the index of the given column in m_cols
int GetColumnIndex(const wxDataViewColumn *column) const;
// Return the index of the column having the given model index.
int GetModelColumnIndex(unsigned int model_column) const;
// return the column displayed at the given position in the control
wxDataViewColumn *GetColumnAt(unsigned int pos) const;
virtual wxDataViewColumn *GetCurrentColumn() const override;
virtual void OnInternalIdle() override;
#if wxUSE_ACCESSIBILITY
virtual wxAccessible* CreateAccessible() override;
#endif // wxUSE_ACCESSIBILITY
private:
// Implement pure virtual method inherited from wxCompositeWindow.
virtual wxWindowList GetCompositeWindowParts() const override;
virtual wxDataViewItem DoGetCurrentItem() const override;
virtual void DoSetCurrentItem(const wxDataViewItem& item) override;
virtual void DoExpand(const wxDataViewItem& item, bool expandChildren) override;
void InvalidateColBestWidths();
void InvalidateColBestWidth(int idx);
void UpdateColWidths();
void DoClearColumns();
wxVector<wxDataViewColumn*> m_cols;
// cached column best widths information, values are for
// respective columns from m_cols and the arrays have same size
struct CachedColWidthInfo
{
CachedColWidthInfo() : width(0), dirty(true) {}
int width; // cached width or 0 if not computed
bool dirty; // column was invalidated, header needs updating
};
wxVector<CachedColWidthInfo> m_colsBestWidths;
// This indicates that at least one entry in m_colsBestWidths has 'dirty'
// flag set. It's cheaper to check one flag in OnInternalIdle() than to
// iterate over m_colsBestWidths to check if anything needs to be done.
bool m_colsDirty;
wxDataViewModelNotifier *m_notifier;
wxDataViewMainWindow *m_clientArea;
wxDataViewHeaderWindow *m_headerArea;
// user defined color to draw row lines, may be invalid
wxColour m_alternateRowColour;
// columns indices used for sorting, empty if nothing is sorted
wxVector<int> m_sortingColumnIdxs;
// if true, allow sorting by more than one column
bool m_allowMultiColumnSort;
private:
void OnSize( wxSizeEvent &event );
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size) override;
// we need to return a special WM_GETDLGCODE value to process just the
// arrows but let the other navigation characters through
#ifdef __WXMSW__
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
#endif // __WXMSW__
WX_FORWARD_TO_SCROLL_HELPER()
private:
wxDECLARE_DYNAMIC_CLASS(wxDataViewCtrl);
wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
wxDECLARE_EVENT_TABLE();
};
#if wxUSE_ACCESSIBILITY
//-----------------------------------------------------------------------------
// wxDataViewCtrlAccessible
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCtrlAccessible: public wxWindowAccessible
{
public:
wxDataViewCtrlAccessible(wxDataViewCtrl* win);
virtual ~wxDataViewCtrlAccessible() = default;
virtual wxAccStatus HitTest(const wxPoint& pt, int* childId,
wxAccessible** childObject) override;
virtual wxAccStatus GetLocation(wxRect& rect, int elementId) override;
virtual wxAccStatus Navigate(wxNavDir navDir, int fromId,
int* toId, wxAccessible** toObject) override;
virtual wxAccStatus GetName(int childId, wxString* name) override;
virtual wxAccStatus GetChildCount(int* childCount) override;
virtual wxAccStatus GetChild(int childId, wxAccessible** child) override;
// wxWindowAccessible::GetParent() implementation is enough.
// virtual wxAccStatus GetParent(wxAccessible** parent) override;
virtual wxAccStatus DoDefaultAction(int childId) override;
virtual wxAccStatus GetDefaultAction(int childId, wxString* actionName) override;
virtual wxAccStatus GetDescription(int childId, wxString* description) override;
virtual wxAccStatus GetHelpText(int childId, wxString* helpText) override;
virtual wxAccStatus GetKeyboardShortcut(int childId, wxString* shortcut) override;
virtual wxAccStatus GetRole(int childId, wxAccRole* role) override;
virtual wxAccStatus GetState(int childId, long* state) override;
virtual wxAccStatus GetValue(int childId, wxString* strValue) override;
virtual wxAccStatus Select(int childId, wxAccSelectionFlags selectFlags) override;
virtual wxAccStatus GetFocus(int* childId, wxAccessible** child) override;
virtual wxAccStatus GetSelections(wxVariant* selections) override;
};
#endif // wxUSE_ACCESSIBILITY
#endif // __GENERICDATAVIEWCTRLH__

View File

@@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/datectrl.h
// Purpose: generic wxDatePickerCtrl implementation
// Author: Andreas Pflug
// Created: 2005-01-19
// Copyright: (c) 2005 Andreas Pflug <pgadmin@pse-consulting.de>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DATECTRL_H_
#define _WX_GENERIC_DATECTRL_H_
#include "wx/compositewin.h"
#include "wx/containr.h"
class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
class WXDLLIMPEXP_FWD_CORE wxCalendarCtrl;
class WXDLLIMPEXP_FWD_CORE wxCalendarComboPopup;
typedef wxDatePickerCtrlCommonBase<wxDateTimePickerCtrlBase> wxDatePickerCtrlGenericBase;
class WXDLLIMPEXP_CORE wxDatePickerCtrlGeneric
: public wxCompositeWindow< wxNavigationEnabled<wxDatePickerCtrlGenericBase> >
{
public:
// creating the control
wxDatePickerCtrlGeneric() { Init(); }
virtual ~wxDatePickerCtrlGeneric();
wxDatePickerCtrlGeneric(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr)
{
Init();
(void)Create(parent, id, date, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr);
// wxDatePickerCtrl methods
void SetValue(const wxDateTime& date) override;
wxDateTime GetValue() const override;
bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const override;
void SetRange(const wxDateTime &dt1, const wxDateTime &dt2) override;
bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
const wxDateTime& upperdate = wxDefaultDateTime);
// extra methods available only in this (generic) implementation
wxCalendarCtrl *GetCalendar() const;
// implementation only from now on
// -------------------------------
// overridden base class methods
virtual bool Destroy() override;
protected:
virtual wxSize DoGetBestSize() const override;
private:
void Init();
// return the list of the windows composing this one
virtual wxWindowList GetCompositeWindowParts() const override;
void OnText(wxCommandEvent &event);
void OnSize(wxSizeEvent& event);
wxComboCtrl* m_combo;
wxCalendarComboPopup* m_popup;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxDatePickerCtrlGeneric);
};
#endif // _WX_GENERIC_DATECTRL_H_

View File

@@ -0,0 +1,173 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dcpsg.h
// Purpose: wxPostScriptDC class
// Author: Julian Smart and others
// Copyright: (c) Julian Smart and Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCPSG_H_
#define _WX_DCPSG_H_
#include "wx/defs.h"
#if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
#include "wx/dc.h"
#include "wx/dcprint.h"
#include "wx/dialog.h"
#include "wx/module.h"
#include "wx/cmndata.h"
#include "wx/strvararg.h"
//-----------------------------------------------------------------------------
// wxPostScriptDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPostScriptDC : public wxDC
{
public:
wxPostScriptDC();
// Recommended constructor
wxPostScriptDC(const wxPrintData& printData);
private:
wxDECLARE_DYNAMIC_CLASS(wxPostScriptDC);
};
class WXDLLIMPEXP_CORE wxPostScriptDCImpl : public wxDCImpl
{
public:
wxPostScriptDCImpl( wxPrinterDC *owner );
wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data );
wxPostScriptDCImpl( wxPostScriptDC *owner );
wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data );
void Init();
virtual ~wxPostScriptDCImpl();
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const override;
bool CanDrawBitmap() const override { return true; }
void Clear() override;
void SetFont( const wxFont& font ) override;
void SetPen( const wxPen& pen ) override;
void SetBrush( const wxBrush& brush ) override;
void SetLogicalFunction( wxRasterOperationMode function ) override;
void SetBackground( const wxBrush& brush ) override;
void DestroyClippingRegion() override;
bool StartDoc(const wxString& message) override;
void EndDoc() override;
void StartPage() override;
void EndPage() override;
wxCoord GetCharHeight() const override;
wxCoord GetCharWidth() const override;
bool CanGetTextExtent() const override { return true; }
// Resolution in pixels per logical inch
wxSize GetPPI() const override;
virtual wxSize FromDIP(const wxSize& sz) const override;
virtual wxSize ToDIP(const wxSize& sz) const override;
virtual void ComputeScaleAndOrigin() override;
void SetBackgroundMode(int WXUNUSED(mode)) override { }
#if wxUSE_PALETTE
void SetPalette(const wxPalette& WXUNUSED(palette)) override { }
#endif
void SetPrintData(const wxPrintData& data);
wxPrintData& GetPrintData() { return m_printData; }
virtual int GetDepth() const override { return 24; }
void PsPrint( const wxString& psdata );
// Overridden for wxPrinterDC Impl
virtual int GetResolution() const override;
virtual wxRect GetPaperRect() const override;
virtual void* GetHandle() const override { return nullptr; }
protected:
bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col,
wxFloodFillStyle style = wxFLOOD_SURFACE) override;
bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const override;
void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) override;
void DoCrossHair(wxCoord x, wxCoord y) override ;
void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) override;
void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) override;
void DoDrawPoint(wxCoord x, wxCoord y) override;
void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) override;
void DoDrawPolygon(int n, const wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE) override;
void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE) override;
void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) override;
void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20) override;
void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) override;
#if wxUSE_SPLINES
void DoDrawSpline(const wxPointList *points) override;
#endif
bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) override;
void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) override;
void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false) override;
void DoDrawText(const wxString& text, wxCoord x, wxCoord y) override;
void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) override;
void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) override;
void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip)) override
{
wxFAIL_MSG( "not implemented" );
}
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = nullptr,
wxCoord *externalLeading = nullptr,
const wxFont *theFont = nullptr) const override;
void DoGetSize(int* width, int* height) const override;
void DoGetSizeMM(int *width, int *height) const override;
// Common part of DoDrawText() and DoDrawRotatedText()
void DrawAnyText(const wxWX2MBbuf& textbuf, wxCoord testDescent, double lineHeight);
// Actually set PostScript font
void SetPSFont();
// Set PostScript color
void SetPSColour(const wxColour& col);
FILE* m_pstream; // PostScript output stream
unsigned char m_currentRed;
unsigned char m_currentGreen;
unsigned char m_currentBlue;
int m_pageNumber;
bool m_clipping;
mutable double m_underlinePosition;
mutable double m_underlineThickness;
wxPrintData m_printData;
double m_pageHeight;
wxArrayString m_definedPSFonts;
bool m_isFontChanged;
private:
wxDECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl);
};
#endif
// wxUSE_POSTSCRIPT && wxUSE_PRINTING_ARCHITECTURE
#endif
// _WX_DCPSG_H_

View File

@@ -0,0 +1,329 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dirctrlg.h
// Purpose: wxGenericDirCtrl class
// Builds on wxDirCtrl class written by Robert Roebling for the
// wxFile application, modified by Harm van der Heijden.
// Further modified for Windows.
// Author: Robert Roebling, Harm van der Heijden, Julian Smart et al
// Created: 21/3/2000
// Copyright: (c) Robert Roebling, Harm van der Heijden, Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIRCTRL_H_
#define _WX_DIRCTRL_H_
#include "wx/defs.h"
#if wxUSE_DIRDLG || wxUSE_FILEDLG
#include "wx/treectrl.h"
#include "wx/dialog.h"
#include "wx/dirdlg.h"
#include "wx/choice.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_BASE wxHashTable;
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogDefaultFolderStr[];
//-----------------------------------------------------------------------------
// Extra styles for wxGenericDirCtrl
//-----------------------------------------------------------------------------
enum
{
// Only allow directory viewing/selection, no files
wxDIRCTRL_DIR_ONLY = 0x0010,
// When setting the default path, select the first file in the directory
wxDIRCTRL_SELECT_FIRST = 0x0020,
// Show the filter list
wxDIRCTRL_SHOW_FILTERS = 0x0040,
// Use 3D borders on internal controls
wxDIRCTRL_3D_INTERNAL = 0x0080,
// Editable labels
wxDIRCTRL_EDIT_LABELS = 0x0100,
// Allow multiple selection
wxDIRCTRL_MULTIPLE = 0x0200,
wxDIRCTRL_DEFAULT_STYLE = wxDIRCTRL_3D_INTERNAL
};
//-----------------------------------------------------------------------------
// wxDirItemData
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDirItemData : public wxTreeItemData
{
public:
wxDirItemData(const wxString& path, const wxString& name, bool isDir);
virtual ~wxDirItemData() = default;
void SetNewDirName(const wxString& path);
bool HasSubDirs() const;
bool HasFiles(const wxString& spec = wxEmptyString) const;
wxString m_path, m_name;
bool m_isHidden;
bool m_isExpanded;
bool m_isDir;
};
//-----------------------------------------------------------------------------
// wxDirCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxDirFilterListCtrl;
class WXDLLIMPEXP_CORE wxGenericDirCtrl: public wxControl
{
public:
wxGenericDirCtrl();
wxGenericDirCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxString &dir = wxASCII_STR(wxDirDialogDefaultFolderStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDIRCTRL_DEFAULT_STYLE,
const wxString& filter = wxEmptyString,
int defaultFilter = 0,
const wxString& name = wxASCII_STR(wxTreeCtrlNameStr) )
{
Init();
Create(parent, id, dir, pos, size, style, filter, defaultFilter, name);
}
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxString &dir = wxASCII_STR(wxDirDialogDefaultFolderStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDIRCTRL_DEFAULT_STYLE,
const wxString& filter = wxEmptyString,
int defaultFilter = 0,
const wxString& name = wxASCII_STR(wxTreeCtrlNameStr) );
virtual void Init();
virtual ~wxGenericDirCtrl();
void OnExpandItem(wxTreeEvent &event );
void OnCollapseItem(wxTreeEvent &event );
void OnBeginEditItem(wxTreeEvent &event );
void OnEndEditItem(wxTreeEvent &event );
void OnTreeSelChange(wxTreeEvent &event);
void OnItemActivated(wxTreeEvent &event);
void OnSize(wxSizeEvent &event );
// Try to expand as much of the given path as possible.
virtual bool ExpandPath(const wxString& path);
// collapse the path
virtual bool CollapsePath(const wxString& path);
// Accessors
virtual inline wxString GetDefaultPath() const { return m_defaultPath; }
virtual void SetDefaultPath(const wxString& path) { m_defaultPath = path; }
// Get dir or filename
virtual wxString GetPath() const;
virtual void GetPaths(wxArrayString& paths) const;
// Get selected filename path only (else empty string).
// I.e. don't count a directory as a selection
virtual wxString GetFilePath() const;
virtual void GetFilePaths(wxArrayString& paths) const;
virtual void SetPath(const wxString& path);
virtual void SelectPath(const wxString& path, bool select = true);
virtual void SelectPaths(const wxArrayString& paths);
virtual void ShowHidden( bool show );
virtual bool GetShowHidden() { return m_showHidden; }
virtual wxString GetFilter() const { return m_filter; }
virtual void SetFilter(const wxString& filter);
virtual int GetFilterIndex() const { return m_currentFilter; }
virtual void SetFilterIndex(int n);
virtual wxTreeItemId GetRootId() { return m_rootId; }
virtual wxTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; }
virtual wxDirFilterListCtrl* GetFilterListCtrl() const { return m_filterListCtrl; }
virtual void UnselectAll();
// Helper
virtual void SetupSections();
// Find the child that matches the first part of 'path'.
// E.g. if a child path is "/usr" and 'path' is "/usr/include"
// then the child for /usr is returned.
// If the path string has been used (we're at the leaf), done is set to true
virtual wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done);
wxString GetPath(wxTreeItemId itemId) const;
// Resize the components of the control
virtual void DoResize();
// Collapse & expand the tree, thus re-creating it from scratch:
virtual void ReCreateTree();
// Collapse the entire tree
virtual void CollapseTree();
// overridden base class methods
virtual void SetFocus() override;
protected:
virtual void ExpandRoot();
virtual void ExpandDir(wxTreeItemId parentId);
virtual void CollapseDir(wxTreeItemId parentId);
virtual const wxTreeItemId AddSection(const wxString& path, const wxString& name, int imageId = 0);
virtual wxTreeItemId AppendItem (const wxTreeItemId & parent,
const wxString & text,
int image = -1, int selectedImage = -1,
wxTreeItemData * data = nullptr);
//void FindChildFiles(wxTreeItemId id, int dirFlags, wxArrayString& filenames);
virtual wxTreeCtrl* CreateTreeCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long treeStyle);
// Extract description and actual filter from overall filter string
bool ExtractWildcard(const wxString& filterStr, int n, wxString& filter, wxString& description);
private:
void PopulateNode(wxTreeItemId node);
wxDirItemData* GetItemData(wxTreeItemId itemId);
bool m_showHidden;
wxTreeItemId m_rootId;
wxString m_defaultPath; // Starting path
long m_styleEx; // Extended style
wxString m_filter; // Wildcards in same format as per wxFileDialog
int m_currentFilter; // The current filter index
wxString m_currentFilterStr; // Current filter string
wxTreeCtrl* m_treeCtrl;
wxDirFilterListCtrl* m_filterListCtrl;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericDirCtrl);
wxDECLARE_NO_COPY_CLASS(wxGenericDirCtrl);
};
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent );
#define wx__DECLARE_DIRCTRL_EVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_DIRCTRL_ ## evt, id, wxTreeEventHandler(fn))
#define EVT_DIRCTRL_SELECTIONCHANGED(id, fn) wx__DECLARE_DIRCTRL_EVT(SELECTIONCHANGED, id, fn)
#define EVT_DIRCTRL_FILEACTIVATED(id, fn) wx__DECLARE_DIRCTRL_EVT(FILEACTIVATED, id, fn)
//-----------------------------------------------------------------------------
// wxDirFilterListCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDirFilterListCtrl: public wxChoice
{
public:
wxDirFilterListCtrl() { Init(); }
wxDirFilterListCtrl(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0)
{
Init();
Create(parent, id, pos, size, style);
}
bool Create(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
void Init();
virtual ~wxDirFilterListCtrl() = default;
//// Operations
void FillFilterList(const wxString& filter, int defaultFilter);
//// Events
void OnSelFilter(wxCommandEvent& event);
protected:
wxGenericDirCtrl* m_dirCtrl;
wxDECLARE_EVENT_TABLE();
wxDECLARE_CLASS(wxDirFilterListCtrl);
wxDECLARE_NO_COPY_CLASS(wxDirFilterListCtrl);
};
#if !defined(__WXMSW__) && !defined(__WXMAC__)
#define wxDirCtrl wxGenericDirCtrl
#endif
// Symbols for accessing individual controls
#define wxID_TREECTRL 7000
#define wxID_FILTERLISTCTRL 7001
#endif // wxUSE_DIRDLG
//-------------------------------------------------------------------------
// wxFileIconsTable - use wxTheFileIconsTable which is created as necessary
//-------------------------------------------------------------------------
#if wxUSE_DIRDLG || wxUSE_FILEDLG || wxUSE_FILECTRL
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_CORE wxFileIconsTable
{
public:
wxFileIconsTable();
~wxFileIconsTable();
enum iconId_Type
{
folder,
folder_open,
computer,
drive,
cdrom,
floppy,
removeable,
file,
executable
};
int GetIconID(const wxString& extension, const wxString& mime = wxEmptyString);
wxImageList *GetSmallImageList();
const wxSize& GetSize() const { return m_size; }
void SetSize(const wxSize& sz) { m_size = sz; }
bool IsOk() const { return m_smallImageList != nullptr; }
protected:
void Create(const wxSize& sz); // create on first use
wxImageList *m_smallImageList;
wxHashTable *m_HashTable;
wxSize m_size;
};
// The global fileicons table
extern WXDLLIMPEXP_DATA_CORE(wxFileIconsTable *) wxTheFileIconsTable;
#endif // wxUSE_DIRDLG || wxUSE_FILEDLG || wxUSE_FILECTRL
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_DIRCTRL_SELECTIONCHANGED wxEVT_DIRCTRL_SELECTIONCHANGED
#define wxEVT_COMMAND_DIRCTRL_FILEACTIVATED wxEVT_DIRCTRL_FILEACTIVATED
#endif
// _WX_DIRCTRLG_H_

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dirdlgg.h
// Purpose: wxGenericDirCtrl class
// Builds on wxDirCtrl class written by Robert Roebling for the
// wxFile application, modified by Harm van der Heijden.
// Further modified for Windows.
// Author: Robert Roebling, Harm van der Heijden, Julian Smart et al
// Created: 21/3/2000
// Copyright: (c) Robert Roebling, Harm van der Heijden, Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIRDLGG_H_
#define _WX_DIRDLGG_H_
class WXDLLIMPEXP_FWD_CORE wxGenericDirCtrl;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxTreeEvent;
// we may be included directly as well as from wx/dirdlg.h (FIXME)
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[];
#ifndef wxDD_DEFAULT_STYLE
#define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
#endif
#include "wx/dialog.h"
//-----------------------------------------------------------------------------
// wxGenericDirDialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericDirDialog : public wxDirDialogBase
{
public:
wxGenericDirDialog() : wxDirDialogBase() { }
wxGenericDirDialog(wxWindow* parent,
const wxString& title = wxASCII_STR(wxDirSelectorPromptStr),
const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,//Size(450, 550),
const wxString& name = wxASCII_STR(wxDirDialogNameStr));
bool Create(wxWindow* parent,
const wxString& title = wxASCII_STR(wxDirSelectorPromptStr),
const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,//Size(450, 550),
const wxString& name = wxASCII_STR(wxDirDialogNameStr));
//// Accessors
void SetPath(const wxString& path) override;
wxString GetPath() const override;
//// Overrides
virtual int ShowModal() override;
virtual void EndModal(int retCode) override;
// this one is specific to wxGenericDirDialog
wxTextCtrl* GetInputCtrl() const { return m_input; }
protected:
//// Event handlers
void OnCloseWindow(wxCloseEvent& event);
void OnOK(wxCommandEvent& event);
void OnTreeSelected(wxTreeEvent &event);
void OnTreeKeyDown(wxTreeEvent &event);
void OnNew(wxCommandEvent& event);
void OnGoHome(wxCommandEvent& event);
void OnShowHidden(wxCommandEvent& event);
wxGenericDirCtrl* m_dirCtrl;
wxTextCtrl* m_input;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericDirDialog);
};
#endif // _WX_DIRDLGG_H_

View File

@@ -0,0 +1,247 @@
//////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dragimgg.h
// Purpose: wxDragImage class: a kind of a cursor, that can cope
// with more sophisticated images
// Author: Julian Smart
// Created: 29/2/2000
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DRAGIMGG_H_
#define _WX_DRAGIMGG_H_
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/cursor.h"
#include "wx/treectrl.h"
#include "wx/listctrl.h"
#include "wx/log.h"
#include "wx/overlay.h"
/*
To use this class, create a wxDragImage when you start dragging, for example:
void MyTreeCtrl::OnBeginDrag(wxTreeEvent& event)
{
#ifdef __WXMSW__
::UpdateWindow((HWND) GetHWND()); // We need to implement this in wxWidgets
#endif
CaptureMouse();
m_dragImage = new wxDragImage(* this, itemId);
m_dragImage->BeginDrag(wxPoint(0, 0), this);
m_dragImage->Move(pt, this);
m_dragImage->Show(this);
...
}
In your OnMouseMove function, hide the image, do any display updating required,
then move and show the image again:
void MyTreeCtrl::OnMouseMove(wxMouseEvent& event)
{
if (m_dragMode == MY_TREE_DRAG_NONE)
{
event.Skip();
return;
}
// Prevent screen corruption by hiding the image
if (m_dragImage)
m_dragImage->Hide(this);
// Do some updating of the window, such as highlighting the drop target
...
#ifdef __WXMSW__
if (updateWindow)
::UpdateWindow((HWND) GetHWND());
#endif
// Move and show the image again
m_dragImage->Move(event.GetPosition(), this);
m_dragImage->Show(this);
}
Eventually we end the drag and delete the drag image.
void MyTreeCtrl::OnLeftUp(wxMouseEvent& event)
{
...
// End the drag and delete the drag image
if (m_dragImage)
{
m_dragImage->EndDrag(this);
delete m_dragImage;
m_dragImage = nullptr;
}
ReleaseMouse();
}
*/
/*
* wxGenericDragImage
*/
class WXDLLIMPEXP_CORE wxGenericDragImage: public wxObject
{
public:
// Ctors & dtor
////////////////////////////////////////////////////////////////////////////
wxGenericDragImage(const wxCursor& cursor = wxNullCursor)
{
Init();
Create(cursor);
}
wxGenericDragImage(const wxBitmap& image, const wxCursor& cursor = wxNullCursor)
{
Init();
Create(image, cursor);
}
wxGenericDragImage(const wxIcon& image, const wxCursor& cursor = wxNullCursor)
{
Init();
Create(image, cursor);
}
wxGenericDragImage(const wxString& str, const wxCursor& cursor = wxNullCursor)
{
Init();
Create(str, cursor);
}
#if wxUSE_TREECTRL
wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id)
{
Init();
Create(treeCtrl, id);
}
#endif
#if wxUSE_LISTCTRL
wxGenericDragImage(const wxListCtrl& listCtrl, long id)
{
Init();
Create(listCtrl, id);
}
#endif
virtual ~wxGenericDragImage();
// Attributes
////////////////////////////////////////////////////////////////////////////
// For efficiency, tell wxGenericDragImage to use a bitmap that's already
// created (e.g. from last drag)
void SetBackingBitmap(wxBitmap* bitmap) { m_pBackingBitmap = bitmap; }
// Operations
////////////////////////////////////////////////////////////////////////////
// Create a drag image with a virtual image (need to override DoDrawImage, GetImageRect)
bool Create(const wxCursor& cursor = wxNullCursor);
// Create a drag image from a bitmap and optional cursor
bool Create(const wxBitmap& image, const wxCursor& cursor = wxNullCursor);
// Create a drag image from an icon and optional cursor
bool Create(const wxIcon& image, const wxCursor& cursor = wxNullCursor);
// Create a drag image from a string and optional cursor
bool Create(const wxString& str, const wxCursor& cursor = wxNullCursor);
#if wxUSE_TREECTRL
// Create a drag image for the given tree control item
bool Create(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
#endif
#if wxUSE_LISTCTRL
// Create a drag image for the given list control item
bool Create(const wxListCtrl& listCtrl, long id);
#endif
// Begin drag. hotspot is the location of the drag position relative to the upper-left
// corner of the image.
bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = false, wxRect* rect = nullptr);
// Begin drag. hotspot is the location of the drag position relative to the upper-left
// corner of the image. This is full screen only. fullScreenRect gives the
// position of the window on the screen, to restrict the drag to.
bool BeginDrag(const wxPoint& hotspot, wxWindow* window, wxWindow* fullScreenRect);
// End drag
bool EndDrag();
// Move the image: call from OnMouseMove. Pt is in window client coordinates if window
// is non-null, or in screen coordinates if null.
bool Move(const wxPoint& pt);
// Show the image
bool Show();
// Hide the image
bool Hide();
// Implementation
////////////////////////////////////////////////////////////////////////////
void Init();
// Override this if you are using a virtual image (drawing your own image)
virtual wxRect GetImageRect(const wxPoint& pos) const;
// Override this if you are using a virtual image (drawing your own image)
virtual bool DoDrawImage(wxDC& dc, const wxPoint& pos) const;
// Override this if you wish to draw the window contents to the backing bitmap
// yourself. This can be desirable if you wish to avoid flicker by not having to
// redraw the window itself before dragging in order to be graphic-minus-dragged-objects.
// Instead, paint the drag image's backing bitmap to be correct, and leave the window
// to be updated only when dragging the objects away (thus giving a smoother appearance).
virtual bool UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC,
const wxRect& sourceRect, const wxRect& destRect) const;
// Erase and redraw simultaneously if possible
virtual bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, bool eraseOld, bool drawNew);
protected:
wxBitmap m_bitmap;
wxIcon m_icon;
wxCursor m_cursor;
wxCursor m_oldCursor;
// wxPoint m_hotspot;
wxPoint m_offset; // The hostpot value passed to BeginDrag
wxPoint m_position;
bool m_isDirty;
bool m_isShown;
wxWindow* m_window;
wxDC* m_windowDC;
wxOverlay m_overlay;
// Stores the window contents while we're dragging the image around
wxBitmap m_backingBitmap;
wxBitmap* m_pBackingBitmap; // Pointer to existing backing bitmap
// (pass to wxGenericDragImage as an efficiency measure)
// A temporary bitmap for repairing/redrawing
wxBitmap m_repairBitmap;
wxRect m_boundingRect;
bool m_fullScreen;
private:
wxDECLARE_DYNAMIC_CLASS(wxGenericDragImage);
wxDECLARE_NO_COPY_CLASS(wxGenericDragImage);
};
#endif
// _WX_DRAGIMGG_H_

View File

@@ -0,0 +1,75 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dvrenderer.h
// Purpose: wxDataViewRenderer for generic wxDataViewCtrl implementation
// Author: Robert Roebling, Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/generic/dataview.h)
// Copyright: (c) 2006 Robert Roebling
// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DVRENDERER_H_
#define _WX_GENERIC_DVRENDERER_H_
// ----------------------------------------------------------------------------
// wxDataViewRenderer
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewCustomRendererBase
{
public:
wxDataViewRenderer( const wxString &varianttype,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewRenderer();
virtual wxDC *GetDC() override;
virtual void SetAlignment( int align ) override;
virtual int GetAlignment() const override;
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) override
{ m_ellipsizeMode = mode; }
virtual wxEllipsizeMode GetEllipsizeMode() const override
{ return m_ellipsizeMode; }
virtual void SetMode( wxDataViewCellMode mode ) override
{ m_mode = mode; }
virtual wxDataViewCellMode GetMode() const override
{ return m_mode; }
// implementation
// This callback is used by generic implementation of wxDVC itself. It's
// different from the corresponding ActivateCell() method which should only
// be overridable for the custom renderers while the generic implementation
// uses this one for all of them, including the standard ones.
virtual bool WXActivateCell(const wxRect& WXUNUSED(cell),
wxDataViewModel *WXUNUSED(model),
const wxDataViewItem & WXUNUSED(item),
unsigned int WXUNUSED(col),
const wxMouseEvent* WXUNUSED(mouseEvent))
{ return false; }
void SetState(int state) { m_state = state; }
protected:
virtual bool IsHighlighted() const override
{ return m_state & wxDATAVIEW_CELL_SELECTED; }
private:
int m_align;
wxDataViewCellMode m_mode;
wxEllipsizeMode m_ellipsizeMode;
wxDC *m_dc;
int m_state;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer);
};
#endif // _WX_GENERIC_DVRENDERER_H_

View File

@@ -0,0 +1,229 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dvrenderers.h
// Purpose: All generic wxDataViewCtrl renderer classes
// Author: Robert Roebling, Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/generic/dataview.h)
// Copyright: (c) 2006 Robert Roebling
// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DVRENDERERS_H_
#define _WX_GENERIC_DVRENDERERS_H_
// ---------------------------------------------------------
// wxDataViewCustomRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
// see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h
virtual bool WXActivateCell(const wxRect& cell,
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col,
const wxMouseEvent *mouseEvent) override
{
return ActivateCell(cell, model, item, col, mouseEvent);
}
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer);
};
// ---------------------------------------------------------
// wxDataViewTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewTextRenderer();
#if wxUSE_MARKUP
void EnableMarkup(bool enable = true);
#endif // wxUSE_MARKUP
virtual bool SetValue( const wxVariant &value ) override;
virtual bool GetValue( wxVariant &value ) const override;
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Render(wxRect cell, wxDC *dc, int state) override;
virtual wxSize GetSize() const override;
// in-place editing
virtual bool HasEditorCtrl() const override;
virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
const wxVariant &value ) override;
virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ) override;
protected:
wxString m_text;
private:
#if wxUSE_MARKUP
class wxItemMarkupText *m_markupText;
#endif // wxUSE_MARKUP
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxBitmapBundle"); }
wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual bool SetValue( const wxVariant &value ) override;
virtual bool GetValue( wxVariant &value ) const override;
virtual
bool IsCompatibleVariantType(const wxString& variantType) const override;
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Render( wxRect cell, wxDC *dc, int state ) override;
virtual wxSize GetSize() const override;
private:
wxBitmapBundle m_bitmapBundle;
protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer);
};
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
void ShowAsRadio() { m_radio = true; }
virtual bool SetValue( const wxVariant &value ) override;
virtual bool GetValue( wxVariant &value ) const override;
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Render( wxRect cell, wxDC *dc, int state ) override;
virtual wxSize GetSize() const override;
// Implementation only, don't use nor override
virtual bool WXActivateCell(const wxRect& cell,
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col,
const wxMouseEvent *mouseEvent) override;
private:
bool m_toggle;
bool m_radio;
protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer);
};
// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual bool SetValue( const wxVariant &value ) override;
virtual bool GetValue( wxVariant& value ) const override;
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Render(wxRect cell, wxDC *dc, int state) override;
virtual wxSize GetSize() const override;
private:
wxString m_label;
int m_value;
protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer);
};
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual bool SetValue( const wxVariant &value ) override;
virtual bool GetValue( wxVariant &value ) const override;
#if wxUSE_ACCESSIBILITY
virtual wxString GetAccessibleDescription() const override;
#endif // wxUSE_ACCESSIBILITY
virtual bool Render(wxRect cell, wxDC *dc, int state) override;
virtual wxSize GetSize() const override;
virtual bool HasEditorCtrl() const override { return true; }
virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
const wxVariant &value ) override;
virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value ) override;
private:
wxDataViewIconText m_value;
protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer);
};
#endif // _WX_GENERIC_DVRENDERERS_H_

View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/fdrepdlg.h
// Purpose: wxGenericFindReplaceDialog class
// Author: Markus Greither
// Created: 25/05/2001
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_FDREPDLG_H_
#define _WX_GENERIC_FDREPDLG_H_
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxRadioBox;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
// ----------------------------------------------------------------------------
// wxGenericFindReplaceDialog: dialog for searching / replacing text
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericFindReplaceDialog : public wxFindReplaceDialogBase
{
public:
wxGenericFindReplaceDialog() { Init(); }
wxGenericFindReplaceDialog(wxWindow *parent,
wxFindReplaceData *data,
const wxString& title,
int style = 0)
{
Init();
(void)Create(parent, data, title, style);
}
bool Create(wxWindow *parent,
wxFindReplaceData *data,
const wxString& title,
int style = 0);
protected:
void Init();
void SendEvent(const wxEventType& evtType);
void OnFind(wxCommandEvent& event);
void OnReplace(wxCommandEvent& event);
void OnReplaceAll(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
void OnUpdateFindUI(wxUpdateUIEvent& event);
void OnCloseWindow(wxCloseEvent& event);
wxCheckBox *m_chkCase,
*m_chkWord;
wxRadioBox *m_radioDir;
wxTextCtrl *m_textFind,
*m_textRepl;
private:
wxDECLARE_DYNAMIC_CLASS(wxGenericFindReplaceDialog);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_GENERIC_FDREPDLG_H_

View File

@@ -0,0 +1,303 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/filectrlg.h
// Purpose: wxGenericFileCtrl Header
// Author: Diaa M. Sami
// Created: Jul-07-2007
// Copyright: (c) Diaa M. Sami
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_FILECTRL_H_
#define _WX_GENERIC_FILECTRL_H_
#if wxUSE_FILECTRL
#include "wx/containr.h"
#include "wx/listctrl.h"
#include "wx/filectrl.h"
#include "wx/filename.h"
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxChoice;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[];
//-----------------------------------------------------------------------------
// wxFileData - a class to hold the file info for the wxFileListCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileData
{
public:
enum fileType
{
is_file = 0x0000,
is_dir = 0x0001,
is_link = 0x0002,
is_exe = 0x0004,
is_drive = 0x0008
};
wxFileData() { Init(); }
// Full copy constructor
wxFileData( const wxFileData& fileData ) { Copy(fileData); }
// Create a filedata from this information
wxFileData( const wxString &filePath, const wxString &fileName,
fileType type, int image_id );
// make a full copy of the other wxFileData
void Copy( const wxFileData &other );
// (re)read the extra data about the file from the system
void ReadData();
// get the name of the file, dir, drive
wxString GetFileName() const { return m_fileName; }
// get the full path + name of the file, dir, path
wxString GetFilePath() const { return m_filePath; }
// Set the path + name and name of the item
void SetNewName( const wxString &filePath, const wxString &fileName );
// Get the size of the file in bytes
wxFileOffset GetSize() const { return m_size; }
// Get the type of file, either file extension or <DIR>, <LINK>, <DRIVE>
wxString GetFileType() const;
// get the last modification time
wxDateTime GetDateTime() const { return m_dateTime; }
// Get the time as a formatted string
wxString GetModificationTime() const;
// in UNIX get rwx for file, in MSW get attributes ARHS
wxString GetPermissions() const { return m_permissions; }
// Get the id of the image used in a wxImageList
int GetImageId() const { return m_image; }
bool IsFile() const { return !IsDir() && !IsLink() && !IsDrive(); }
bool IsDir() const { return (m_type & is_dir ) != 0; }
bool IsLink() const { return (m_type & is_link ) != 0; }
bool IsExe() const { return (m_type & is_exe ) != 0; }
bool IsDrive() const { return (m_type & is_drive) != 0; }
// Get/Set the type of file, file/dir/drive/link
int GetType() const { return m_type; }
// the wxFileListCtrl fields in report view
enum fileListFieldType
{
FileList_Name,
FileList_Size,
FileList_Type,
FileList_Time,
#if defined(__UNIX__) || defined(__WIN32__)
FileList_Perm,
#endif // defined(__UNIX__) || defined(__WIN32__)
FileList_Max
};
// Get the entry for report view of wxFileListCtrl
wxString GetEntry( fileListFieldType num ) const;
// Get a string representation of the file info
wxString GetHint() const;
// initialize a wxListItem attributes
void MakeItem( wxListItem &item );
// operators
wxFileData& operator = (const wxFileData& fd) { Copy(fd); return *this; }
protected:
wxString m_fileName;
wxString m_filePath;
wxFileOffset m_size;
wxDateTime m_dateTime;
wxString m_permissions;
int m_type;
int m_image;
private:
void Init();
};
//-----------------------------------------------------------------------------
// wxFileListCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileListCtrl : public wxListCtrl
{
public:
wxFileListCtrl();
wxFileListCtrl( wxWindow *win,
wxWindowID id,
const wxString &wild,
bool showHidden,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_LIST,
const wxValidator &validator = wxDefaultValidator,
const wxString &name = wxT("filelist") );
virtual ~wxFileListCtrl();
virtual void ChangeToListMode();
virtual void ChangeToReportMode();
virtual void ChangeToSmallIconMode();
virtual void ShowHidden( bool show = true );
bool GetShowHidden() const { return m_showHidden; }
virtual long Add( wxFileData *fd, wxListItem &item );
virtual void UpdateItem(const wxListItem &item);
virtual void UpdateFiles();
virtual void MakeDir();
virtual void GoToParentDir();
virtual void GoToHomeDir();
virtual void GoToDir( const wxString &dir );
virtual void SetWild( const wxString &wild );
wxString GetWild() const { return m_wild; }
wxString GetDir() const { return m_dirName; }
void OnListDeleteItem( wxListEvent &event );
void OnListDeleteAllItems( wxListEvent &event );
void OnListEndLabelEdit( wxListEvent &event );
void OnListColClick( wxListEvent &event );
void OnSize( wxSizeEvent &event );
virtual void SortItems(wxFileData::fileListFieldType field, bool forward);
bool GetSortDirection() const { return m_sort_forward; }
wxFileData::fileListFieldType GetSortField() const { return m_sort_field; }
protected:
void FreeItemData(wxListItem& item);
void FreeAllItemsData();
wxString m_dirName;
bool m_showHidden;
wxString m_wild;
bool m_sort_forward;
wxFileData::fileListFieldType m_sort_field;
private:
wxDECLARE_DYNAMIC_CLASS(wxFileListCtrl);
wxDECLARE_EVENT_TABLE();
};
class WXDLLIMPEXP_CORE wxGenericFileCtrl : public wxNavigationEnabled<wxControl>,
public wxFileCtrlBase
{
public:
wxGenericFileCtrl()
{
m_ignoreChanges = false;
}
wxGenericFileCtrl ( wxWindow *parent,
wxWindowID id,
const wxString& defaultDirectory = wxEmptyString,
const wxString& defaultFilename = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFC_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileCtrlNameStr) )
{
m_ignoreChanges = false;
Create(parent, id, defaultDirectory, defaultFilename, wildCard,
style, pos, size, name );
}
virtual ~wxGenericFileCtrl() = default;
bool Create( wxWindow *parent,
wxWindowID id,
const wxString& defaultDirectory = wxEmptyString,
const wxString& defaultFileName = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFC_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileCtrlNameStr) );
virtual void SetWildcard( const wxString& wildCard ) override;
virtual void SetFilterIndex( int filterindex ) override;
virtual bool SetDirectory( const wxString& dir ) override;
// Selects a certain file.
// In case the filename specified isn't found/couldn't be shown with
// currently selected filter, false is returned and nothing happens
virtual bool SetFilename( const wxString& name ) override;
// Changes to a certain directory and selects a certain file.
// In case the filename specified isn't found/couldn't be shown with
// currently selected filter, false is returned and if directory exists
// it's chdir'ed to
virtual bool SetPath( const wxString& path ) override;
virtual wxString GetFilename() const override;
virtual wxString GetDirectory() const override;
virtual wxString GetWildcard() const override { return this->m_wildCard; }
virtual wxString GetPath() const override;
virtual void GetPaths( wxArrayString& paths ) const override;
virtual void GetFilenames( wxArrayString& files ) const override;
virtual int GetFilterIndex() const override { return m_filterIndex; }
virtual bool HasMultipleFileSelection() const override
{ return HasFlag(wxFC_MULTIPLE); }
virtual void ShowHidden(bool show) override { m_list->ShowHidden( show ); }
void GoToParentDir();
void GoToHomeDir();
// get the directory currently shown in the control: this can be different
// from GetDirectory() if the user entered a full path (with a path other
// than the one currently shown in the control) in the text control
// manually
wxString GetShownDirectory() const { return m_list->GetDir(); }
wxFileListCtrl *GetFileList() { return m_list; }
void ChangeToReportMode() { m_list->ChangeToReportMode(); }
void ChangeToListMode() { m_list->ChangeToListMode(); }
private:
void OnChoiceFilter( wxCommandEvent &event );
void OnCheck( wxCommandEvent &event );
void OnActivated( wxListEvent &event );
void OnTextEnter( wxCommandEvent &WXUNUSED( event ) );
void OnTextChange( wxCommandEvent &WXUNUSED( event ) );
void OnSelected( wxListEvent &event );
void HandleAction( const wxString &fn );
void DoSetFilterIndex( int filterindex );
void UpdateControls();
// the first of these methods can only be used for the controls with single
// selection (i.e. without wxFC_MULTIPLE style), the second one in any case
wxFileName DoGetFileName() const;
void DoGetFilenames( wxArrayString& filenames, bool fullPath ) const;
int m_style;
wxString m_filterExtension;
wxChoice *m_choice;
wxTextCtrl *m_text;
wxFileListCtrl *m_list;
wxCheckBox *m_check;
wxStaticText *m_static;
wxString m_dir;
wxString m_fileName;
wxString m_wildCard; // wild card in one string as we got it
int m_filterIndex;
bool m_inSelected;
bool m_ignoreChanges;
bool m_noSelChgEvent; // suppress selection changed events.
wxDECLARE_DYNAMIC_CLASS(wxGenericFileCtrl);
wxDECLARE_EVENT_TABLE();
};
#endif // wxUSE_FILECTRL
#endif // _WX_GENERIC_FILECTRL_H_

View File

@@ -0,0 +1,165 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/filedlgg.h
// Purpose: wxGenericFileDialog
// Author: Robert Roebling
// Created: 8/17/99
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLGG_H_
#define _WX_FILEDLGG_H_
#include "wx/listctrl.h"
#include "wx/datetime.h"
#include "wx/filefn.h"
#include "wx/artprov.h"
#include "wx/filedlg.h"
#include "wx/generic/filectrlg.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
class WXDLLIMPEXP_FWD_CORE wxGenericFileCtrl;
class WXDLLIMPEXP_FWD_CORE wxGenericFileDialog;
class WXDLLIMPEXP_FWD_CORE wxFileCtrlEvent;
//-------------------------------------------------------------------------
// wxGenericFileDialog
//-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericFileDialog: public wxFileDialogBase
{
public:
wxGenericFileDialog() : wxFileDialogBase() { Init(); }
wxGenericFileDialog(wxWindow *parent,
const wxString& message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileDialogNameStr),
bool bypassGenericImpl = false );
bool Create( wxWindow *parent,
const wxString& message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileDialogNameStr),
bool bypassGenericImpl = false );
virtual ~wxGenericFileDialog();
virtual void SetDirectory(const wxString& dir) override
{ m_filectrl->SetDirectory(dir); }
virtual void SetFilename(const wxString& name) override
{ m_filectrl->SetFilename(name); }
virtual void SetMessage(const wxString& message) override { SetTitle(message); }
virtual void SetPath(const wxString& path) override
{ m_filectrl->SetPath(path); }
virtual void SetFilterIndex(int filterIndex) override
{ m_filectrl->SetFilterIndex(filterIndex); }
virtual void SetWildcard(const wxString& wildCard) override
{ m_filectrl->SetWildcard(wildCard); }
virtual wxString GetPath() const override
{
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetPaths() instead" );
return m_filectrl->GetPath();
}
virtual void GetPaths(wxArrayString& paths) const override
{ m_filectrl->GetPaths(paths); }
virtual wxString GetDirectory() const override
{ return m_filectrl->GetDirectory(); }
virtual wxString GetFilename() const override
{
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetFilenames() instead" );
return m_filectrl->GetFilename();
}
virtual void GetFilenames(wxArrayString& files) const override
{ m_filectrl->GetFilenames(files); }
virtual wxString GetWildcard() const override
{ return m_filectrl->GetWildcard(); }
virtual int GetFilterIndex() const override
{ return m_filectrl->GetFilterIndex(); }
virtual bool SupportsExtraControl() const override { return true; }
// implementation only from now on
// -------------------------------
virtual int ShowModal() override;
virtual bool Show( bool show = true ) override;
void OnList( wxCommandEvent &event );
void OnReport( wxCommandEvent &event );
void OnUp( wxCommandEvent &event );
void OnHome( wxCommandEvent &event );
void OnOk( wxCommandEvent &event );
void OnNew( wxCommandEvent &event );
void OnFileActivated( wxFileCtrlEvent &event);
private:
// if true, don't use this implementation at all
bool m_bypassGenericImpl;
protected:
// update the state of m_upDirButton and m_newDirButton depending on the
// currently selected directory
void OnUpdateButtonsUI(wxUpdateUIEvent& event);
wxString m_filterExtension;
wxGenericFileCtrl *m_filectrl;
wxBitmapButton *m_upDirButton;
wxBitmapButton *m_newDirButton;
private:
void Init();
wxBitmapButton* AddBitmapButton( wxWindowID winId, const wxArtID& artId,
const wxString& tip, wxSizer *sizer );
wxDECLARE_DYNAMIC_CLASS(wxGenericFileDialog);
wxDECLARE_EVENT_TABLE();
// these variables are preserved between wxGenericFileDialog calls
static long ms_lastViewStyle; // list or report?
static bool ms_lastShowHidden; // did we show hidden files?
};
#ifdef wxHAS_GENERIC_FILEDIALOG
class WXDLLIMPEXP_CORE wxFileDialog: public wxGenericFileDialog
{
public:
wxFileDialog() = default;
wxFileDialog(wxWindow *parent,
const wxString& message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = 0,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize)
:wxGenericFileDialog(parent, message,
defaultDir, defaultFile, wildCard,
style,
pos, size)
{
}
private:
wxDECLARE_DYNAMIC_CLASS(wxFileDialog);
};
#endif // wxHAS_GENERIC_FILEDIALOG
#endif // _WX_FILEDLGG_H_

View File

@@ -0,0 +1,216 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/filepickerg.h
// Purpose: wxGenericFileDirButton, wxGenericFileButton, wxGenericDirButton
// Author: Francesco Montorsi
// Created: 14/4/2006
// Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDIRPICKER_H_
#define _WX_FILEDIRPICKER_H_
#include "wx/button.h"
#include "wx/filedlg.h"
#include "wx/dirdlg.h"
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRPICKER_CHANGED, wxFileDirPickerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILEPICKER_CHANGED, wxFileDirPickerEvent );
//-----------------------------------------------------------------------------
// wxGenericFileDirButton: a button which brings up a wx{File|Dir}Dialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericFileDirButton : public wxButton,
public wxFileDirPickerWidgetBase
{
public:
wxGenericFileDirButton() = default;
wxGenericFileDirButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxASCII_STR(wxFilePickerWidgetLabel),
const wxString& path = wxEmptyString,
const wxString &message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString &wildcard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxFilePickerWidgetNameStr))
{
Create(parent, id, label, path, message, wildcard,
pos, size, style, validator, name);
}
virtual wxControl *AsControl() override { return this; }
public: // overridable
virtual wxDialog *CreateDialog() = 0;
virtual wxWindow *GetDialogParent()
{ return GetParent(); }
virtual wxEventType GetEventType() const = 0;
public:
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label = wxASCII_STR(wxFilePickerWidgetLabel),
const wxString& path = wxEmptyString,
const wxString &message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString &wildcard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxFilePickerWidgetNameStr));
// event handler for the click
void OnButtonClick(wxCommandEvent &);
protected:
// Return the path from the button-specific dialog (this is the same dialog
// that is returned by CreateDialog()).
virtual wxString GetPathFromDialog(wxDialog *p) const = 0;
wxString m_message, m_wildcard;
// we just store the style passed to the ctor here instead of passing it to
// wxButton as some of our bits can conflict with wxButton styles and it
// just doesn't make sense to use picker styles for wxButton anyhow
long m_pickerStyle = -1;
};
//-----------------------------------------------------------------------------
// wxGenericFileButton: a button which brings up a wxFileDialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericFileButton : public wxGenericFileDirButton
{
public:
wxGenericFileButton() = default;
wxGenericFileButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxASCII_STR(wxFilePickerWidgetLabel),
const wxString& path = wxEmptyString,
const wxString &message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString &wildcard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxFILEBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxFilePickerWidgetNameStr))
{
Create(parent, id, label, path, message, wildcard,
pos, size, style, validator, name);
}
public: // overridable
static long GetDialogStyle(long pickerStyle)
{
long filedlgstyle = 0;
if ( pickerStyle & wxFLP_OPEN )
filedlgstyle |= wxFD_OPEN;
if ( pickerStyle & wxFLP_SAVE )
filedlgstyle |= wxFD_SAVE;
if ( pickerStyle & wxFLP_OVERWRITE_PROMPT )
filedlgstyle |= wxFD_OVERWRITE_PROMPT;
if ( pickerStyle & wxFLP_FILE_MUST_EXIST )
filedlgstyle |= wxFD_FILE_MUST_EXIST;
if ( pickerStyle & wxFLP_CHANGE_DIR )
filedlgstyle |= wxFD_CHANGE_DIR;
return filedlgstyle;
}
long GetDialogStyle() const
{
// the derived class must initialize it if it doesn't use the
// non-default wxGenericFileDirButton ctor
wxASSERT_MSG( m_pickerStyle != -1,
"forgot to initialize m_pickerStyle?" );
return GetDialogStyle(m_pickerStyle);
}
virtual wxDialog *CreateDialog() override;
wxEventType GetEventType() const override
{ return wxEVT_FILEPICKER_CHANGED; }
protected:
wxString GetPathFromDialog(wxDialog *p) const override
{ return wxStaticCast(p, wxFileDialog)->GetPath(); }
private:
wxDECLARE_DYNAMIC_CLASS(wxGenericFileButton);
};
//-----------------------------------------------------------------------------
// wxGenericDirButton: a button which brings up a wxDirDialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericDirButton : public wxGenericFileDirButton
{
public:
wxGenericDirButton() = default;
wxGenericDirButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxASCII_STR(wxDirPickerWidgetLabel),
const wxString& path = wxEmptyString,
const wxString &message = wxASCII_STR(wxDirSelectorPromptStr),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDIRBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxDirPickerWidgetNameStr))
{
Create(parent, id, label, path, message, wxEmptyString,
pos, size, style, validator, name);
}
public: // overridable
static long GetDialogStyle(long pickerStyle)
{
long dirdlgstyle = wxDD_DEFAULT_STYLE;
if ( pickerStyle & wxDIRP_DIR_MUST_EXIST )
dirdlgstyle |= wxDD_DIR_MUST_EXIST;
if ( pickerStyle & wxDIRP_CHANGE_DIR )
dirdlgstyle |= wxDD_CHANGE_DIR;
return dirdlgstyle;
}
long GetDialogStyle() const
{
return GetDialogStyle(m_pickerStyle);
}
virtual wxDialog *CreateDialog() override;
wxEventType GetEventType() const override
{ return wxEVT_DIRPICKER_CHANGED; }
protected:
wxString GetPathFromDialog(wxDialog *p) const override
{ return wxStaticCast(p, wxDirDialog)->GetPath(); }
private:
wxDECLARE_DYNAMIC_CLASS(wxGenericDirButton);
};
// old wxEVT_COMMAND_* constants
//#define wxEVT_COMMAND_DIRPICKER_CHANGED wxEVT_DIRPICKER_CHANGED
//#define wxEVT_COMMAND_FILEPICKER_CHANGED wxEVT_FILEPICKER_CHANGED
#endif // _WX_FILEDIRPICKER_H_

View File

@@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/fontdlgg.h
// Purpose: wxGenericFontDialog
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_FONTDLGG_H
#define _WX_GENERIC_FONTDLGG_H
#include "wx/gdicmn.h"
#include "wx/font.h"
#define USE_SPINCTRL_FOR_POINT_SIZE 0
/*
* FONT DIALOG
*/
class WXDLLIMPEXP_FWD_CORE wxChoice;
class WXDLLIMPEXP_FWD_CORE wxText;
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxFontPreviewer;
enum
{
wxID_FONT_UNDERLINE = 3000,
wxID_FONT_STYLE,
wxID_FONT_WEIGHT,
wxID_FONT_FAMILY,
wxID_FONT_COLOUR,
wxID_FONT_SIZE
};
class WXDLLIMPEXP_CORE wxGenericFontDialog : public wxFontDialogBase
{
public:
wxGenericFontDialog() { Init(); }
wxGenericFontDialog(wxWindow *parent)
: wxFontDialogBase(parent) { Init(); }
wxGenericFontDialog(wxWindow *parent, const wxFontData& data)
: wxFontDialogBase(parent, data) { Init(); }
virtual ~wxGenericFontDialog();
virtual int ShowModal() override;
// Internal functions
void OnCloseWindow(wxCloseEvent& event);
virtual void CreateWidgets();
virtual void InitializeFont();
void OnChangeFont(wxCommandEvent& event);
#if USE_SPINCTRL_FOR_POINT_SIZE
void OnChangeSize(wxSpinEvent& event);
#endif
protected:
virtual bool DoCreate(wxWindow *parent) override;
private:
// common part of all ctors
void Init();
void DoChangeFont();
wxFont m_dialogFont;
wxChoice *m_familyChoice;
wxChoice *m_styleChoice;
wxChoice *m_weightChoice;
wxChoice *m_colourChoice;
wxCheckBox *m_underLineCheckBox;
#if USE_SPINCTRL_FOR_POINT_SIZE
wxSpinCtrl *m_pointSizeSpin;
#else
wxChoice *m_pointSizeChoice;
#endif
wxFontPreviewer *m_previewer;
bool m_useEvents;
// static bool fontDialogCancelled;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericFontDialog);
};
#endif // _WX_GENERIC_FONTDLGG_H

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/fontpickerg.h
// Purpose: wxGenericFontButton header
// Author: Francesco Montorsi
// Created: 14/4/2006
// Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONTPICKER_H_
#define _WX_FONTPICKER_H_
#include "wx/button.h"
#include "wx/fontdata.h"
//-----------------------------------------------------------------------------
// wxGenericFontButton: a button which brings up a wxFontDialog
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericFontButton : public wxButton,
public wxFontPickerWidgetBase
{
public:
wxGenericFontButton() = default;
wxGenericFontButton(wxWindow *parent,
wxWindowID id,
const wxFont &initial = wxNullFont,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxFONTBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxFontPickerWidgetNameStr))
{
Create(parent, id, initial, pos, size, style, validator, name);
}
virtual wxColour GetSelectedColour() const override
{ return m_data.GetColour(); }
virtual void SetSelectedColour(const wxColour &colour) override
{ m_data.SetColour(colour); UpdateFont(); }
virtual ~wxGenericFontButton() = default;
public: // API extensions specific for wxGenericFontButton
// user can override this to init font data in a different way
virtual void InitFontData();
// returns the font data shown in wxFontDialog
wxFontData *GetFontData() { return &m_data; }
public:
bool Create(wxWindow *parent,
wxWindowID id,
const wxFont &initial = *wxNORMAL_FONT,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxFONTBTN_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxFontPickerWidgetNameStr));
void OnButtonClick(wxCommandEvent &);
protected:
void UpdateFont() override;
wxFontData m_data;
private:
wxDECLARE_DYNAMIC_CLASS(wxGenericFontButton);
};
#endif // _WX_FONTPICKER_H_

View File

@@ -0,0 +1,25 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/fswatcher.h
// Purpose: wxPollingFileSystemWatcher
// Author: Bartosz Bekier
// Created: 2009-05-26
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FSWATCHER_GENERIC_H_
#define _WX_FSWATCHER_GENERIC_H_
#include "wx/defs.h"
#if wxUSE_FSWATCHER
class WXDLLIMPEXP_BASE wxPollingFileSystemWatcher : public wxFileSystemWatcherBase
{
public:
};
#endif // wxUSE_FSWATCHER
#endif /* _WX_FSWATCHER_GENERIC_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,414 @@
///////////////////////////////////////////////////////////////////////////
// Name: wx/generic/gridctrl.h
// Purpose: wxGrid controls
// Author: Paul Gammans, Roger Gammans
// Created: 11/04/2001
// Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_GRIDCTRL_H_
#define _WX_GENERIC_GRIDCTRL_H_
#include "wx/grid.h"
#if wxUSE_GRID
#define wxGRID_VALUE_CHOICEINT wxT("choiceint")
#define wxGRID_VALUE_DATETIME wxT("datetime")
// the default renderer for the cells containing string data
class WXDLLIMPEXP_ADV wxGridCellStringRenderer : public wxGridCellRenderer
{
public:
wxGridCellStringRenderer()
: wxGridCellRenderer()
{
}
wxGridCellStringRenderer(const wxGridCellStringRenderer& other)
: wxGridCellRenderer(other)
{
}
// draw the string
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
// return the string extent
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellStringRenderer(*this); }
protected:
// calc the string extent for given string/font
wxSize DoGetBestSize(const wxGridCellAttr& attr,
wxReadOnlyDC& dc,
const wxString& text);
};
// the default renderer for the cells containing numeric (long) data
class WXDLLIMPEXP_ADV wxGridCellNumberRenderer : public wxGridCellStringRenderer
{
public:
explicit wxGridCellNumberRenderer(long minValue = LONG_MIN,
long maxValue = LONG_MAX)
: wxGridCellStringRenderer(),
m_minValue(minValue),
m_maxValue(maxValue)
{
}
wxGridCellNumberRenderer(const wxGridCellNumberRenderer& other)
: wxGridCellStringRenderer(other),
m_minValue(other.m_minValue),
m_maxValue(other.m_maxValue)
{
}
// draw the string right aligned
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc) override;
// Optional parameters for this renderer are "<min>,<max>".
virtual void SetParameters(const wxString& params) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellNumberRenderer(*this); }
protected:
wxString GetString(const wxGrid& grid, int row, int col);
long m_minValue,
m_maxValue;
};
class WXDLLIMPEXP_ADV wxGridCellFloatRenderer : public wxGridCellStringRenderer
{
public:
wxGridCellFloatRenderer(int width = -1,
int precision = -1,
int format = wxGRID_FLOAT_FORMAT_DEFAULT);
wxGridCellFloatRenderer(const wxGridCellFloatRenderer& other)
: wxGridCellStringRenderer(other),
m_width(other.m_width),
m_precision(other.m_precision),
m_style(other.m_style),
m_format(other.m_format)
{
}
// get/change formatting parameters
int GetWidth() const { return m_width; }
void SetWidth(int width) { m_width = width; m_format.clear(); }
int GetPrecision() const { return m_precision; }
void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
int GetFormat() const { return m_style; }
void SetFormat(int format) { m_style = format; m_format.clear(); }
// draw the string right aligned with given width/precision
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
// parameters string format is "width[,precision[,format]]"
// with format being one of f|e|g|E|F|G
virtual void SetParameters(const wxString& params) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellFloatRenderer(*this); }
protected:
wxString GetString(const wxGrid& grid, int row, int col);
private:
// formatting parameters
int m_width,
m_precision;
int m_style;
wxString m_format;
};
// renderer for boolean fields
class WXDLLIMPEXP_ADV wxGridCellBoolRenderer : public wxGridCellRenderer
{
public:
wxGridCellBoolRenderer()
: wxGridCellRenderer()
{
}
wxGridCellBoolRenderer(const wxGridCellBoolRenderer& other)
: wxGridCellRenderer(other)
{
}
// draw a check mark or nothing
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
// return the checkmark size
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellBoolRenderer(*this); }
};
#if wxUSE_DATETIME
#include "wx/datetime.h"
namespace wxGridPrivate { class DateParseParams; }
// renderer for the cells containing dates only, without time component
class WXDLLIMPEXP_ADV wxGridCellDateRenderer : public wxGridCellStringRenderer
{
public:
explicit wxGridCellDateRenderer(const wxString& outformat = wxString());
wxGridCellDateRenderer(const wxGridCellDateRenderer& other)
: wxGridCellStringRenderer(other),
m_oformat(other.m_oformat),
m_tz(other.m_tz)
{
}
// draw the string right aligned
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellDateRenderer(*this); }
// output strptime()-like format string
virtual void SetParameters(const wxString& params) override;
protected:
wxString GetString(const wxGrid& grid, int row, int col);
// This is overridden in wxGridCellDateTimeRenderer which uses a separate
// input format and forbids fallback to ParseDate().
virtual void
GetDateParseParams(wxGridPrivate::DateParseParams& params) const;
wxString m_oformat;
wxDateTime::TimeZone m_tz;
};
// the default renderer for the cells containing times and dates
class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellDateRenderer
{
public:
wxGridCellDateTimeRenderer(const wxString& outformat = wxASCII_STR(wxDefaultDateTimeFormat),
const wxString& informat = wxASCII_STR(wxDefaultDateTimeFormat));
wxGridCellDateTimeRenderer(const wxGridCellDateTimeRenderer& other)
: wxGridCellDateRenderer(other),
m_iformat(other.m_iformat)
{
}
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellDateTimeRenderer(*this); }
protected:
virtual void
GetDateParseParams(wxGridPrivate::DateParseParams& params) const override;
wxString m_iformat;
};
#endif // wxUSE_DATETIME
// Renderer for fields taking one of a limited set of values: this is the same
// as the renderer for strings, except that it can implement GetMaxBestSize().
class WXDLLIMPEXP_ADV wxGridCellChoiceRenderer : public wxGridCellStringRenderer
{
public:
explicit wxGridCellChoiceRenderer(const wxString& choices = wxString());
wxGridCellChoiceRenderer(const wxGridCellChoiceRenderer& other);
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc) override;
// Parameters string is a comma-separated list of values.
virtual void SetParameters(const wxString& params) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{
return new wxGridCellChoiceRenderer(*this);
}
protected:
wxArrayString m_choices;
};
// renders a number using the corresponding text string
class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellChoiceRenderer
{
public:
explicit wxGridCellEnumRenderer(const wxString& choices = wxString())
: wxGridCellChoiceRenderer(choices)
{
}
wxGridCellEnumRenderer(const wxGridCellEnumRenderer& other)
: wxGridCellChoiceRenderer(other)
{
}
// draw the string right aligned
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellEnumRenderer(*this); }
protected:
wxString GetString(const wxGrid& grid, int row, int col);
};
class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
{
public:
wxGridCellAutoWrapStringRenderer()
: wxGridCellStringRenderer()
{
}
wxGridCellAutoWrapStringRenderer(const wxGridCellAutoWrapStringRenderer& other)
: wxGridCellStringRenderer(other)
{
}
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected) override;
virtual wxSize GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col) override;
virtual int GetBestHeight(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int width) override;
virtual int GetBestWidth(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int height) override;
wxNODISCARD virtual wxGridCellRenderer *Clone() const override
{ return new wxGridCellAutoWrapStringRenderer(*this); }
private:
wxArrayString GetTextLines( wxGrid& grid,
wxReadOnlyDC& dc,
const wxGridCellAttr& attr,
const wxRect& rect,
int row, int col);
// Helper methods of GetTextLines()
// Break a single logical line of text into several physical lines, all of
// which are added to the lines array. The lines are broken at maxWidth and
// the dc is used for measuring text extent only.
void BreakLine(wxReadOnlyDC& dc,
const wxString& logicalLine,
wxCoord maxWidth,
wxArrayString& lines);
// Break a word, which is supposed to be wider than maxWidth, into several
// lines, which are added to lines array and the last, incomplete, of which
// is returned in line output parameter.
//
// Returns the width of the last line.
wxCoord BreakWord(wxReadOnlyDC& dc,
const wxString& word,
wxCoord maxWidth,
wxArrayString& lines,
wxString& line);
};
#endif // wxUSE_GRID
#endif // _WX_GENERIC_GRIDCTRL_H_

View File

@@ -0,0 +1,501 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/grideditors.h
// Purpose: wxGridCellEditorEvtHandler and wxGrid editors
// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
// Modified by: Santiago Palacios
// Created: 1/08/1999
// Copyright: (c) Michael Bedward
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_GRID_EDITORS_H_
#define _WX_GENERIC_GRID_EDITORS_H_
#include "wx/defs.h"
#if wxUSE_GRID
#if wxUSE_VALIDATORS
#include <memory>
#endif
class wxGridCellEditorEvtHandler : public wxEvtHandler
{
public:
wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor)
: m_grid(grid),
m_editor(editor),
m_inSetFocus(false)
{
}
void DismissEditor();
void OnKillFocus(wxFocusEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnChar(wxKeyEvent& event);
void SetInSetFocus(bool inSetFocus) { m_inSetFocus = inSetFocus; }
private:
wxGrid *m_grid;
wxGridCellEditor *m_editor;
// Work around the fact that a focus kill event can be sent to
// a combobox within a set focus event.
bool m_inSetFocus;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler);
wxDECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler);
};
#if wxUSE_TEXTCTRL
// the editor for string/text data
class WXDLLIMPEXP_ADV wxGridCellTextEditor : public wxGridCellEditor
{
public:
explicit wxGridCellTextEditor(size_t maxChars = 0)
: wxGridCellEditor(),
m_maxChars(maxChars)
{
}
wxGridCellTextEditor(const wxGridCellTextEditor& other);
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual void SetSize(const wxRect& rect) override;
virtual bool IsAcceptedKey(wxKeyEvent& event) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
virtual void StartingKey(wxKeyEvent& event) override;
virtual void HandleReturn(wxKeyEvent& event) override;
// parameters string format is "max_width"
virtual void SetParameters(const wxString& params) override;
#if wxUSE_VALIDATORS
virtual void SetValidator(const wxValidator& validator);
#endif
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellTextEditor(*this); }
// added GetValue so we can get the value which is in the control
virtual wxString GetValue() const override;
protected:
wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
// parts of our virtual functions reused by the derived classes
void DoCreate(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler,
long style = 0);
void DoBeginEdit(const wxString& startValue);
void DoReset(const wxString& startValue);
private:
size_t m_maxChars; // max number of chars allowed
#if wxUSE_VALIDATORS
std::unique_ptr<wxValidator> m_validator;
#endif
wxString m_value;
};
// the editor for numeric (long) data
class WXDLLIMPEXP_ADV wxGridCellNumberEditor : public wxGridCellTextEditor
{
public:
// allows to specify the range - if min == max == -1, no range checking is
// done
explicit wxGridCellNumberEditor(int min = -1, int max = -1)
: wxGridCellTextEditor(),
m_min(min),
m_max(max),
m_value(0L)
{
}
wxGridCellNumberEditor(const wxGridCellNumberEditor& other)
: wxGridCellTextEditor(other),
m_min(other.m_min),
m_max(other.m_max),
m_value(other.m_value)
{
}
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual void SetSize(const wxRect& rect) override;
virtual bool IsAcceptedKey(wxKeyEvent& event) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
virtual void StartingKey(wxKeyEvent& event) override;
// parameters string format is "min,max"
virtual void SetParameters(const wxString& params) override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellNumberEditor(*this); }
// added GetValue so we can get the value which is in the control
virtual wxString GetValue() const override;
protected:
#if wxUSE_SPINCTRL
wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
#endif
// if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
bool HasRange() const
{
#if wxUSE_SPINCTRL
return m_min != m_max;
#else
return false;
#endif
}
// string representation of our value
wxString GetString() const
{ return wxString::Format(wxT("%ld"), m_value); }
private:
int m_min,
m_max;
long m_value;
};
enum wxGridCellFloatFormat
{
// Decimal floating point (%f)
wxGRID_FLOAT_FORMAT_FIXED = 0x0010,
// Scientific notation (mantise/exponent) using e character (%e)
wxGRID_FLOAT_FORMAT_SCIENTIFIC = 0x0020,
// Use the shorter of %e or %f (%g)
wxGRID_FLOAT_FORMAT_COMPACT = 0x0040,
// To use in combination with one of the above formats (%F/%E/%G)
wxGRID_FLOAT_FORMAT_UPPER = 0x0080,
// Format used by default.
wxGRID_FLOAT_FORMAT_DEFAULT = wxGRID_FLOAT_FORMAT_FIXED,
// A mask to extract format from the combination of flags.
wxGRID_FLOAT_FORMAT_MASK = wxGRID_FLOAT_FORMAT_FIXED |
wxGRID_FLOAT_FORMAT_SCIENTIFIC |
wxGRID_FLOAT_FORMAT_COMPACT |
wxGRID_FLOAT_FORMAT_UPPER
};
// the editor for floating point numbers (double) data
class WXDLLIMPEXP_ADV wxGridCellFloatEditor : public wxGridCellTextEditor
{
public:
explicit wxGridCellFloatEditor(int width = -1,
int precision = -1,
int format = wxGRID_FLOAT_FORMAT_DEFAULT)
: wxGridCellTextEditor(),
m_width(width),
m_precision(precision),
m_value(0.0),
m_style(format)
{
}
wxGridCellFloatEditor(const wxGridCellFloatEditor& other)
: wxGridCellTextEditor(other),
m_width(other.m_width),
m_precision(other.m_precision),
m_value(other.m_value),
m_style(other.m_style),
m_format(other.m_format)
{
}
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual bool IsAcceptedKey(wxKeyEvent& event) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
virtual void StartingKey(wxKeyEvent& event) override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellFloatEditor(*this); }
// parameters string format is "width[,precision[,format]]"
// format to choose between f|e|g|E|G (f is used by default)
virtual void SetParameters(const wxString& params) override;
protected:
// string representation of our value
wxString GetString();
private:
int m_width,
m_precision;
double m_value;
int m_style;
wxString m_format;
};
#endif // wxUSE_TEXTCTRL
#if wxUSE_CHECKBOX
// the editor for boolean data
class WXDLLIMPEXP_ADV wxGridCellBoolEditor : public wxGridCellEditor
{
public:
wxGridCellBoolEditor()
: wxGridCellEditor(),
m_value(false)
{
}
wxGridCellBoolEditor(const wxGridCellBoolEditor& other)
: wxGridCellEditor(other),
m_value(other.m_value)
{
}
virtual wxGridActivationResult
TryActivate(int row, int col, wxGrid* grid,
const wxGridActivationSource& actSource) override;
virtual void DoActivate(int row, int col, wxGrid* grid) override;
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual void SetSize(const wxRect& rect) override;
virtual void Show(bool show, wxGridCellAttr *attr = nullptr) override;
virtual bool IsAcceptedKey(wxKeyEvent& event) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
virtual void StartingClick() override;
virtual void StartingKey(wxKeyEvent& event) override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellBoolEditor(*this); }
// added GetValue so we can get the value which is in the control, see
// also UseStringValues()
virtual wxString GetValue() const override;
// set the string values returned by GetValue() for the true and false
// states, respectively
static void UseStringValues(const wxString& valueTrue = wxT("1"),
const wxString& valueFalse = wxString());
// return true if the given string is equal to the string representation of
// true value which we currently use
static bool IsTrueValue(const wxString& value);
protected:
wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
private:
// These functions modify or use m_value.
void SetValueFromGrid(int row, int col, wxGrid* grid);
void SetGridFromValue(int row, int col, wxGrid* grid) const;
wxString GetStringValue() const { return GetStringValue(m_value); }
static
wxString GetStringValue(bool value) { return ms_stringValues[value]; }
bool m_value;
static wxString ms_stringValues[2];
};
#endif // wxUSE_CHECKBOX
#if wxUSE_COMBOBOX
// the editor for string data allowing to choose from the list of strings
class WXDLLIMPEXP_ADV wxGridCellChoiceEditor : public wxGridCellEditor
{
public:
// if !allowOthers, user can't type a string not in choices array
explicit wxGridCellChoiceEditor(size_t count = 0,
const wxString choices[] = nullptr,
bool allowOthers = false);
explicit wxGridCellChoiceEditor(const wxArrayString& choices,
bool allowOthers = false)
: wxGridCellEditor(),
m_choices(choices),
m_allowOthers(allowOthers)
{
}
wxGridCellChoiceEditor(const wxGridCellChoiceEditor& other)
: wxGridCellEditor(other),
m_value(other.m_value),
m_choices(other.m_choices),
m_allowOthers(other.m_allowOthers)
{
}
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual void SetSize(const wxRect& rect) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
// parameters string format is "item1[,item2[...,itemN]]"
virtual void SetParameters(const wxString& params) override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellChoiceEditor(*this); }
// added GetValue so we can get the value which is in the control
virtual wxString GetValue() const override;
protected:
wxComboBox *Combo() const { return (wxComboBox *)m_control; }
void OnComboCloseUp(wxCommandEvent& evt);
wxString m_value;
wxArrayString m_choices;
bool m_allowOthers;
};
#endif // wxUSE_COMBOBOX
#if wxUSE_COMBOBOX
class WXDLLIMPEXP_ADV wxGridCellEnumEditor : public wxGridCellChoiceEditor
{
public:
explicit wxGridCellEnumEditor(const wxString& choices = wxString());
wxGridCellEnumEditor(const wxGridCellEnumEditor& other)
: wxGridCellChoiceEditor(other),
m_index(other.m_index)
{
}
virtual ~wxGridCellEnumEditor() = default;
wxNODISCARD virtual wxGridCellEditor* Clone() const override
{ return new wxGridCellEnumEditor(*this); }
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
private:
long m_index;
};
#endif // wxUSE_COMBOBOX
class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
{
public:
wxGridCellAutoWrapStringEditor()
: wxGridCellTextEditor()
{
}
wxGridCellAutoWrapStringEditor(const wxGridCellAutoWrapStringEditor& other)
: wxGridCellTextEditor(other)
{
}
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellAutoWrapStringEditor(*this); }
};
#if wxUSE_DATEPICKCTRL
class WXDLLIMPEXP_ADV wxGridCellDateEditor : public wxGridCellEditor
{
public:
explicit wxGridCellDateEditor(const wxString& format = wxString());
wxGridCellDateEditor(const wxGridCellDateEditor& other)
: wxGridCellEditor(other),
m_value(other.m_value),
m_format(other.m_format)
{
}
virtual void SetParameters(const wxString& params) override;
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) override;
virtual void SetSize(const wxRect& rect) override;
virtual void BeginEdit(int row, int col, wxGrid* grid) override;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) override;
virtual void ApplyEdit(int row, int col, wxGrid* grid) override;
virtual void Reset() override;
wxNODISCARD virtual wxGridCellEditor *Clone() const override
{ return new wxGridCellDateEditor(*this); }
virtual wxString GetValue() const override;
protected:
wxDatePickerCtrl* DatePicker() const;
private:
wxDateTime m_value;
wxString m_format;
};
#endif // wxUSE_DATEPICKCTRL
#endif // wxUSE_GRID
#endif // _WX_GENERIC_GRID_EDITORS_H_

View File

@@ -0,0 +1,184 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/gridsel.h
// Purpose: wxGridSelection
// Author: Stefan Neis
// Created: 20/02/2000
// Copyright: (c) Stefan Neis
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_GRIDSEL_H_
#define _WX_GENERIC_GRIDSEL_H_
#include "wx/defs.h"
#if wxUSE_GRID
#include "wx/grid.h"
#include "wx/vector.h"
#include <memory>
// Forward declaration
namespace wxGridPrivate { class SelectionShape; }
using wxSelectionShape = wxGridPrivate::SelectionShape;
wxDEPRECATED_MSG("use wxGridBlockCoordsVector instead")
typedef wxVector<wxGridBlockCoords> wxVectorGridBlockCoords;
// Note: for all eventType arguments of the methods of this class wxEVT_NULL
// may be passed to forbid events generation completely.
class WXDLLIMPEXP_CORE wxGridSelection
{
public:
wxGridSelection(wxGrid *grid,
wxGrid::wxGridSelectionModes sel = wxGrid::wxGridSelectCells);
bool IsSelection();
bool IsInSelection(int row, int col) const;
bool IsInSelection(const wxGridCellCoords& coords) const
{
return IsInSelection(coords.GetRow(), coords.GetCol());
}
void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; }
void SelectRow(int row, const wxKeyboardState& kbd = wxKeyboardState());
void SelectCol(int col, const wxKeyboardState& kbd = wxKeyboardState());
void SelectBlock(int topRow, int leftCol,
int bottomRow, int rightCol,
const wxKeyboardState& kbd = wxKeyboardState(),
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
void SelectBlock(const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
const wxKeyboardState& kbd = wxKeyboardState(),
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED)
{
SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
bottomRight.GetRow(), bottomRight.GetCol(),
kbd, eventType);
}
// This function replaces all the existing selected blocks (which become
// redundant) with a single block covering the entire grid.
void SelectAll();
void DeselectBlock(const wxGridBlockCoords& block,
const wxKeyboardState& kbd = wxKeyboardState(),
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
// Note that this method refreshes the previously selected blocks and sends
// an event about the selection change.
void ClearSelection();
void UpdateRows( size_t pos, int numRows );
void UpdateCols( size_t pos, int numCols );
// Extend (or shrink) the current selection block (creating it if
// necessary, i.e. if there is no selection at all currently or if the
// current cell isn't selected, as in this case a new block
// containing it is always added) to the one specified by the start and end
// coordinates of its opposite corners (which don't have to be in
// top/bottom left/right order).
//
// Note that blockStart is equal to wxGrid::m_currentCellCoords almost
// always, but not always (the exception is when we scrolled out from
// the top of the grid and select a column or scrolled right and select
// a row: in this case the lowest visible row/column will be set as
// current, not the first one).
//
// Both components of both blockStart and blockEnd must be valid.
//
// This function sends an event notifying about the selection change using
// the provided event type, which is wxEVT_GRID_RANGE_SELECTED by default,
// but may also be wxEVT_GRID_RANGE_SELECTING, when the selection is not
// final yet.
//
// Return true if the current block was actually changed.
bool ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd,
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
// Return the coordinates of the cell from which the selection should
// continue to be extended. This is normally the opposite corner of the
// last selected block from the current cell coordinates.
//
// If there is no selection, just returns the current cell coordinates.
wxGridCellCoords GetExtensionAnchor() const;
wxGridCellCoordsArray GetCellSelection() const;
wxGridCellCoordsArray GetBlockSelectionTopLeft() const;
wxGridCellCoordsArray GetBlockSelectionBottomRight() const;
wxArrayInt GetRowSelection() const;
wxArrayInt GetColSelection() const;
const wxGridBlockCoordsVector& GetBlocks() const { return m_selection; }
void EndSelecting();
void CancelSelecting();
// Return the SelectionShape object. Call ComputeSelectionShape() if necessary.
const wxSelectionShape& GetSelectionShape(const wxRect& renderExtent);
void InvalidateSelectionShape();
private:
void SelectBlockNoEvent(const wxGridBlockCoords& block)
{
SelectBlock(block.GetTopRow(), block.GetLeftCol(),
block.GetBottomRow(), block.GetRightCol(),
wxKeyboardState(), wxEVT_NULL);
}
// Really select the block and don't check for the current selection mode.
void Select(const wxGridBlockCoords& block,
const wxKeyboardState& kbd,
wxEventType eventType);
// Ensure that the new "block" becomes part of "blocks", adding it to them
// if necessary and, if we do it, also removing any existing elements of
// "blocks" that become unnecessary because they're entirely contained in
// the new "block". However note that we may also not to have to add it at
// all, if it's already contained in one of the existing blocks.
//
// We don't currently check if the new block is contained by several
// existing blocks, as this would be more difficult and doesn't seem to be
// really needed in practice.
void MergeOrAddBlock(wxGridBlockCoordsVector& blocks,
const wxGridBlockCoords& block);
// Called each time the selection changed or scrolled to recompute m_selectionShape.
void ComputeSelectionShape(const wxRect& renderExtent = {});
// All currently selected blocks. We expect there to be a relatively small
// amount of them, even for very large grids, as each block must be
// selected by the user, so we store them unsorted.
//
// Selection may be empty, but if it isn't, the last block is special, as
// it is the current block, which is affected by operations such as
// extending the current selection from keyboard.
wxGridBlockCoordsVector m_selection;
wxGrid *m_grid;
wxGrid::wxGridSelectionModes m_selectionMode;
// Used by wxGrid::DrawOverlaySelection() to draw a:
//
// - Simple rectangle (using wxDC::DrawRectangle() if it is empty and the bounding box is valid.
// - Simple polygon (using wxDC::DrawPolygon()) if it represents a simple polygon.
// - Poly-polygon (using wxDC::DrawPolyPolygon()) if it consists of multiple polygons.
//
std::unique_ptr<wxSelectionShape> m_selectionShape;
// See ComputeSelectionShape() definition for explanation.
bool m_updateHighlightedLabels = false;
wxDECLARE_NO_COPY_CLASS(wxGridSelection);
};
#endif // wxUSE_GRID
#endif // _WX_GENERIC_GRIDSEL_H_

View File

@@ -0,0 +1,186 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/headerctrlg.h
// Purpose: Generic wxHeaderCtrl implementation
// Author: Vadim Zeitlin
// Created: 2008-12-01
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_HEADERCTRLG_H_
#define _WX_GENERIC_HEADERCTRLG_H_
#include "wx/event.h"
#include "wx/vector.h"
#include "wx/overlay.h"
// ----------------------------------------------------------------------------
// wxHeaderCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
{
public:
wxHeaderCtrl()
{
Init();
}
wxHeaderCtrl(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHD_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxHeaderCtrlNameStr))
{
Init();
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHD_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxHeaderCtrlNameStr));
virtual ~wxHeaderCtrl();
protected:
virtual wxSize DoGetBestSize() const override;
private:
// implement base class pure virtuals
virtual void DoSetCount(unsigned int count) override;
virtual unsigned int DoGetCount() const override;
virtual void DoUpdate(unsigned int idx) override;
virtual void DoScrollHorz(int dx) override;
virtual void DoSetColumnsOrder(const wxArrayInt& order) override;
virtual wxArrayInt DoGetColumnsOrder() const override;
// common part of all ctors
void Init();
// event handlers
void OnPaint(wxPaintEvent& event);
void OnMouse(wxMouseEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnCaptureLost(wxMouseCaptureLostEvent& event);
// move the column with given idx at given position (this doesn't generate
// any events but does refresh the display)
void DoMoveCol(unsigned int idx, unsigned int pos);
// return the horizontal start position of the given column in physical
// coordinates
int GetColStart(unsigned int idx) const;
// and the end position
int GetColEnd(unsigned int idx) const;
// refresh the given column [only]; idx must be valid
void RefreshCol(unsigned int idx);
// refresh the given column if idx is valid
void RefreshColIfNotNone(unsigned int idx);
// refresh all the controls starting from (and including) the given one
void RefreshColsAfter(unsigned int idx);
// return the column at the given position or -1 if it is beyond the
// rightmost column and put true into onSeparator output parameter if the
// position is near the divider at the right end of this column (notice
// that this means that we return column 0 even if the position is over
// column 1 but close enough to the divider separating it from column 0)
unsigned int FindColumnAtPoint(int x, bool *onSeparator = nullptr) const;
// return the result of FindColumnAtPoint() if it is a valid column,
// otherwise the index of the last (rightmost) displayed column
unsigned int FindColumnClosestToPoint(int xPhysical) const;
// return true if a drag resizing operation is currently in progress
bool IsResizing() const;
// return true if a drag reordering operation is currently in progress
bool IsReordering() const;
// return true if any drag operation is currently in progress
bool IsDragging() const { return IsResizing() || IsReordering(); }
// end any drag operation currently in progress (resizing or reordering)
void EndDragging();
// cancel the drag operation currently in progress and generate an event
// about it
void CancelDragging();
// start (if m_colBeingResized is -1) or continue resizing the column
//
// this generates wxEVT_HEADER_BEGIN_RESIZE/RESIZING events and can
// cancel the operation if the user handler decides so
void StartOrContinueResizing(unsigned int col, int xPhysical);
// end the resizing operation currently in progress and generate an event
// about it with its cancelled flag set if xPhysical is -1
void EndResizing(int xPhysical);
// same functions as above but for column moving/reordering instead of
// resizing
void StartReordering(unsigned int col, int xPhysical);
// returns true if we did drag the column somewhere else or false if we
// didn't really move it -- in this case we consider that no reordering
// took place and that a normal column click event should be generated
bool EndReordering(int xPhysical);
// constrain the given position to be larger than the start position of the
// given column plus its minimal width and return the effective width
int ConstrainByMinWidth(unsigned int col, int& xPhysical);
// update the information displayed while a column is being moved around
void UpdateReorderingMarker(int xPhysical);
// clear any overlaid markers
void ClearMarkers();
// number of columns in the control currently
unsigned int m_numColumns;
// index of the column under mouse or -1 if none
unsigned int m_hover;
// the column being resized or -1 if there is no resizing operation in
// progress
unsigned int m_colBeingResized;
// the column being moved or -1 if there is no reordering operation in
// progress
unsigned int m_colBeingReordered;
// the distance from the start of m_colBeingReordered and the mouse
// position when the user started to drag it
int m_dragOffset;
// the horizontal scroll offset
int m_scrollOffset;
// the overlay display used during the dragging operations
wxOverlay m_overlay;
// the indices of the column appearing at the given position on the display
// (its size is always m_numColumns)
wxArrayInt m_colIndices;
bool m_wasSeparatorDClick;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
};
#endif // _WX_GENERIC_HEADERCTRLG_H_

View File

@@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/helpext.h
// Purpose: an external help controller for wxWidgets
// Author: Karsten Ballueder (Ballueder@usa.net)
// Copyright: (c) Karsten Ballueder 1998
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_HELPEXT_H_
#define __WX_HELPEXT_H_
#if wxUSE_HELP
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/helpbase.h"
// ----------------------------------------------------------------------------
// wxExtHelpController
// ----------------------------------------------------------------------------
// This class implements help via an external browser.
class WXDLLIMPEXP_ADV wxExtHelpController : public wxHelpControllerBase
{
public:
wxExtHelpController(wxWindow* parentWindow = nullptr);
virtual ~wxExtHelpController();
// Set viewer: new name for SetBrowser
virtual void SetViewer(const wxString& viewer = wxEmptyString,
long flags = wxHELP_NETSCAPE) override;
virtual bool Initialize(const wxString& dir, int WXUNUSED(server)) override
{ return Initialize(dir); }
virtual bool Initialize(const wxString& dir) override;
virtual bool LoadFile(const wxString& file = wxEmptyString) override;
virtual bool DisplayContents() override;
virtual bool DisplaySection(int sectionNo) override;
virtual bool DisplaySection(const wxString& section) override;
virtual bool DisplayBlock(long blockNo) override;
virtual bool KeywordSearch(const wxString& k,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL) override;
virtual bool Quit() override;
virtual void OnQuit() override;
virtual bool DisplayHelp(const wxString &) ;
virtual void SetFrameParameters(const wxString& WXUNUSED(title),
const wxSize& WXUNUSED(size),
const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
bool WXUNUSED(newFrameEachTime) = false) override
{
// does nothing by default
}
virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = nullptr,
wxPoint *WXUNUSED(pos) = nullptr,
bool *WXUNUSED(newFrameEachTime) = nullptr) override
{
return nullptr; // does nothing by default
}
protected:
// Filename of currently active map file.
wxString m_helpDir;
// How many entries do we have in the map file?
int m_NumOfEntries;
// A list containing all id,url,documentation triples.
wxList *m_MapList;
private:
// parse a single line of the map file (called by LoadFile())
//
// return true if the line was valid or false otherwise
bool ParseMapFileLine(const wxString& line);
// Deletes the list and all objects.
void DeleteList();
// How to call the html viewer.
wxString m_BrowserName;
// Is the viewer a variant of netscape?
bool m_BrowserIsNetscape;
wxDECLARE_CLASS(wxExtHelpController);
};
#endif // wxUSE_HELP
#endif // __WX_HELPEXT_H_

View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/hyperlink.h
// Purpose: Hyperlink control
// Author: David Norris <danorris@gmail.com>, Otto Wyss
// Modified by: Ryan Norton, Francesco Montorsi
// Created: 04/02/2005
// Copyright: (c) 2005 David Norris
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERICHYPERLINKCTRL_H_
#define _WX_GENERICHYPERLINKCTRL_H_
// ----------------------------------------------------------------------------
// wxGenericHyperlinkCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGenericHyperlinkCtrl : public wxHyperlinkCtrlBase
{
public:
// Default constructor (for two-step construction).
wxGenericHyperlinkCtrl() { Init(); }
// Constructor.
wxGenericHyperlinkCtrl(wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& url,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHL_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxHyperlinkCtrlNameStr))
{
Init();
(void) Create(parent, id, label, url, pos, size, style, name);
}
// Creation function (for two-step construction).
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& url,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHL_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxHyperlinkCtrlNameStr));
// get/set
wxColour GetHoverColour() const override { return m_hoverColour; }
void SetHoverColour(const wxColour &colour) override { m_hoverColour = colour; }
wxColour GetNormalColour() const override { return m_normalColour; }
void SetNormalColour(const wxColour &colour) override;
wxColour GetVisitedColour() const override { return m_visitedColour; }
void SetVisitedColour(const wxColour &colour) override;
wxString GetURL() const override { return m_url; }
void SetURL (const wxString &url) override { m_url=url; }
void SetVisited(bool visited = true) override { m_visited=visited; }
bool GetVisited() const override { return m_visited; }
// NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour,
// wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
// overridden/inherited wxWindow methods
virtual wxVisualAttributes GetDefaultAttributes() const override;
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
protected:
// Helper used by this class itself and native MSW implementation that
// connects OnRightUp() and OnPopUpCopy() handlers.
void ConnectMenuHandlers();
// event handlers
// Renders the hyperlink.
void OnPaint(wxPaintEvent& event);
// Handle set/kill focus events (invalidate for painting focus rect)
void OnFocus(wxFocusEvent& event);
// Fire a HyperlinkEvent on space
void OnChar(wxKeyEvent& event);
// Returns the wxRect of the label of this hyperlink.
// This is different from the clientsize's rectangle when
// clientsize != bestsize and this rectangle is influenced
// by the alignment of the label (wxHL_ALIGN_*).
wxRect GetLabelRect() const;
// If the click originates inside the bounding box of the label,
// a flag is set so that an event will be fired when the left
// button is released.
void OnLeftDown(wxMouseEvent& event);
// If the click both originated and finished inside the bounding box
// of the label, a HyperlinkEvent is fired.
void OnLeftUp(wxMouseEvent& event);
void OnRightUp(wxMouseEvent& event);
// Changes the cursor to a hand, if the mouse is inside the label's
// bounding box.
void OnMotion(wxMouseEvent& event);
// Changes the cursor back to the default, if necessary.
void OnLeaveWindow(wxMouseEvent& event);
// handles "Copy URL" menuitem
void OnPopUpCopy(wxCommandEvent& event);
// overridden base class virtuals
// Returns the best size for the window, which is the size needed
// to display the text label.
virtual wxSize DoGetBestClientSize() const override;
// creates a context menu with "Copy URL" menuitem
virtual void DoContextMenu(const wxPoint &);
private:
// Common part of all ctors.
void Init();
// URL associated with the link. This is transmitted inside
// the HyperlinkEvent fired when the user clicks on the label.
wxString m_url;
// Foreground colours for various link types.
// NOTE: wxWindow::m_backgroundColour is used for background,
// wxWindow::m_foregroundColour is used to render non-visited links
wxColour m_hoverColour;
wxColour m_normalColour;
wxColour m_visitedColour;
// True if the mouse cursor is inside the label's bounding box.
bool m_rollover;
// True if the link has been clicked before.
bool m_visited;
// True if a click is in progress (left button down) and the click
// originated inside the label's bounding box.
bool m_clicking;
};
#endif // _WX_GENERICHYPERLINKCTRL_H_

View File

@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/icon.h
// Purpose: wxIcon implementation for ports where it's same as wxBitmap
// Author: Julian Smart
// Created: 17/09/98
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_ICON_H_
#define _WX_GENERIC_ICON_H_
#include "wx/bitmap.h"
//-----------------------------------------------------------------------------
// wxIcon
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxIcon: public wxBitmap
{
public:
wxIcon() = default;
wxIcon(const char* const* bits) : wxBitmap(bits) { }
// For compatibility with wxMSW where desired size is sometimes required to
// distinguish between multiple icons in a resource.
wxIcon( const wxString& filename,
wxBitmapType type = wxICON_DEFAULT_TYPE,
int WXUNUSED(desiredWidth)=-1, int WXUNUSED(desiredHeight)=-1 ) :
wxBitmap(filename, type)
{
}
wxIcon(const wxIconLocation& loc)
: wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_ANY)
{
}
bool LoadFile(const wxString& name, wxBitmapType flags,
int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
{ return wxBitmap::LoadFile(name, flags); }
// unhide the base class version
virtual bool LoadFile(const wxString& name,
wxBitmapType flags = wxICON_DEFAULT_TYPE) override
{ return wxBitmap::LoadFile(name, flags); }
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
// ctors, assignment operators...), but it's ok to have such function
void CopyFromBitmap(const wxBitmap& bmp)
{
if ( &bmp != this )
Ref(bmp);
}
wxDECLARE_VARIANT_OBJECT_EXPORTED(wxIcon, WXDLLIMPEXP_CORE);
private:
wxDECLARE_DYNAMIC_CLASS(wxIcon);
};
#endif // _WX_GENERIC_ICON_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/imaglist.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_IMAGLISTG_H_
#define _WX_IMAGLISTG_H_
#include "wx/gdicmn.h"
#include "wx/vector.h"
class WXDLLIMPEXP_CORE wxGenericImageList : public wxImageListBase
{
public:
wxGenericImageList();
wxGenericImageList( int width, int height, bool mask = true, int initialCount = 1 );
virtual ~wxGenericImageList();
bool Create( int width, int height, bool mask = true, int initialCount = 1 );
virtual void Destroy() override;
virtual int GetImageCount() const override;
virtual bool GetSize( int index, int &width, int &height ) const override;
using wxImageListBase::GetSize;
virtual int Add( const wxBitmap& bitmap ) override;
virtual int Add( const wxBitmap& bitmap, const wxBitmap& mask ) override;
virtual int Add( const wxBitmap& bitmap, const wxColour& maskColour ) override;
virtual wxBitmap GetBitmap(int index) const override;
virtual wxIcon GetIcon(int index) const override;
virtual bool Replace( int index,
const wxBitmap& bitmap,
const wxBitmap& mask = wxNullBitmap ) override;
virtual bool Remove( int index ) override;
virtual bool RemoveAll() override;
virtual bool Draw(int index, wxDC& dc, int x, int y,
int flags = wxIMAGELIST_DRAW_NORMAL,
bool solidBackground = false) override;
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("Don't use this overload: it's not portable and does nothing")
bool Create() { return true; }
wxDEPRECATED_MSG("Use GetBitmap() instead")
const wxBitmap *GetBitmapPtr(int index) const { return DoGetPtr(index); }
#endif // WXWIN_COMPATIBILITY_3_0
private:
const wxBitmap *DoGetPtr(int index) const;
wxBitmap GetImageListBitmap(const wxBitmap& bitmap) const;
wxVector<wxBitmap> m_images;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericImageList);
};
#ifndef wxHAS_NATIVE_IMAGELIST
/*
* wxImageList has to be a real class or we have problems with
* the run-time information.
*/
class WXDLLIMPEXP_CORE wxImageList: public wxGenericImageList
{
wxDECLARE_DYNAMIC_CLASS(wxImageList);
public:
using wxGenericImageList::wxGenericImageList;
};
#endif // !wxHAS_NATIVE_IMAGELIST
#endif // _WX_IMAGLISTG_H_

View File

@@ -0,0 +1,158 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/infobar.h
// Purpose: generic wxInfoBar class declaration
// Author: Vadim Zeitlin
// Created: 2009-07-28
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_INFOBAR_H_
#define _WX_GENERIC_INFOBAR_H_
class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
class WXDLLIMPEXP_FWD_CORE wxStaticBitmap;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
// ----------------------------------------------------------------------------
// wxInfoBar
// ----------------------------------------------------------------------------
enum
{
wxINFOBAR_CHECKBOX = 0x0010
};
class WXDLLIMPEXP_CORE wxInfoBarGeneric : public wxInfoBarBase
{
public:
// the usual ctors and Create() but remember that info bar is created
// hidden
wxInfoBarGeneric() { Init(); }
wxInfoBarGeneric(wxWindow *parent, wxWindowID winid = wxID_ANY, long style = 0)
{
Init();
Create(parent, winid, style);
}
bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY, long style = 0);
// implement base class methods
// ----------------------------
virtual void ShowMessage(const wxString& msg,
int flags = wxICON_INFORMATION) override;
virtual void Dismiss() override;
virtual void AddButton(wxWindowID btnid, const wxString& label = wxString()) override;
virtual void RemoveButton(wxWindowID btnid) override;
virtual size_t GetButtonCount() const override;
virtual wxWindowID GetButtonId(size_t idx) const override;
virtual bool HasButtonId(wxWindowID btnid) const override;
// methods specific to this version
// --------------------------------
// set the effect(s) to use when showing/hiding the bar, may be
// wxSHOW_EFFECT_NONE to disable any effects entirely
//
// by default, slide to bottom/top is used when it's positioned on the top
// of the window for showing/hiding it and top/bottom when it's positioned
// at the bottom
void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect)
{
m_showEffect = showEffect;
m_hideEffect = hideEffect;
}
// get effect used when showing/hiding the window
wxShowEffect GetShowEffect() const;
wxShowEffect GetHideEffect() const;
// set the duration of animation used when showing/hiding the bar, in ms
void SetEffectDuration(int duration) { m_effectDuration = duration; }
// get the currently used effect animation duration
int GetEffectDuration() const { return m_effectDuration; }
// Whether the checkbox was checked at the time of the window
// being closed.
// This should be called in a client's handler for the
// wxID_CLOSE button being clicked.
bool IsCheckBoxChecked() const { return m_checked; }
// Sets whether the checkbox should be shown.
void ShowCheckBox(const wxString& checkBoxText, bool checked);
// overridden base class methods
// -----------------------------
// setting the font of this window sets it for the text control inside it
// (default font is a larger and bold version of the normal one)
virtual bool SetFont(const wxFont& font) override;
// same thing with the colour: this affects the text colour
virtual bool SetForegroundColour(const wxColor& colour) override;
protected:
// info bar shouldn't have any border by default, the colour difference
// between it and the main window separates it well enough
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
// update the parent to take our new or changed size into account (notably
// should be called when we're shown or hidden)
void UpdateParent();
private:
// common part of all ctors
void Init();
virtual bool UseNative() const { return false; }
// handler for the close button
void OnButton(wxCommandEvent& event);
// show/hide the bar
void DoShow();
void DoHide();
// determine the placement of the bar from its position in the containing
// sizer
enum BarPlacement
{
BarPlacement_Top,
BarPlacement_Bottom,
BarPlacement_Unknown
};
BarPlacement GetBarPlacement() const;
// different controls making up the bar
wxStaticBitmap *m_icon = nullptr;
wxStaticText *m_text = nullptr;
wxBitmapButton *m_button = nullptr;
wxCheckBox *m_checkbox = nullptr;
// the effects to use when showing/hiding and duration for them: by default
// the effect is determined by the info bar automatically depending on its
// position and the default duration is used
wxShowEffect m_showEffect,
m_hideEffect;
int m_effectDuration;
bool m_checked = false;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric);
};
#endif // _WX_GENERIC_INFOBAR_H_

View File

@@ -0,0 +1,228 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/laywin.h
// Purpose: Implements a simple layout algorithm, plus
// wxSashLayoutWindow which is an example of a window with
// layout-awareness (via event handlers). This is suited to
// IDE-style window layout.
// Author: Julian Smart
// Created: 04/01/98
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LAYWIN_H_G_
#define _WX_LAYWIN_H_G_
#include "wx/defs.h"
#if wxUSE_SASH
#include "wx/sashwin.h"
#endif // wxUSE_SASH
#include "wx/event.h"
class WXDLLIMPEXP_FWD_CORE wxQueryLayoutInfoEvent;
class WXDLLIMPEXP_FWD_CORE wxCalculateLayoutEvent;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_QUERY_LAYOUT_INFO, wxQueryLayoutInfoEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALCULATE_LAYOUT, wxCalculateLayoutEvent );
enum wxLayoutOrientation
{
wxLAYOUT_HORIZONTAL,
wxLAYOUT_VERTICAL
};
enum wxLayoutAlignment
{
wxLAYOUT_NONE,
wxLAYOUT_TOP,
wxLAYOUT_LEFT,
wxLAYOUT_RIGHT,
wxLAYOUT_BOTTOM
};
// Not sure this is necessary
// Tell window which dimension we're sizing on
#define wxLAYOUT_LENGTH_Y 0x0008
#define wxLAYOUT_LENGTH_X 0x0000
// Use most recently used length
#define wxLAYOUT_MRU_LENGTH 0x0010
// Only a query, so don't actually move it.
#define wxLAYOUT_QUERY 0x0100
/*
* This event is used to get information about window alignment,
* orientation and size.
*/
class WXDLLIMPEXP_CORE wxQueryLayoutInfoEvent: public wxEvent
{
public:
wxQueryLayoutInfoEvent(wxWindowID id = 0)
{
SetEventType(wxEVT_QUERY_LAYOUT_INFO);
m_requestedLength = 0;
m_flags = 0;
m_id = id;
m_alignment = wxLAYOUT_TOP;
m_orientation = wxLAYOUT_HORIZONTAL;
}
// Read by the app
void SetRequestedLength(int length) { m_requestedLength = length; }
int GetRequestedLength() const { return m_requestedLength; }
void SetFlags(int flags) { m_flags = flags; }
int GetFlags() const { return m_flags; }
// Set by the app
void SetSize(const wxSize& size) { m_size = size; }
wxSize GetSize() const { return m_size; }
void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; }
wxLayoutOrientation GetOrientation() const { return m_orientation; }
void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
wxLayoutAlignment GetAlignment() const { return m_alignment; }
wxNODISCARD virtual wxEvent *Clone() const override { return new wxQueryLayoutInfoEvent(*this); }
protected:
int m_flags;
int m_requestedLength;
wxSize m_size;
wxLayoutOrientation m_orientation;
wxLayoutAlignment m_alignment;
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxQueryLayoutInfoEvent);
};
typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&);
#define wxQueryLayoutInfoEventHandler( func ) \
wxEVENT_HANDLER_CAST( wxQueryLayoutInfoEventFunction, func )
#define EVT_QUERY_LAYOUT_INFO(func) \
wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_LAYOUT_INFO, wxID_ANY, wxID_ANY, wxQueryLayoutInfoEventHandler( func ), nullptr ),
/*
* This event is used to take a bite out of the available client area.
*/
class WXDLLIMPEXP_CORE wxCalculateLayoutEvent: public wxEvent
{
public:
wxCalculateLayoutEvent(wxWindowID id = 0)
{
SetEventType(wxEVT_CALCULATE_LAYOUT);
m_flags = 0;
m_id = id;
}
// Read by the app
void SetFlags(int flags) { m_flags = flags; }
int GetFlags() const { return m_flags; }
// Set by the app
void SetRect(const wxRect& rect) { m_rect = rect; }
wxRect GetRect() const { return m_rect; }
wxNODISCARD virtual wxEvent *Clone() const override { return new wxCalculateLayoutEvent(*this); }
protected:
int m_flags;
wxRect m_rect;
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxCalculateLayoutEvent);
};
typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&);
#define wxCalculateLayoutEventHandler( func ) wxEVENT_HANDLER_CAST(wxCalculateLayoutEventFunction, func)
#define EVT_CALCULATE_LAYOUT(func) \
wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_CALCULATE_LAYOUT, wxID_ANY, wxID_ANY, wxCalculateLayoutEventHandler( func ), nullptr ),
#if wxUSE_SASH
// This is window that can remember alignment/orientation, does its own layout,
// and can provide sashes too. Useful for implementing docked windows with sashes in
// an IDE-style interface.
class WXDLLIMPEXP_CORE wxSashLayoutWindow: public wxSashWindow
{
public:
wxSashLayoutWindow()
{
Init();
}
wxSashLayoutWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"))
{
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("layoutWindow"));
// Accessors
inline wxLayoutAlignment GetAlignment() const { return m_alignment; }
inline wxLayoutOrientation GetOrientation() const { return m_orientation; }
inline void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
inline void SetOrientation(wxLayoutOrientation orient) { m_orientation = orient; }
// Give the window default dimensions
inline void SetDefaultSize(const wxSize& size) { m_defaultSize = size; }
// Event handlers
// Called by layout algorithm to allow window to take a bit out of the
// client rectangle, and size itself if not in wxLAYOUT_QUERY mode.
void OnCalculateLayout(wxCalculateLayoutEvent& event);
// Called by layout algorithm to retrieve information about the window.
void OnQueryLayoutInfo(wxQueryLayoutInfoEvent& event);
private:
void Init();
wxLayoutAlignment m_alignment;
wxLayoutOrientation m_orientation;
wxSize m_defaultSize;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxSashLayoutWindow);
wxDECLARE_EVENT_TABLE();
};
#endif // wxUSE_SASH
class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame;
class WXDLLIMPEXP_FWD_CORE wxFrame;
// This class implements the layout algorithm
class WXDLLIMPEXP_CORE wxLayoutAlgorithm: public wxObject
{
public:
wxLayoutAlgorithm() = default;
#if wxUSE_MDI_ARCHITECTURE
// The MDI client window is sized to whatever's left over.
bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = nullptr);
#endif // wxUSE_MDI_ARCHITECTURE
// mainWindow is sized to whatever's left over. This function for backward
// compatibility; use LayoutWindow.
bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = nullptr);
// mainWindow is sized to whatever's left over.
bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = nullptr);
};
#endif
// _WX_LAYWIN_H_G_

View File

@@ -0,0 +1,274 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/listctrl.h
// Purpose: Generic list control
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_LISTCTRL_H_
#define _WX_GENERIC_LISTCTRL_H_
#include "wx/containr.h"
#include "wx/scrolwin.h"
#include "wx/textctrl.h"
#if wxUSE_DRAG_AND_DROP
class WXDLLIMPEXP_FWD_CORE wxDropTarget;
#endif
//-----------------------------------------------------------------------------
// internal classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxListHeaderWindow;
class WXDLLIMPEXP_FWD_CORE wxListMainWindow;
//-----------------------------------------------------------------------------
// wxListCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericListCtrl: public wxNavigationEnabled<wxListCtrlBase>,
public wxScrollHelper
{
typedef wxNavigationEnabled<wxListCtrlBase> BaseType;
public:
wxGenericListCtrl() : wxScrollHelper(this)
{
Init();
}
wxGenericListCtrl( wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxASCII_STR(wxListCtrlNameStr))
: wxScrollHelper(this)
{
Create(parent, winid, pos, size, style, validator, name);
}
virtual ~wxGenericListCtrl();
void Init();
bool Create( wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxASCII_STR(wxListCtrlNameStr));
bool GetColumn( int col, wxListItem& item ) const override;
bool SetColumn( int col, const wxListItem& item ) override;
int GetColumnWidth( int col ) const override;
bool SetColumnWidth( int col, int width) override;
// Column ordering functions
int GetColumnOrder(int col) const override;
int GetColumnIndexFromOrder(int order) const override;
wxArrayInt GetColumnsOrder() const override;
bool SetColumnsOrder(const wxArrayInt& orders) override;
int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
wxRect GetViewRect() const;
bool GetItem( wxListItem& info ) const;
bool SetItem( wxListItem& info ) ;
bool SetItem( long index, int col, const wxString& label, int imageId = -1 );
int GetItemState( long item, long stateMask ) const;
bool SetItemState( long item, long state, long stateMask);
bool SetItemImage( long item, int image, int selImage = -1 );
bool SetItemColumnImage( long item, long column, int image );
wxString GetItemText( long item, int col = 0 ) const;
void SetItemText( long item, const wxString& str );
wxUIntPtr GetItemData( long item ) const;
bool SetItemPtrData(long item, wxUIntPtr data);
bool SetItemData(long item, long data) { return SetItemPtrData(item, data); }
bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
bool GetSubItemRect( long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
bool GetItemPosition( long item, wxPoint& pos ) const;
bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
int GetItemCount() const override;
int GetColumnCount() const override;
void SetItemSpacing( int spacing, bool isSmall = false );
wxSize GetItemSpacing() const;
void SetItemTextColour( long item, const wxColour& col);
wxColour GetItemTextColour( long item ) const;
void SetItemBackgroundColour( long item, const wxColour &col);
wxColour GetItemBackgroundColour( long item ) const;
void SetItemFont( long item, const wxFont &f);
wxFont GetItemFont( long item ) const;
int GetSelectedItemCount() const;
wxColour GetTextColour() const;
void SetTextColour(const wxColour& col);
long GetTopItem() const;
bool HasCheckBoxes() const override;
bool EnableCheckBoxes(bool enable = true) override;
bool IsItemChecked(long item) const override;
void CheckItem(long item, bool check) override;
void ShowSortIndicator(int idx, bool ascending = true) override;
int GetSortIndicator() const override;
bool IsAscendingSortIndicator() const override;
void SetSingleStyle( long style, bool add = true ) ;
void SetWindowStyleFlag( long style ) override;
void RecreateWindow() {}
long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
void ClearAll();
bool DeleteItem( long item );
bool DeleteAllItems();
bool DeleteAllColumns() override;
bool DeleteColumn( int col ) override;
void SetItemCount(long count);
wxTextCtrl *EditLabel(long item,
wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl));
// End label editing, optionally cancelling the edit
bool EndEditLabel(bool cancel);
wxTextCtrl* GetEditControl() const;
bool IsVisible(long item) const override;
void Edit( long item ) { EditLabel(item); }
bool EnsureVisible( long item );
long FindItem( long start, const wxString& str, bool partial = false );
long FindItem( long start, wxUIntPtr data );
long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
long HitTest( const wxPoint& point, int& flags, long *pSubItem = nullptr ) const;
long InsertItem(wxListItem& info);
long InsertItem( long index, const wxString& label );
long InsertItem( long index, int imageIndex );
long InsertItem( long index, const wxString& label, int imageIndex );
bool ScrollList( int dx, int dy );
bool SortItems( wxListCtrlCompare fn, wxIntPtr data );
// do we have a header window?
bool HasHeader() const
{ return InReportView() && !HasFlag(wxLC_NO_HEADER); }
// refresh items selectively (only useful for virtual list controls)
void RefreshItem(long item);
void RefreshItems(long itemFrom, long itemTo);
virtual void EnableBellOnNoMatch(bool on = true) override;
// overridden base class virtuals
// ------------------------------
virtual wxVisualAttributes GetDefaultAttributes() const override
{
return GetClassDefaultAttributes(GetWindowVariant());
}
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
virtual void Update() override;
// implementation only from now on
// -------------------------------
// generic version extension, don't use in portable code
bool Update( long item );
void OnInternalIdle( ) override;
// We have to hand down a few functions
virtual void Refresh(bool eraseBackground = true,
const wxRect *rect = nullptr) override;
virtual bool SetBackgroundColour( const wxColour &colour ) override;
virtual bool SetForegroundColour( const wxColour &colour ) override;
virtual wxColour GetBackgroundColour() const;
virtual wxColour GetForegroundColour() const;
virtual bool SetFont( const wxFont &font ) override;
virtual bool SetCursor( const wxCursor &cursor ) override;
virtual void ExtendRulesAndAlternateColour(bool extend = true) override;
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget ) override;
virtual wxDropTarget *GetDropTarget() const override;
#endif
virtual bool ShouldInheritColours() const override { return false; }
// implementation
// --------------
wxListHeaderWindow *m_headerWin;
wxListMainWindow *m_mainWin;
protected:
// Implement base class pure virtual methods.
long DoInsertColumn(long col, const wxListItem& info) override;
void DoUpdateImages(int which) override;
virtual wxSize DoGetBestClientSize() const override;
// it calls our OnGetXXX() functions
friend class WXDLLIMPEXP_FWD_CORE wxListMainWindow;
virtual wxBorder GetDefaultBorder() const override;
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size) override;
private:
void CreateOrDestroyHeaderWindowAsNeeded();
void OnScroll( wxScrollWinEvent& event );
void OnSize( wxSizeEvent &event );
// we need to return a special WM_GETDLGCODE value to process just the
// arrows but let the other navigation characters through
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
virtual WXLRESULT
MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
#endif // __WXMSW__
WX_FORWARD_TO_SCROLL_HELPER()
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericListCtrl);
};
#if !(defined(__WXMSW__) || defined(__WXQT__)) || defined(__WXUNIVERSAL__ )
/*
* wxListCtrl has to be a real class or we have problems with
* the run-time information.
*/
class WXDLLIMPEXP_CORE wxListCtrl: public wxGenericListCtrl
{
wxDECLARE_DYNAMIC_CLASS(wxListCtrl);
public:
wxListCtrl() = default;
wxListCtrl(wxWindow *parent, wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator &validator = wxDefaultValidator,
const wxString &name = wxASCII_STR(wxListCtrlNameStr))
: wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
{
}
};
#endif // !__WXMSW__ || __WXUNIVERSAL__
#endif // _WX_GENERIC_LISTCTRL_H_

View File

@@ -0,0 +1,157 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/logg.h
// Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
// Author: Vadim Zeitlin
// Created: 29/01/98
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LOGG_H_
#define _WX_LOGG_H_
#if wxUSE_GUI
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxLogFrame;
class WXDLLIMPEXP_FWD_CORE wxWindow;
// ----------------------------------------------------------------------------
// the following log targets are only compiled in if the we're compiling the
// GUI part (andnot just the base one) of the library, they're implemented in
// src/generic/logg.cpp *and not src/common/log.cpp unlike all the rest)
// ----------------------------------------------------------------------------
#if wxUSE_TEXTCTRL
// log everything to a text window (GUI only of course)
class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog
{
public:
wxLogTextCtrl(wxTextCtrl *pTextCtrl);
protected:
// implement sink function
virtual void DoLogText(const wxString& msg) override;
private:
// the control we use
wxTextCtrl *m_pTextCtrl;
wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl);
};
#endif // wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// GUI log target, the default one for wxWidgets programs
// ----------------------------------------------------------------------------
#if wxUSE_LOGGUI
class WXDLLIMPEXP_CORE wxLogGui : public wxLog
{
public:
// ctor has a side effect of installing a custom modal hook flushing the
// logs before showing any modal dialog: we do this to avoid showing the
// log dialog while another modal dialog is showing or, even worse, only
// after it is dismissed
wxLogGui();
// dtor removes the modal hook
virtual ~wxLogGui();
// show all messages that were logged since the last Flush()
virtual void Flush() override;
protected:
virtual void DoLogRecord(wxLogLevel level,
const wxString& msg,
const wxLogRecordInfo& info) override;
// return the title to be used for the log dialog, depending on m_bErrors
// and m_bWarnings values
wxString GetTitle() const;
// return the icon (one of wxICON_XXX constants) to be used for the dialog
// depending on m_bErrors/m_bWarnings
int GetSeverityIcon() const;
// empty everything
void Clear();
wxArrayString m_aMessages; // the log message texts
wxArrayInt m_aSeverity; // one of wxLOG_XXX values
wxArrayLong m_aTimes; // the time of each message
bool m_bErrors, // do we have any errors?
m_bWarnings, // any warnings?
m_bHasMessages; // any messages at all?
private:
// this method is called to show a single log message, it uses
// wxMessageBox() by default
virtual void DoShowSingleLogMessage(const wxString& message,
const wxString& title,
int style);
// this method is called to show multiple log messages, it uses wxLogDialog
virtual void DoShowMultipleLogMessages(const wxArrayString& messages,
const wxArrayInt& severities,
const wxArrayLong& times,
const wxString& title,
int style);
};
#endif // wxUSE_LOGGUI
// ----------------------------------------------------------------------------
// (background) log window: this class forwards all log messages to the log
// target which was active when it was instantiated, but also collects them
// to the log window. This window has its own menu which allows the user to
// close it, clear the log contents or save it to the file.
// ----------------------------------------------------------------------------
#if wxUSE_LOGWINDOW
class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough
{
public:
wxLogWindow(wxWindow *pParent, // the parent frame (can be null)
const wxString& szTitle, // the title of the frame
bool bShow = true, // show window immediately?
bool bPassToOld = true); // pass messages to the old target?
virtual ~wxLogWindow();
// window operations
// show/hide the log window
void Show(bool bShow = true);
// retrieve the pointer to the frame
wxFrame *GetFrame() const;
// overridables
// called if the user closes the window interactively, will not be
// called if it is destroyed for another reason (such as when program
// exits) - return true from here to allow the frame to close, false
// to prevent this from happening
virtual bool OnFrameClose(wxFrame *frame);
// called right before the log frame is going to be deleted: will
// always be called unlike OnFrameClose()
virtual void OnFrameDelete(wxFrame *frame);
protected:
virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg) override;
private:
wxLogFrame *m_pLogFrame; // the log frame
wxDECLARE_NO_COPY_CLASS(wxLogWindow);
};
#endif // wxUSE_LOGWINDOW
#endif // wxUSE_GUI
#endif // _WX_LOGG_H_

View File

@@ -0,0 +1,53 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/mask.h
// Purpose: generic implementation of wxMask
// Author: Vadim Zeitlin
// Created: 2006-09-28
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_MASKG_H_
#define _WX_GENERIC_MASKG_H_
// ----------------------------------------------------------------------------
// generic wxMask implementation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMask : public wxMaskBase
{
public:
wxMask() = default;
wxMask(const wxBitmap& bitmap, const wxColour& colour)
{
InitFromColour(bitmap, colour);
}
#if wxUSE_PALETTE
wxMask(const wxBitmap& bitmap, int paletteIndex)
{
Create(bitmap, paletteIndex);
}
#endif // wxUSE_PALETTE
wxMask(const wxBitmap& bitmap)
{
InitFromMonoBitmap(bitmap);
}
// implementation-only from now on
wxBitmap GetBitmap() const { return m_bitmap; }
private:
// implement wxMaskBase pure virtuals
virtual void FreeData();
virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
wxBitmap m_bitmap;
wxDECLARE_DYNAMIC_CLASS(wxMask);
};
#endif // _WX_GENERIC_MASKG_H_

View File

@@ -0,0 +1,262 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/mdig.h
// Purpose: Generic MDI (Multiple Document Interface) classes
// Author: Hans Van Leemputten
// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
// Created: 29/07/2002
// Copyright: (c) 2002 Hans Van Leemputten
// (c) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_MDIG_H_
#define _WX_GENERIC_MDIG_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/panel.h"
class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxIconBundle;
class WXDLLIMPEXP_FWD_CORE wxNotebook;
#if wxUSE_GENERIC_MDI_AS_NATIVE
#define wxGenericMDIParentFrame wxMDIParentFrame
#define wxGenericMDIChildFrame wxMDIChildFrame
#define wxGenericMDIClientWindow wxMDIClientWindow
#else // !wxUSE_GENERIC_MDI_AS_NATIVE
class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame;
class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame;
class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow;
#endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE
// ----------------------------------------------------------------------------
// wxGenericMDIParentFrame
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericMDIParentFrame : public wxMDIParentFrameBase
{
public:
wxGenericMDIParentFrame() { Init(); }
wxGenericMDIParentFrame(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr));
virtual ~wxGenericMDIParentFrame();
// implement base class pure virtuals
static bool IsTDI() { return true; }
virtual void ActivateNext() { AdvanceActive(true); }
virtual void ActivatePrevious() { AdvanceActive(false); }
#if wxUSE_MENUS
virtual void SetWindowMenu(wxMenu* pMenu);
virtual void SetMenuBar(wxMenuBar *pMenuBar);
#endif // wxUSE_MENUS
virtual wxGenericMDIClientWindow *OnCreateGenericClient();
// implementation only from now on
void WXSetChildMenuBar(wxGenericMDIChildFrame *child);
void WXUpdateChildTitle(wxGenericMDIChildFrame *child);
void WXActivateChild(wxGenericMDIChildFrame *child);
void WXRemoveChild(wxGenericMDIChildFrame *child);
bool WXIsActiveChild(wxGenericMDIChildFrame *child) const;
bool WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const;
// return the book control used by the client window to manage the pages
wxBookCtrlBase *GetBookCtrl() const;
protected:
#if wxUSE_MENUS
wxMenuBar *m_pMyMenuBar;
#endif // wxUSE_MENUS
// advance the activation forward or backwards
void AdvanceActive(bool forward);
private:
void Init();
#if wxUSE_MENUS
void RemoveWindowMenu(wxMenuBar *pMenuBar);
void AddWindowMenu(wxMenuBar *pMenuBar);
void OnWindowMenu(wxCommandEvent& event);
#endif // wxUSE_MENUS
virtual bool ProcessEvent(wxEvent& event);
void OnClose(wxCloseEvent& event);
// return the client window, may be null if we hadn't been created yet
wxGenericMDIClientWindow *GetGenericClientWindow() const;
// close all children, return false if any of them vetoed it
bool CloseAll();
// this pointer is non-null if we're currently inside our ProcessEvent()
// and we forwarded the event to this child (as we do with menu events)
wxMDIChildFrameBase *m_childHandler;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame);
};
// ----------------------------------------------------------------------------
// wxGenericMDIChildFrame
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericMDIChildFrame : public wxTDIChildFrame
{
public:
wxGenericMDIChildFrame() { Init(); }
wxGenericMDIChildFrame(wxGenericMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
bool Create(wxGenericMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
virtual ~wxGenericMDIChildFrame();
// implement MDI operations
virtual void Activate();
#if wxUSE_MENUS
virtual void SetMenuBar( wxMenuBar *menu_bar );
virtual wxMenuBar *GetMenuBar() const;
#endif // wxUSE_MENUS
virtual wxString GetTitle() const { return m_title; }
virtual void SetTitle(const wxString& title);
virtual bool TryAfter(wxEvent& event);
// implementation only from now on
wxGenericMDIParentFrame* GetGenericMDIParent() const
{
#if wxUSE_GENERIC_MDI_AS_NATIVE
return GetMDIParent();
#else // generic != native
return m_mdiParentGeneric;
#endif
}
protected:
wxString m_title;
#if wxUSE_MENUS
wxMenuBar *m_pMenuBar;
#endif // wxUSE_MENUS
#if !wxUSE_GENERIC_MDI_AS_NATIVE
wxGenericMDIParentFrame *m_mdiParentGeneric;
#endif
protected:
void Init();
private:
#if wxUSE_MENUS
void OnMenuHighlight(wxMenuEvent& event);
#endif // wxUSE_MENUS
void OnClose(wxCloseEvent& event);
wxDECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame);
wxDECLARE_EVENT_TABLE();
friend class wxGenericMDIClientWindow;
};
// ----------------------------------------------------------------------------
// wxGenericMDIClientWindow
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericMDIClientWindow : public wxMDIClientWindowBase
{
public:
wxGenericMDIClientWindow() = default;
// unfortunately we need to provide our own version of CreateClient()
// because of the difference in the type of the first parameter and
// implement the base class pure virtual method in terms of it
// (CreateGenericClient() is virtual itself to allow customizing the client
// window creation by overriding it in the derived classes)
virtual bool CreateGenericClient(wxWindow *parent);
virtual bool CreateClient(wxMDIParentFrame *parent,
long WXUNUSED(style) = wxVSCROLL | wxHSCROLL)
{
return CreateGenericClient(parent);
}
// implementation only
wxBookCtrlBase *GetBookCtrl() const;
wxGenericMDIChildFrame *GetChild(size_t pos) const;
int FindChild(wxGenericMDIChildFrame *child) const;
private:
void PageChanged(int OldSelection, int newSelection);
void OnPageChanged(wxBookCtrlEvent& event);
void OnSize(wxSizeEvent& event);
// the notebook containing all MDI children as its pages
wxNotebook *m_notebook;
wxDECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow);
};
// ----------------------------------------------------------------------------
// inline functions implementation
// ----------------------------------------------------------------------------
inline bool
wxGenericMDIParentFrame::
WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const
{
return child == m_childHandler;
}
#endif // _WX_GENERIC_MDIG_H_

View File

@@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/msgdlgg.h
// Purpose: Generic wxMessageDialog
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_MSGDLGG_H_
#define _WX_GENERIC_MSGDLGG_H_
class WXDLLIMPEXP_FWD_CORE wxSizer;
class WXDLLIMPEXP_CORE wxGenericMessageDialog : public wxMessageDialogBase
{
public:
wxGenericMessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxMessageBoxCaptionStr),
long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
virtual int ShowModal() override;
protected:
// Creates a message dialog taking any options that have been set after
// object creation into account such as custom labels.
void DoCreateMsgdialog();
void OnYes(wxCommandEvent& event);
void OnNo(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
// can be overridden to provide more contents to the dialog
virtual void AddMessageDialogCheckBox(wxSizer *WXUNUSED(sizer)) { }
virtual void AddMessageDialogDetails(wxSizer *WXUNUSED(sizer)) { }
private:
// Creates and returns a standard button sizer using the style of this
// dialog and the custom labels, if any.
//
// May return nullptr on smart phone platforms not using buttons at all.
wxSizer *CreateMsgDlgButtonSizer();
wxPoint m_pos;
bool m_created;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericMessageDialog);
};
#endif // _WX_GENERIC_MSGDLGG_H_

View File

@@ -0,0 +1,154 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/notebook.h
// Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
// Author: Julian Smart
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_
#define _WX_NOTEBOOK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/event.h"
#include "wx/control.h"
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
// fwd declarations
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxTabView;
// ----------------------------------------------------------------------------
// wxNotebook
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
{
public:
// ctors
// -----
// default for dynamic class
wxNotebook();
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxNotebookNameStr));
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxNotebookNameStr));
// dtor
virtual ~wxNotebook();
// accessors
// ---------
// Find the position of the wxNotebookPage, wxNOT_FOUND if not found.
int FindPagePosition(wxNotebookPage* page) const;
// set the currently selected page, return the index of the previously
// selected one (or wxNOT_FOUND on error)
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
int SetSelection(size_t nPage);
// cycle thru the tabs
// void AdvanceSelection(bool bForward = true);
// changes selected page without sending events
int ChangeSelection(size_t nPage);
// set/get the title of a page
bool SetPageText(size_t nPage, const wxString& strText);
wxString GetPageText(size_t nPage) const;
// get the number of rows for a control with wxNB_MULTILINE style (not all
// versions support it - they will always return 1 then)
virtual int GetRowCount() const ;
// sets/returns item's image index in the current image list
int GetPageImage(size_t nPage) const;
bool SetPageImage(size_t nPage, int nImage);
// control the appearance of the notebook pages
// set the size (the same for all pages)
void SetPageSize(const wxSize& size);
// set the padding between tabs (in pixels)
void SetPadding(const wxSize& padding);
// Sets the size of the tabs (assumes all tabs are the same size)
void SetTabSize(const wxSize& sz);
// operations
// ----------
// remove one page from the notebook, and delete the page.
bool DeletePage(size_t nPage);
bool DeletePage(wxNotebookPage* page);
// remove one page from the notebook, without deleting the page.
bool RemovePage(size_t nPage);
bool RemovePage(wxNotebookPage* page);
virtual wxWindow* DoRemovePage(size_t nPage);
// remove all pages
bool DeleteAllPages();
// the same as AddPage(), but adds it at the specified position
bool InsertPage(size_t nPage,
wxNotebookPage *pPage,
const wxString& strText,
bool bSelect = false,
int imageId = NO_IMAGE);
// callbacks
// ---------
void OnSize(wxSizeEvent& event);
void OnInternalIdle();
void OnSelChange(wxBookCtrlEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event);
// base class virtuals
// -------------------
virtual void Command(wxCommandEvent& event);
virtual void SetConstraintSizes(bool recurse = true);
virtual bool DoPhase(int nPhase);
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
// Implementation
// Obsolete, don't use.
wxTabView *GetTabView() const { return m_tabView; }
void SetTabView(wxTabView *v) { m_tabView = v; }
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
virtual wxRect GetAvailableClientSize();
// Implementation: calculate the layout of the view rect
// and resize the children if required
bool RefreshLayout(bool force = true);
protected:
// common part of all ctors
void Init();
// helper functions
void ChangePage(int nOldSel, int nSel); // change pages
wxTabView* m_tabView;
wxDECLARE_DYNAMIC_CLASS(wxNotebook);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_NOTEBOOK_H_

View File

@@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/notifmsg.h
// Purpose: generic implementation of wxGenericNotificationMessage
// Author: Vadim Zeitlin
// Created: 2007-11-24
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_NOTIFMSG_H_
#define _WX_GENERIC_NOTIFMSG_H_
// ----------------------------------------------------------------------------
// wxGenericNotificationMessage
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGenericNotificationMessage : public wxNotificationMessageBase
{
public:
wxGenericNotificationMessage()
{
Init();
}
wxGenericNotificationMessage(const wxString& title,
const wxString& message = wxString(),
wxWindow *parent = nullptr,
int flags = wxICON_INFORMATION)
{
Init();
Create(title, message, parent, flags);
}
// generic implementation-specific methods
// get/set the default timeout (used if Timeout_Auto is specified)
static int GetDefaultTimeout();
static void SetDefaultTimeout(int timeout);
private:
void Init();
wxDECLARE_NO_COPY_CLASS(wxGenericNotificationMessage);
};
#endif // _WX_GENERIC_NOTIFMSG_H_

View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/numdlgg.h
// Purpose: wxNumberEntryDialog class
// Author: John Labenski
// Created: 07.02.04 (extracted from textdlgg.cpp)
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __NUMDLGH_G__
#define __NUMDLGH_G__
#include "wx/defs.h"
#if wxUSE_NUMBERDLG
#include "wx/dialog.h"
#if wxUSE_SPINCTRL
class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
#else
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
#endif // wxUSE_SPINCTRL
// ----------------------------------------------------------------------------
// wxNumberEntryDialog: a dialog with spin control, [ok] and [cancel] buttons
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxNumberEntryDialog : public wxDialog
{
public:
wxNumberEntryDialog()
{
m_value = m_min = m_max = 0;
}
wxNumberEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value, long min, long max,
const wxPoint& pos = wxDefaultPosition)
{
Create(parent, message, prompt, caption, value, min, max, pos);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value, long min, long max,
const wxPoint& pos = wxDefaultPosition);
long GetValue() const { return m_value; }
// implementation only
void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
protected:
#if wxUSE_SPINCTRL
wxSpinCtrl *m_spinctrl;
#else
wxTextCtrl *m_spinctrl;
#endif // wxUSE_SPINCTRL
long m_value, m_min, m_max;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxNumberEntryDialog);
wxDECLARE_NO_COPY_CLASS(wxNumberEntryDialog);
};
// ----------------------------------------------------------------------------
// function to get a number from user
// ----------------------------------------------------------------------------
WXDLLIMPEXP_CORE long
wxGetNumberFromUser(const wxString& message,
const wxString& prompt,
const wxString& caption,
long value = 0,
long min = 0,
long max = 100,
wxWindow *parent = nullptr,
const wxPoint& pos = wxDefaultPosition);
#endif // wxUSE_NUMBERDLG
#endif // __NUMDLGH_G__

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/paletteg.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_PALETTEG_H__
#define __WX_PALETTEG_H__
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxPalette;
//-----------------------------------------------------------------------------
// wxPalette
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPalette: public wxPaletteBase
{
public:
wxPalette();
wxPalette( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue );
bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel( unsigned char red, unsigned char green, unsigned char blue ) const;
bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const;
virtual int GetColoursCount() const override;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxPalette);
};
#endif // __WX_PALETTEG_H__

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/printps.h
// Purpose: wxPostScriptPrinter, wxPostScriptPrintPreview
// wxGenericPageSetupDialog
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __PRINTPSH__
#define __PRINTPSH__
#include "wx/prntbase.h"
#if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
// ----------------------------------------------------------------------------
// Represents the printer: manages printing a wxPrintout object
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPostScriptPrinter : public wxPrinterBase
{
public:
wxPostScriptPrinter(wxPrintDialogData *data = nullptr);
virtual ~wxPostScriptPrinter();
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) override;
virtual wxDC* PrintDialog(wxWindow *parent) override;
virtual bool Setup(wxWindow *parent) override;
private:
wxDECLARE_DYNAMIC_CLASS(wxPostScriptPrinter);
};
// ----------------------------------------------------------------------------
// wxPrintPreview: programmer creates an object of this class to preview a
// wxPrintout.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPostScriptPrintPreview : public wxPrintPreviewBase
{
public:
wxPostScriptPrintPreview(wxPrintout *printout,
wxPrintout *printoutForPrinting = nullptr,
wxPrintDialogData *data = nullptr);
wxPostScriptPrintPreview(wxPrintout *printout,
wxPrintout *printoutForPrinting,
wxPrintData *data);
virtual ~wxPostScriptPrintPreview();
virtual bool Print(bool interactive) override;
virtual void DetermineScaling() override;
private:
void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
private:
wxDECLARE_CLASS(wxPostScriptPrintPreview);
};
#endif
#endif
// __PRINTPSH__

View File

@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/addremovectrl.h
// Purpose: Generic wxAddRemoveImpl implementation, also used in wxMSW
// Author: Vadim Zeitlin
// Created: 2015-02-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_ADDREMOVECTRL_H_
#define _WX_GENERIC_PRIVATE_ADDREMOVECTRL_H_
// ----------------------------------------------------------------------------
// wxAddRemoveImpl
// ----------------------------------------------------------------------------
class wxAddRemoveImpl : public wxAddRemoveImplWithButtons
{
public:
wxAddRemoveImpl(wxAddRemoveAdaptor* adaptor,
wxAddRemoveCtrl* parent,
wxWindow* ctrlItems)
: wxAddRemoveImplWithButtons(adaptor, parent, ctrlItems)
{
m_btnAdd = new wxButton(parent, wxID_ADD, GetAddButtonLabel(),
wxDefaultPosition, wxDefaultSize,
wxBU_EXACTFIT | wxBORDER_NONE);
m_btnRemove = new wxButton(parent, wxID_REMOVE, GetRemoveButtonLabel(),
wxDefaultPosition, wxDefaultSize,
wxBU_EXACTFIT | wxBORDER_NONE);
wxSizer* const sizerBtns = new wxBoxSizer(wxVERTICAL);
sizerBtns->Add(m_btnAdd, wxSizerFlags().Expand());
sizerBtns->Add(m_btnRemove, wxSizerFlags().Expand());
wxSizer* const sizerTop = new wxBoxSizer(wxHORIZONTAL);
sizerTop->Add(ctrlItems, wxSizerFlags(1).Expand());
sizerTop->Add(sizerBtns, wxSizerFlags().Centre().Border(wxLEFT));
parent->SetSizer(sizerTop);
SetUpEvents();
}
private:
static wxString GetAddButtonLabel()
{
return wchar_t(0xFF0B); // FULLWIDTH PLUS SIGN
}
static wxString GetRemoveButtonLabel()
{
return wchar_t(0x2012); // FIGURE DASH
}
};
#endif // _WX_GENERIC_PRIVATE_ADDREMOVECTRL_H_

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/animate.h
// Purpose: wxAnimationGenericImpl
// Author: Julian Smart and Guillermo Rodriguez Garcia
// Modified by: Francesco Montorsi
// Created: 13/8/99
// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_ANIMATEH__
#define _WX_GENERIC_PRIVATE_ANIMATEH__
#include "wx/private/animate.h"
// ----------------------------------------------------------------------------
// wxAnimationGenericImpl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl
{
public:
wxAnimationGenericImpl() : m_decoder(nullptr) {}
virtual ~wxAnimationGenericImpl() { UnRef(); }
virtual bool IsOk() const override
{ return m_decoder != nullptr; }
virtual bool IsCompatibleWith(wxClassInfo* ci) const override;
virtual unsigned int GetFrameCount() const override;
virtual int GetDelay(unsigned int i) const override;
virtual wxImage GetFrame(unsigned int i) const override;
virtual wxSize GetSize() const override;
virtual bool LoadFile(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY) override;
virtual bool Load(wxInputStream& stream,
wxAnimationType type = wxANIMATION_TYPE_ANY) override;
// extended interface used only by the generic implementation of wxAnimationCtrl
virtual wxPoint GetFramePosition(unsigned int frame) const;
virtual wxSize GetFrameSize(unsigned int frame) const;
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
virtual wxColour GetTransparentColour(unsigned int frame) const;
virtual wxColour GetBackgroundColour() const;
private:
void UnRef();
wxAnimationDecoder* m_decoder;
wxDECLARE_NO_COPY_CLASS(wxAnimationGenericImpl);
};
#endif // _WX_GENERIC_PRIVATE_ANIMATEH__

View File

@@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/drawbitmap.h
// Purpose: Small helper for drawing images.
// Author: Vadim Zeitlin
// Created: 2022-10-25
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_DRAWBITMAP_H_
#define _WX_GENERIC_PRIVATE_DRAWBITMAP_H_
#include "wx/dc.h"
#include "wx/window.h"
#include "wx/withimages.h"
// Just a trivial wrapper for wxDC::DrawBitmap() using wxWithImages: this is
// used in several places in the generic wxListCtrl and wxTreeCtrl code.
inline void
wxDrawImageBitmap(wxWindow* window,
const wxWithImages& images,
int image,
wxDC& dc,
int x,
int y)
{
dc.DrawBitmap(images.GetImageBitmapFor(window, image),
x, y,
true /* use mask */);
}
// Overload for the controls deriving from both wxWindow and wxWithImages, as
// both wxListCtrl and wxTreeCtrl do.
template <typename T>
inline void
wxDrawImageBitmap(T* window, int image, wxDC& dc, int x, int y)
{
wxDrawImageBitmap(window, *window, image, dc, x, y);
}
#endif // _WX_GENERIC_PRIVATE_DRAWBITMAP_H_

View File

@@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/drawresize.h
// Purpose: Helper function for drawing "resize hint".
// Author: Vadim Zeitlin
// Created: 2024-04-20
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_DRAWRESIZE_H_
#define _WX_GENERIC_PRIVATE_DRAWRESIZE_H_
// This function is also used by wxAuiManager when not using overlay, so it has
// to remain separate from wxDrawOverlayResizeHint().
inline wxBitmap wxPaneCreateStippleBitmap()
{
unsigned char data[] = { 0,0,0,192,192,192, 192,192,192,0,0,0 };
wxImage img(2,2,data,true);
return wxBitmap(img);
}
// This is used by both wxSplitterWindow and wxAuiManager to draw the resize
// hint using the overlay associated with the given window.
inline void
wxDrawOverlayResizeHint(wxWindow* win, wxOverlay& overlay, const wxRect& rect)
{
wxOverlayDC dc(overlay, win);
dc.Clear();
wxBitmap stipple = wxPaneCreateStippleBitmap();
wxBrush brush(stipple);
dc.SetBrush(brush);
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(rect);
}
#endif // _WX_GENERIC_PRIVATE_DRAWRESIZE_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,950 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/listctrl.h
// Purpose: private definitions of wxListCtrl helpers
// Author: Robert Roebling
// Vadim Zeitlin (virtual list control support)
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_LISTCTRL_PRIVATE_H_
#define _WX_GENERIC_LISTCTRL_PRIVATE_H_
#include "wx/defs.h"
#if wxUSE_LISTCTRL
#include "wx/listctrl.h"
#include "wx/selstore.h"
#include "wx/timer.h"
#include "wx/settings.h"
#include <memory>
// ============================================================================
// private classes
// ============================================================================
//-----------------------------------------------------------------------------
// wxColWidthInfo (internal)
//-----------------------------------------------------------------------------
struct wxColWidthInfo
{
int nMaxWidth;
bool bNeedsUpdate; // only set to true when an item whose
// width == nMaxWidth is removed
wxColWidthInfo(int w = 0, bool needsUpdate = false)
{
nMaxWidth = w;
bNeedsUpdate = needsUpdate;
}
};
using ColWidthArray = std::vector<wxColWidthInfo>;
//-----------------------------------------------------------------------------
// wxListItemData (internal)
//-----------------------------------------------------------------------------
class wxListItemData
{
public:
wxListItemData(wxListMainWindow *owner);
wxListItemData(const wxListItemData&) = delete;
wxListItemData(wxListItemData&&);
wxListItemData& operator=(const wxListItemData&) = delete;
wxListItemData& operator=(wxListItemData&&);
~wxListItemData();
void SetItem( const wxListItem &info );
void SetImage( int image ) { m_image = image; }
void SetData( wxUIntPtr data ) { m_data = data; }
void SetPosition( int x, int y );
void SetSize( int width, int height );
bool HasText() const { return !m_text.empty(); }
const wxString& GetText() const { return m_text; }
void SetText(const wxString& text) { m_text = text; }
// we can't use empty string for measuring the string width/height, so
// always return something
wxString GetTextForMeasuring() const
{
wxString s = GetText();
if ( s.empty() )
s = wxT('H');
return s;
}
bool IsHit( int x, int y ) const;
int GetX() const;
int GetY() const;
int GetWidth() const;
int GetHeight() const;
int GetImage() const { return m_image; }
bool HasImage() const { return GetImage() != -1; }
void GetItem( wxListItem &info ) const;
void SetAttr(wxItemAttr *attr) { m_attr = attr; }
wxItemAttr *GetAttr() const { return m_attr; }
public:
// the item image or -1
int m_image = -1;
// user data associated with the item
wxUIntPtr m_data = 0;
// the item coordinates are not used in report mode; instead this pointer is
// null and the owner window is used to retrieve the item position and size
wxRect *m_rect = nullptr;
// the list ctrl we are in
wxListMainWindow *m_owner;
// custom attributes or nullptr
wxItemAttr *m_attr = nullptr;
protected:
wxString m_text;
};
//-----------------------------------------------------------------------------
// wxListHeaderData (internal)
//-----------------------------------------------------------------------------
class wxListHeaderData : public wxObject
{
public:
wxListHeaderData();
wxListHeaderData( const wxListItem &info );
void SetItem( const wxListItem &item );
void SetPosition( int x, int y );
void SetWidth( int w );
void SetState( int state );
void SetFormat( int format );
void SetHeight( int h );
bool HasImage() const;
bool HasText() const { return !m_text.empty(); }
const wxString& GetText() const { return m_text; }
void SetText(const wxString& text) { m_text = text; }
void GetItem( wxListItem &item ) const;
bool IsHit( int x, int y ) const;
int GetImage() const;
int GetWidth() const;
int GetFormat() const;
int GetState() const;
protected:
long m_mask;
int m_image;
wxString m_text;
int m_format;
int m_width;
int m_xpos,
m_ypos;
int m_height;
int m_state;
private:
void Init();
};
//-----------------------------------------------------------------------------
// wxListLineData (internal)
//-----------------------------------------------------------------------------
class wxListLineData
{
public:
// the list of subitems: only may have more than one item in report mode
std::vector<wxListItemData> m_items;
// this is not used in report view
struct GeometryInfo
{
// total item rect
wxRect m_rectAll;
// label only
wxRect m_rectLabel;
// icon only
wxRect m_rectIcon;
// the part to be highlighted
wxRect m_rectHighlight;
// extend all our rects to be centered inside the one of given width
void ExtendWidth(wxCoord w)
{
wxASSERT_MSG( m_rectAll.width <= w,
wxT("width can only be increased") );
int delta = (w - m_rectAll.width) / 2;
m_rectAll.width = w;
m_rectLabel.x += delta;
m_rectIcon.x += delta;
m_rectHighlight.x += delta;
}
};
std::unique_ptr<GeometryInfo> m_gi;
// is this item selected? [NB: not used in virtual mode]
bool m_highlighted;
bool m_checked;
// back pointer to the list ctrl
wxListMainWindow *m_owner;
public:
wxListLineData(wxListMainWindow *owner);
wxListLineData(const wxListLineData&) = delete;
wxListLineData(wxListLineData&& other) = default;
wxListLineData& operator=(const wxListLineData&) = delete;
wxListLineData& operator=(wxListLineData&&) = default;
~wxListLineData() = default;
// called by the owner when it toggles report view
void SetReportView(bool inReportView)
{
// we only need m_gi when we're not in report view so update as needed
m_gi.reset( inReportView ? nullptr : new GeometryInfo );
}
// are we in report mode?
inline bool InReportView() const;
// are we in virtual report mode?
inline bool IsVirtual() const;
// these 2 methods shouldn't be called for report view controls, in that
// case we determine our position/size ourselves
// calculate the size of the line
void CalculateSize( wxReadOnlyDC *dc, int spacing );
// remember the position this line appears at
void SetPosition( int x, int y, int spacing );
// wxListCtrl API
void SetImage( int image ) { SetImage(0, image); }
int GetImage() const { return GetImage(0); }
void SetImage( int index, int image );
int GetImage( int index ) const;
void Check(bool check) { m_checked = check; }
bool IsChecked() { return m_checked; }
bool HasImage() const { return GetImage() != -1; }
bool HasText() const { return !GetText(0).empty(); }
void SetItem( int index, const wxListItem &info );
void GetItem( int index, wxListItem &info ) const;
wxString GetText(int index) const;
void SetText( int index, const wxString& s );
wxItemAttr *GetAttr() const;
void SetAttr(wxItemAttr *attr);
// return true if the highlighting really changed
bool Highlight( bool on );
void ReverseHighlight();
bool IsHighlighted() const
{
wxASSERT_MSG( !IsVirtual(), wxT("unexpected call to IsHighlighted") );
return m_highlighted;
}
// draw the line on the given DC in icon/list mode
void Draw( wxDC *dc, bool current );
// the same in report mode: it needs more parameters as we don't store
// everything in the item in report mode
void DrawInReportMode( wxDC *dc,
const wxRect& rect,
const wxRect& rectHL,
bool highlighted,
bool current,
bool checked );
private:
// set the line to contain num items (only can be > 1 in report mode)
void InitItems( int num );
// get the mode (i.e. style) of the list control
inline int GetMode() const;
// Apply this item attributes to the given DC: set the text font and colour
// and also erase the background appropriately.
void ApplyAttributes(wxDC *dc,
const wxRect& rectHL,
bool highlighted,
bool current);
// draw the text on the DC with the correct justification; also add an
// ellipsis if the text is too large to fit in the current width
void DrawTextFormatted(wxDC *dc,
const wxString &text,
int col,
int x,
int yMid, // this is middle, not top, of the text
int width);
};
//-----------------------------------------------------------------------------
// wxListHeaderWindow (internal)
//-----------------------------------------------------------------------------
class wxListHeaderWindow : public wxWindow
{
protected:
wxListMainWindow *m_owner;
const wxCursor *m_currentCursor;
wxCursor *m_resizeCursor;
bool m_isDragging;
// column being resized or -1
int m_column;
// divider line position in logical (unscrolled) coords
int m_currentX;
// minimal position beyond which the divider line
// can't be dragged in logical coords
int m_minX;
public:
wxListHeaderWindow();
// We provide only Create(), not the ctor, because we need to create the
// C++ object before creating the window, see the explanations in
// CreateOrDestroyHeaderWindowAsNeeded()
bool Create( wxWindow *win,
wxWindowID id,
wxListMainWindow *owner,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxT("wxlistctrlcolumntitles") );
virtual ~wxListHeaderWindow();
// We never need focus as we don't have any keyboard interface.
virtual bool AcceptsFocus() const override { return false; }
void DrawCurrent();
void AdjustDC( wxDC& dc );
void OnPaint( wxPaintEvent &event );
void OnMouse( wxMouseEvent &event );
// needs refresh
bool m_dirty;
// Update main window's column later
bool m_sendSetColumnWidth;
int m_colToSend;
int m_widthToSend;
bool m_sortAsc;
int m_sortCol;
virtual wxWindow *GetMainWindowOfCompositeControl() override { return GetParent(); }
virtual void OnInternalIdle() override;
private:
// common part of all ctors
void Init();
// generate and process the list event of the given type, return true if
// it wasn't vetoed, i.e. if we should proceed
bool SendListEvent(wxEventType type, const wxPoint& pos);
wxDECLARE_EVENT_TABLE();
};
//-----------------------------------------------------------------------------
// wxListRenameTimer (internal)
//-----------------------------------------------------------------------------
class wxListRenameTimer: public wxTimer
{
private:
wxListMainWindow *m_owner;
public:
wxListRenameTimer( wxListMainWindow *owner );
void Notify() override;
};
//-----------------------------------------------------------------------------
// wxListFindTimer (internal)
//-----------------------------------------------------------------------------
class wxListFindTimer: public wxTimer
{
public:
// reset the current prefix after half a second of inactivity
enum { DELAY = 500 };
wxListFindTimer( wxListMainWindow *owner )
: m_owner(owner)
{
}
virtual void Notify() override;
private:
wxListMainWindow *m_owner;
};
//-----------------------------------------------------------------------------
// wxListTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing
//-----------------------------------------------------------------------------
class wxListTextCtrlWrapper : public wxEvtHandler
{
public:
// NB: text must be a valid object but not Create()d yet
wxListTextCtrlWrapper(wxListMainWindow *owner,
wxTextCtrl *text,
size_t itemEdit);
wxTextCtrl *GetText() const { return m_text; }
// Check if the given key event should stop editing and return true if it
// does or false otherwise.
bool CheckForEndEditKey(const wxKeyEvent& event);
// Different reasons for calling EndEdit():
//
// It was called because:
enum EndReason
{
End_Accept, // user has accepted the changes.
End_Discard, // user has cancelled editing.
End_Destroy // the entire control is being destroyed.
};
void EndEdit(EndReason reason);
protected:
void OnChar( wxKeyEvent &event );
void OnKeyUp( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
bool AcceptChanges();
void Finish( bool setfocus );
private:
wxListMainWindow *m_owner;
wxTextCtrl *m_text;
wxString m_startValue;
size_t m_itemEdited;
bool m_aboutToFinish;
wxDECLARE_EVENT_TABLE();
};
//-----------------------------------------------------------------------------
// wxListMainWindow (internal)
//-----------------------------------------------------------------------------
class wxListMainWindow : public wxWindow
{
public:
wxListMainWindow();
wxListMainWindow( wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size );
virtual ~wxListMainWindow();
// called by the main control when its mode changes
void SetReportView(bool inReportView);
// helper to simplify testing for wxLC_XXX flags
bool HasFlag(int flag) const { return m_parent->HasFlag(flag); }
// return true if this is a virtual list control
bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
// return true if the control is in report mode
bool InReportView() const { return HasFlag(wxLC_REPORT); }
// return true if we are in single selection mode, false if multi sel
bool IsSingleSel() const { return HasFlag(wxLC_SINGLE_SEL); }
// do we have a header window?
bool HasHeader() const
{ return InReportView() && !HasFlag(wxLC_NO_HEADER); }
void HighlightAll( bool on );
// all these functions only do something if the line is currently visible
// Make sure that _line_ is the only item highlighted in the control.
// _oldLine_ is the old focused item.
void HighlightOnly( size_t line, size_t oldLine = (size_t)-1 );
// In multiple selection mode, instead of sending one notification per item
// (which is too slow if a lot of items are selected) we send only one notification
// for all of them which is the wxMSW behaviour. Currently done for virtual
// list controls and for deselection only.
enum SendEvent { SendEvent_None, SendEvent_Normal };
// change the line "selected" state, return true if it really changed
bool HighlightLine( size_t line, bool highlight = true,
SendEvent sendEvent = SendEvent_Normal );
// as HighlightLine() but do it for the range of lines: this is incredibly
// more efficient for virtual list controls!
//
// NB: unlike HighlightLine() this one does refresh the lines on screen
void HighlightLines( size_t lineFrom, size_t lineTo, bool on = true,
SendEvent sendEvent = SendEvent_Normal );
// toggle the line state and refresh it
void ReverseHighlight( size_t line )
{ HighlightLine(line, !IsHighlighted(line)); RefreshLine(line); }
// return true if the line is highlighted
bool IsHighlighted(size_t line) const;
// refresh one or several lines at once
void RefreshLine( size_t line );
void RefreshLines( size_t lineFrom, size_t lineTo );
// refresh all selected items
void RefreshSelected();
// refresh all lines below the given one: the difference with
// RefreshLines() is that the index here might not be a valid one (happens
// when the last line is deleted)
void RefreshAfter( size_t lineFrom );
// the methods which are forwarded to wxListLineData itself in list/icon
// modes but are here because the lines don't store their positions in the
// report mode
// get the bound rect for the entire line
wxRect GetLineRect(size_t line) const;
// get the bound rect of the label
wxRect GetLineLabelRect(size_t line) const;
// get the bound rect of the items icon (only may be called if we do have
// an icon!)
wxRect GetLineIconRect(size_t line) const;
// get the rect to be highlighted when the item has focus
wxRect GetLineHighlightRect(size_t line) const;
// get the size of the total line rect
wxSize GetLineSize(size_t line) const
{ return GetLineRect(line).GetSize(); }
// return the hit code for the corresponding position (in this line)
long HitTestLine(size_t line, int x, int y) const;
// bring the selected item into view, scrolling to it if necessary
void MoveToItem(size_t item);
bool ScrollList( int WXUNUSED(dx), int dy );
// bring the current item into view
void MoveToFocus() { MoveToItem(m_current); }
// start editing the label of the given item
wxTextCtrl *EditLabel(long item,
wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl));
bool EndEditLabel(bool cancel);
wxTextCtrl *GetEditControl() const
{
return m_textctrlWrapper ? m_textctrlWrapper->GetText() : nullptr;
}
void ResetTextControl(wxTextCtrl *text)
{
delete text;
m_textctrlWrapper = nullptr;
}
void OnRenameTimer();
bool OnRenameAccept(size_t itemEdit, const wxString& value);
void OnRenameCancelled(size_t itemEdit);
void OnFindTimer();
// set whether or not to ring the find bell
// (does nothing on MSW - bell is always rung)
void EnableBellOnNoMatch( bool on );
void OnMouse( wxMouseEvent &event );
// called to switch the selection from the current item to newCurrent,
void OnArrowChar( size_t newCurrent, const wxKeyEvent& event );
void OnCharHook( wxKeyEvent &event );
void OnChar( wxKeyEvent &event );
void OnKeyDown( wxKeyEvent &event );
void OnKeyUp( wxKeyEvent &event );
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnScroll( wxScrollWinEvent& event );
void OnPaint( wxPaintEvent &event );
void OnChildFocus(wxChildFocusEvent& event);
void DrawImage( int index, wxDC *dc, int x, int y );
void GetImageSize( int index, int &width, int &height ) const;
void SetImages( wxWithImages *images, const int which );
void SetItemSpacing( int spacing, bool isSmall = false );
int GetItemSpacing( bool isSmall = false );
void SetColumn( int col, const wxListItem &item );
void SetColumnWidth( int col, int width );
void GetColumn( int col, wxListItem &item ) const;
int GetColumnWidth( int col ) const;
int GetColumnCount() const { return m_columns.size(); }
// returns the sum of the heights of all columns
int GetHeaderWidth() const;
int GetCountPerPage() const;
void SetItem( wxListItem &item );
void GetItem( wxListItem &item ) const;
void SetItemState( long item, long state, long stateMask );
void SetItemStateAll( long state, long stateMask );
int GetItemState( long item, long stateMask ) const;
bool GetItemRect( long item, wxRect &rect ) const
{
return GetSubItemRect(item, wxLIST_GETSUBITEMRECT_WHOLEITEM, rect);
}
bool GetSubItemRect( long item, long subItem, wxRect& rect,
int code = wxLIST_RECT_BOUNDS ) const;
wxRect GetViewRect() const;
bool GetItemPosition( long item, wxPoint& pos ) const;
int GetSelectedItemCount() const;
bool HasCheckBoxes() const;
bool EnableCheckBoxes(bool enable = true);
bool IsItemChecked(long item) const;
void CheckItem(long item, bool check);
wxString GetItemText(long item, int col = 0) const
{
wxListItem info;
info.m_mask = wxLIST_MASK_TEXT;
info.m_itemId = item;
info.m_col = col;
GetItem( info );
return info.m_text;
}
void SetItemText(long item, const wxString& value)
{
wxListItem info;
info.m_mask = wxLIST_MASK_TEXT;
info.m_itemId = item;
info.m_text = value;
SetItem( info );
}
wxWithImages* GetSmallImages() const
{ return m_small_images; }
// set the scrollbars and update the positions of the items
void RecalculatePositions();
// do the same thing and also call Refresh()
void RecalculatePositionsAndRefresh();
long GetNextItem( long item, int geometry, int state ) const;
void DeleteItem( long index );
void DeleteAllItems();
void DeleteColumn( int col );
void DeleteEverything();
void EnsureVisible( long index );
long FindItem( long start, const wxString& str, bool partial = false );
long FindItem( long start, wxUIntPtr data);
long FindItem( const wxPoint& pt );
long HitTest( int x, int y, int &flags ) const;
void InsertItem( wxListItem &item );
long InsertColumn( long col, const wxListItem &item );
int GetItemWidthWithImage(wxListItem * item);
void SortItems( wxListCtrlCompare fn, wxIntPtr data );
size_t GetItemCount() const;
bool IsEmpty() const { return GetItemCount() == 0; }
void SetItemCount(long count);
// change the current (== focused) item, send a notification event
void ChangeCurrent(size_t current);
void ResetCurrent() { ChangeCurrent((size_t)-1); }
bool HasCurrent() const { return m_current != (size_t)-1; }
// send out a wxListEvent
void SendNotify( size_t line,
wxEventType command,
const wxPoint& point = wxDefaultPosition );
// override base class virtual to reset m_lineHeight when the font changes
virtual bool SetFont(const wxFont& font) override
{
if ( !wxWindow::SetFont(font) )
return false;
m_lineHeight = 0;
return true;
}
void ExtendRulesAndAlternateColour(bool extend)
{
m_extendRulesAndAlternateColour = extend;
}
// these are for wxListLineData usage only
// get the backpointer to the list ctrl
wxGenericListCtrl *GetListCtrl() const
{
return wxStaticCast(GetParent(), wxGenericListCtrl);
}
// get the height of all lines (assuming they all do have the same height)
wxCoord GetLineHeight() const;
// get the y position of the given line (only for report view)
wxCoord GetLineY(size_t line) const;
// get the brush to use for the item highlighting
wxBrush *GetHighlightBrush() const
{
return m_hasFocus ? m_highlightBrush : m_highlightUnfocusedBrush;
}
bool HasFocus() const override
{
return m_hasFocus;
}
void UpdateSelectionCount(bool selected)
{
wxASSERT_MSG( !IsVirtual(), "Can be called for non virtual lists only" );
if ( IsSingleSel() )
return;
selected ? ++m_selCount : --m_selCount;
}
void DrawInReportModeOnBlank ( wxDC *dc,
const wxRect& rect,
int lineNumber );
protected:
// the array of all line objects for a non virtual list control (for the
// virtual list control we only ever use m_lines[0])
std::vector<wxListLineData> m_lines;
// the list of column objects
std::vector<wxListHeaderData> m_columns;
// currently focused item or -1
size_t m_current;
// the number of lines per page
int m_linesPerPage;
// this flag is set when something which should result in the window
// redrawing happens (i.e. an item was added or deleted, or its appearance
// changed) and OnPaint() doesn't redraw the window while it is set which
// allows to minimize the number of repaintings when a lot of items are
// being added. The real repainting occurs only after the next OnIdle()
// call
bool m_dirty;
wxColour *m_highlightColour;
wxWithImages *m_small_images;
wxWithImages *m_normal_images;
int m_small_spacing;
int m_normal_spacing;
bool m_hasFocus;
bool m_lastOnSame;
wxTimer *m_renameTimer;
// incremental search data
wxString m_findPrefix;
wxTimer *m_findTimer;
// This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1
// if it is globally enabled but has been temporarily disabled because we
// had already beeped for this particular search.
int m_findBell;
bool m_isCreated;
int m_dragCount;
wxPoint m_dragStart;
ColWidthArray m_aColWidths;
// for double click logic
size_t m_lineLastClicked,
m_lineBeforeLastClicked,
m_lineSelectSingleOnUp;
// Multiple selection extends from the anchor. Not used in single-selection mode.
size_t m_anchor;
bool m_hasCheckBoxes;
protected:
wxWindow *GetMainWindowOfCompositeControl() override { return GetParent(); }
// the total count of items selected in a non virtual list control with
// multiple selections (always 0 otherwise)
size_t m_selCount;
// the total count of items in a virtual list control
size_t m_countVirt;
// the object maintaining the items selection state, only used in virtual
// controls
wxSelectionStore m_selStore;
// common part of all ctors
void Init();
// get the line data for the given index
wxListLineData *GetLine(size_t n) const
{
wxListMainWindow *self = wxConstCast(this, wxListMainWindow);
if ( IsVirtual() )
{
self->CacheLineData(n);
n = 0;
}
else
{
wxCHECK_MSG( n < m_lines.size(), nullptr, wxT("invalid line index") );
}
return &self->m_lines[n];
}
// get a dummy line which can be used for geometry calculations and such:
// you must use GetLine() if you want to really draw the line
wxListLineData *GetDummyLine() const;
// cache the line data of the n-th line in m_lines[0]
void CacheLineData(size_t line);
// get the range of visible lines
void GetVisibleLinesRange(size_t *from, size_t *to);
// force us to recalculate the range of visible lines
void ResetVisibleLinesRange() { m_lineFrom = (size_t)-1; }
// find the first item starting with the given prefix after the given item
size_t PrefixFindItem(size_t item, const wxString& prefix) const;
// get the colour to be used for drawing the rules
wxColour GetRuleColour() const
{
return wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
}
private:
// initialize the current item if needed
void UpdateCurrent();
// change the current (== focused) item, without sending any event
// return true if m_current really changed.
bool ChangeCurrentWithoutEvent(size_t current);
// Trying to activate the current item from keyboard is only possible
// if it is actually selected. We don't send wxEVT_LIST_ITEM_ACTIVATED
// event if it is not, and wxEVT_LIST_KEY_DOWN event should carry -1
// in this case, as the wxMSW implementation does.
bool ShouldSendEventForCurrent() const
{
return HasCurrent() && IsHighlighted(m_current);
}
// For multiple selection mode.
// Change the selected range from [anchor, oldCurrent] to [anchor, newCurrent]
// without generating unnecessary wxEVT_LIST_ITEM_{DE}SELECTED events.
void ExtendSelection(size_t oldCurrent, size_t newCurrent);
// delete all items but don't refresh: called from dtor
void DoDeleteAllItems();
// Compute the minimal width needed to fully display the column header.
int ComputeMinHeaderWidth(const wxListHeaderData* header) const;
// Check if the given point is inside the checkbox of this item.
//
// Always returns false if there are no checkboxes.
bool IsInsideCheckBox(long item, int x, int y);
// the height of one line using the current font
wxCoord m_lineHeight;
// the total header width or 0 if not calculated yet
wxCoord m_headerWidth;
// the first and last lines being shown on screen right now (inclusive),
// both may be -1 if they must be calculated so never access them directly:
// use GetVisibleLinesRange() above instead
size_t m_lineFrom,
m_lineTo;
// the brushes to use for item highlighting when we do/don't have focus
wxBrush *m_highlightBrush,
*m_highlightUnfocusedBrush;
// wrapper around the text control currently used for in place editing or
// nullptr if no item is being edited
wxListTextCtrlWrapper *m_textctrlWrapper;
// tells whether or not to paint empty rows with alternate colour and draw
// rulers on empty rows
bool m_extendRulesAndAlternateColour;
wxDECLARE_EVENT_TABLE();
friend class wxGenericListCtrl;
friend class wxListCtrlMaxWidthCalculator;
};
#endif // wxUSE_LISTCTRL
#endif // _WX_GENERIC_LISTCTRL_PRIVATE_H_

View File

@@ -0,0 +1,143 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/markuptext.h
// Purpose: Generic wx*MarkupText classes for managing text with markup.
// Author: Vadim Zeitlin
// Created: 2011-02-21
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_MARKUPTEXT_H_
#define _WX_GENERIC_PRIVATE_MARKUPTEXT_H_
#include "wx/defs.h"
#include "wx/gdicmn.h"
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxReadOnlyDC;
class wxMarkupParserOutput;
// ----------------------------------------------------------------------------
// wxMarkupText: allows to measure and draw the text containing markup.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMarkupTextBase
{
public:
virtual ~wxMarkupTextBase() = default;
// Update the markup string, return false if it didn't change.
bool SetMarkup(const wxString& markup)
{
if ( markup == m_markup )
return false;
m_markup = markup;
return true;
}
// Return the width and height required by the given string and optionally
// the height of the visible part above the baseline (i.e. ascent minus
// internal leading).
//
// The font currently selected into the DC is used for measuring (notice
// that it is changed by this function but normally -- i.e. if markup is
// valid -- restored to its original value when it returns).
wxSize Measure(wxReadOnlyDC& dc, int *visibleHeight = nullptr) const;
protected:
wxMarkupTextBase(const wxString& markup)
: m_markup(markup)
{
}
// Return m_markup suitable for measuring by Measure, i.e. stripped of
// any mnemonics.
virtual wxString GetMarkupForMeasuring() const = 0;
wxString m_markup;
};
class WXDLLIMPEXP_CORE wxMarkupText : public wxMarkupTextBase
{
public:
// Constants for Render() flags.
enum
{
Render_Default = 0, // Don't show mnemonics visually.
Render_ShowAccels = 1 // Underline mnemonics.
};
// Initialize with the given string containing markup (which is supposed to
// be valid, the caller must check for it before constructing this object).
//
// Notice that the usual rules for mnemonics apply to the markup text: if
// it contains any '&' characters they must be escaped by doubling them,
// otherwise they indicate that the next character is the mnemonic for this
// field.
//
// TODO-MULTILINE-MARKUP: Currently only single line labels are supported,
// search for other occurrences of this comment to find the places which
// need to be updated to support multiline labels with markup.
wxMarkupText(const wxString& markup) : wxMarkupTextBase(markup)
{
}
// Default copy ctor, assignment operator and dtor are ok.
// Render the markup string into the given DC in the specified rectangle.
//
// Notice that while the function uses the provided rectangle for alignment
// (by default it centers the text in it), no clipping is done by it so use
// Measure() and set the clipping region before rendering if necessary.
void Render(wxDC& dc, const wxRect& rect, int flags,
int alignment = wxALIGN_CENTER);
protected:
virtual wxString GetMarkupForMeasuring() const override;
};
// ----------------------------------------------------------------------------
// wxItemMarkupText: variant of wxMarkupText for items without mnemonics
// ----------------------------------------------------------------------------
// This class has similar interface to wxItemMarkup, but no strings contain
// mnemonics and no escaping is done.
class WXDLLIMPEXP_CORE wxItemMarkupText : public wxMarkupTextBase
{
public:
// Initialize with the given string containing markup (which is supposed to
// be valid, the caller must check for it before constructing this object).
// Notice that mnemonics are not interpreted at all by this class, so
// literal ampersands shouldn't be escaped/doubled.
wxItemMarkupText(const wxString& markup) : wxMarkupTextBase(markup)
{
}
// Default copy ctor, assignment operator and dtor are ok.
// Similar to wxMarkupText::Render(), but uses wxRendererNative::DrawItemText()
// instead of generic wxDC::DrawLabel(), so is more suitable for use in
// controls that already use DrawItemText() for its items.
//
// The meaning of the flags here is different than in wxMarkupText too:
// they're passed to DrawItemText().
//
// Currently the only supported ellipsize modes are wxELLIPSIZE_NONE and
// wxELLIPSIZE_END, the others are treated as wxELLIPSIZE_END.
void Render(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int rendererFlags,
wxEllipsizeMode ellipsizeMode);
protected:
virtual wxString GetMarkupForMeasuring() const override { return m_markup; }
};
#endif // _WX_GENERIC_PRIVATE_MARKUPTEXT_H_

View File

@@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/notifmsg.h
// Purpose: wxGenericNotificationMessage declarations
// Author: Tobias Taschner
// Created: 2015-08-04
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_NOTIFMSG_H_
#define _WX_GENERIC_PRIVATE_NOTIFMSG_H_
#include "wx/private/notifmsg.h"
class wxGenericNotificationMessageImpl : public wxNotificationMessageImpl
{
public:
wxGenericNotificationMessageImpl(wxNotificationMessageBase* notification);
virtual ~wxGenericNotificationMessageImpl();
virtual bool Show(int timeout) override;
virtual bool Close() override;
virtual void SetTitle(const wxString& title) override;
virtual void SetMessage(const wxString& message) override;
virtual void SetParent(wxWindow *parent) override;
virtual void SetFlags(int flags) override;
virtual void SetIcon(const wxIcon& icon) override;
virtual bool AddAction(wxWindowID actionid, const wxString &label) override;
// get/set the default timeout (used if Timeout_Auto is specified)
static int GetDefaultTimeout() { return ms_timeout; }
static void SetDefaultTimeout(int timeout);
private:
// default timeout
static int ms_timeout;
// notification message is represented by a frame in this implementation
class wxNotificationMessageWindow *m_window;
wxDECLARE_NO_COPY_CLASS(wxGenericNotificationMessageImpl);
};
#endif // _WX_GENERIC_PRIVATE_NOTIFMSG_H_

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/richtooltip.h
// Purpose: wxRichToolTipGenericImpl declaration.
// Author: Vadim Zeitlin
// Created: 2011-10-18
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_
#define _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_
#include "wx/bmpbndl.h"
#include "wx/colour.h"
// ----------------------------------------------------------------------------
// wxRichToolTipGenericImpl: defines generic wxRichToolTip implementation.
// ----------------------------------------------------------------------------
class wxRichToolTipGenericImpl : public wxRichToolTipImpl
{
public:
wxRichToolTipGenericImpl(const wxString& title, const wxString& message) :
m_title(title),
m_message(message)
{
m_tipKind = wxTipKind_Auto;
// This is pretty arbitrary, we could follow MSW and use some multiple
// of double-click time here.
m_timeout = 5000;
m_delay = 0;
}
virtual void SetBackgroundColour(const wxColour& col,
const wxColour& colEnd) override;
virtual void SetCustomIcon(const wxBitmapBundle& icon) override;
virtual void SetStandardIcon(int icon) override;
virtual void SetTimeout(unsigned milliseconds,
unsigned millisecondsDelay = 0) override;
virtual void SetTipKind(wxTipKind tipKind) override;
virtual void SetTitleFont(const wxFont& font) override;
virtual void ShowFor(wxWindow* win, const wxRect* rect = nullptr) override;
protected:
wxString m_title,
m_message;
private:
wxBitmapBundle m_icon;
wxColour m_colStart,
m_colEnd;
unsigned m_timeout,
m_delay;
wxTipKind m_tipKind;
wxFont m_titleFont;
};
#endif // _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_

View File

@@ -0,0 +1,154 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/private/rowheightcache.h
// Purpose: height cache of rows in a dataview
// Author: Jens Goepfert (mail@jensgoepfert.de)
// Created: 2018-03-06
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_ROWHEIGHTCACHE_H_
#define _WX_PRIVATE_ROWHEIGHTCACHE_H_
#include <unordered_map>
#include <vector>
// struct describing a range of rows which contains rows <from> .. <to-1>
struct RowRange
{
unsigned int from;
unsigned int to;
};
/**
A helper class that manages a set of RowRange objects.
It stores the indices that are members of a group in a memory
efficient way.
*/
class WXDLLIMPEXP_CORE RowRanges
{
public:
/**
Adds a row index to this group by adding it to an existing RowRange
or by creating a new one.
*/
void Add(unsigned int row);
/**
Removes a row index and all indices after idx from this group.
*/
void Remove(unsigned int row);
/**
Checks whether a row index is contained in this group.
*/
bool Has(unsigned int row) const;
/**
Returns the number of row indices that are contained in this group.
*/
unsigned int CountAll() const;
/**
Returns the number of rows that are in this group before the given row
index.
Not that this doesn't include the given row.
*/
unsigned int CountTo(unsigned int row) const;
/**
Returns the size of the range.
This is only used for testing and debugging.
*/
unsigned int GetSize() const { return m_ranges.size(); }
private:
std::vector<RowRange> m_ranges;
/**
If a new row index was inserted, Cleanup() checks if the neighbour
ranges of idx can includes the same row indices and discards
unnecessary RowRange objects.
*/
void CleanUp(unsigned int idx);
};
/**
HeightCache implements a cache mechanism for wxDataViewCtrl.
It gives fast access to:
* the height of one line (GetLineHeight)
* the y-coordinate where a row starts (GetLineStart)
* and vice versa (GetLineAt)
The layout of the cache is a hashmap where the keys are all existing row
heights in pixels. The values are RowRange objects that represent all rows
having the specified height.
An example:
@code
{
22: RowRange([0..10], [15..17], [20..2000]),
42: RowRange([11..12], [18..18]),
62: RowRange([13..14], [19..19])
}
@endcode
Examples
========
GetLineStart
------------
To retrieve the y-coordinate of item 1000 it is necessary to look into
each key of the hashmap *m_heightToRowRange*. Get the row count of
indices lower than 1000 (RowRange::CountTo) and multiplies it which the
according height.
RowRange([0..10], [15..17], [20..2000]).CountTo(1000)
--> 0..10 are 11 items, 15..17 are 3 items and 20..1000 are 980 items (1000-20)
= 11 + 3 + 980 = 994 items
GetLineStart(1000) --> (22 * 994) + (42 * 3) + (62 * 3) = 22180
GetLineHeight
-------------
To retrieve the line height look into each key and check if row is
contained in RowRange (RowRange::Has)
GetLineAt
---------
To retrieve the row that starts at a specific y-coordinate.
Look into each key and count all rows.
Use bisect algorithm in combination with GetLineStart() to
find the appropriate item
*/
class WXDLLIMPEXP_CORE HeightCache
{
public:
~HeightCache();
bool GetLineStart(unsigned int row, int& start);
bool GetLineHeight(unsigned int row, int& height);
bool GetLineAt(int y, unsigned int& row);
bool GetLineInfo(unsigned int row, int &start, int &height);
void Put(unsigned int row, int height);
/**
Removes the stored height of the given row from the cache and
invalidates all cached rows (including the given one).
*/
void Remove(unsigned int row);
void Clear();
private:
using HeightToRowRangesMap = std::unordered_map<int, RowRanges>;
HeightToRowRangesMap m_heightToRowRange;
};
#endif // _WX_PRIVATE_ROWHEIGHTCACHE_H_

View File

@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/textmeasure.h
// Purpose: Generic wxTextMeasure declaration.
// Author: Vadim Zeitlin
// Created: 2012-10-17
// Copyright: (c) 1997-2012 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_TEXTMEASURE_H_
#define _WX_GENERIC_PRIVATE_TEXTMEASURE_H_
// ----------------------------------------------------------------------------
// wxTextMeasure for the platforms without native support.
// ----------------------------------------------------------------------------
class wxTextMeasure : public wxTextMeasureBase
{
public:
explicit wxTextMeasure(const wxDC *dc, const wxFont *font = nullptr)
: wxTextMeasureBase(dc, font) {}
explicit wxTextMeasure(const wxWindow *win, const wxFont *font = nullptr)
: wxTextMeasureBase(win, font) {}
protected:
virtual void DoGetTextExtent(const wxString& string,
wxCoord *width,
wxCoord *height,
wxCoord *descent = nullptr,
wxCoord *externalLeading = nullptr) override;
virtual bool DoGetPartialTextExtents(const wxString& text,
wxArrayInt& widths,
double scaleX) override;
wxDECLARE_NO_COPY_CLASS(wxTextMeasure);
};
#endif // _WX_GENERIC_PRIVATE_TEXTMEASURE_H_

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/timer.h
// Purpose: Generic implementation of wxTimer class
// Author: Vaclav Slavik
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_TIMER_H_
#define _WX_GENERIC_PRIVATE_TIMER_H_
#if wxUSE_TIMER
#include "wx/private/timer.h"
//-----------------------------------------------------------------------------
// wxTimer
//-----------------------------------------------------------------------------
class wxTimerDesc;
class WXDLLIMPEXP_CORE wxGenericTimerImpl : public wxTimerImpl
{
public:
wxGenericTimerImpl(wxTimer* timer) : wxTimerImpl(timer) { Init(); }
virtual ~wxGenericTimerImpl();
virtual bool Start(int millisecs = -1, bool oneShot = false);
virtual void Stop();
virtual bool IsRunning() const;
// implementation
static void NotifyTimers();
protected:
void Init();
private:
wxTimerDesc *m_desc;
};
#endif // wxUSE_TIMER
#endif // _WX_GENERIC_PRIVATE_TIMER_H_

View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/widthcalc.h
// Purpose: wxMaxWidthCalculatorBase helper class.
// Author: Václav Slavík, Kinaou Hervé
// Copyright: (c) 2015 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_WIDTHCALC_H_
#define _WX_GENERIC_PRIVATE_WIDTHCALC_H_
#include "wx/defs.h"
#if wxUSE_DATAVIEWCTRL || wxUSE_LISTCTRL
#include "wx/log.h"
#include "wx/timer.h"
// ----------------------------------------------------------------------------
// wxMaxWidthCalculatorBase: base class for calculating max column width
// ----------------------------------------------------------------------------
class wxMaxWidthCalculatorBase
{
public:
// column of which calculate the width
explicit wxMaxWidthCalculatorBase(size_t column)
: m_column(column),
m_width(0)
{
}
void UpdateWithWidth(int width)
{
m_width = wxMax(m_width, width);
}
// Update the max with for the expected row
virtual void UpdateWithRow(int row) = 0;
int GetMaxWidth() const { return m_width; }
size_t GetColumn() const { return m_column; }
void
ComputeBestColumnWidth(size_t count,
size_t first_visible,
size_t last_visible)
{
// The code below deserves some explanation. For very large controls, we
// simply can't afford to calculate sizes for all items, it takes too
// long. So the best we can do is to check the first and the last N/2
// items in the control for some sufficiently large N and calculate best
// sizes from that. That can result in the calculated best width being too
// small for some outliers, but it's better to get slightly imperfect
// result than to wait several seconds after every update. To avoid highly
// visible miscalculations, we also include all currently visible items
// no matter what. Finally, the value of N is determined dynamically by
// measuring how much time we spent on the determining item widths so far.
#if wxUSE_STOPWATCH
size_t top_part_end = count;
static const long CALC_TIMEOUT = 20/*ms*/;
// don't call wxStopWatch::Time() too often
static const unsigned CALC_CHECK_FREQ = 100;
wxStopWatch timer;
#else
// use some hard-coded limit, that's the best we can do without timer
size_t top_part_end = wxMin(500, count);
#endif // wxUSE_STOPWATCH/!wxUSE_STOPWATCH
size_t row = 0;
for ( row = 0; row < top_part_end; row++ )
{
#if wxUSE_STOPWATCH
if ( row % CALC_CHECK_FREQ == CALC_CHECK_FREQ-1 &&
timer.Time() > CALC_TIMEOUT )
break;
#endif // wxUSE_STOPWATCH
UpdateWithRow(row);
}
// row is the first unmeasured item now; that's our value of N/2
if ( row < count )
{
top_part_end = row;
// add bottom N/2 items now:
const size_t bottom_part_start = wxMax(row, count - row);
for ( row = bottom_part_start; row < count; row++ )
{
UpdateWithRow(row);
}
// finally, include currently visible items in the calculation:
first_visible = wxMax(first_visible, top_part_end);
last_visible = wxMin(bottom_part_start, last_visible);
for ( row = first_visible; row < last_visible; row++ )
{
UpdateWithRow(row);
}
wxLogTrace("items container",
"determined best size from %zu top, %zu bottom "
"plus %zu more visible items out of %zu total",
top_part_end,
count - bottom_part_start,
last_visible - first_visible,
count);
}
}
private:
const size_t m_column;
int m_width;
wxDECLARE_NO_COPY_CLASS(wxMaxWidthCalculatorBase);
};
#endif // wxUSE_DATAVIEWCTRL || wxUSE_LISTCTRL
#endif // _WX_GENERIC_PRIVATE_WIDTHCALC_H_

View File

@@ -0,0 +1,255 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/prntdlgg.h
// Purpose: wxGenericPrintDialog, wxGenericPrintSetupDialog,
// wxGenericPageSetupDialog
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __PRINTDLGH_G_
#define __PRINTDLGH_G_
#include "wx/defs.h"
#if wxUSE_PRINTING_ARCHITECTURE
#include "wx/dialog.h"
#include "wx/cmndata.h"
#include "wx/prntbase.h"
#include "wx/printdlg.h"
#include "wx/listctrl.h"
#include "wx/dc.h"
#if wxUSE_POSTSCRIPT
#include "wx/dcps.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxComboBox;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
class WXDLLIMPEXP_FWD_CORE wxRadioBox;
class WXDLLIMPEXP_FWD_CORE wxPageSetupDialogData;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// This is not clear why all these enums start with 10 or 30 but do not change it
// without good reason to avoid some subtle backwards compatibility breakage
enum
{
wxPRINTID_STATIC = 10,
wxPRINTID_RANGE,
wxPRINTID_FROM,
wxPRINTID_TO,
wxPRINTID_COPIES,
wxPRINTID_PRINTTOFILE,
wxPRINTID_SETUP
};
enum
{
wxPRINTID_LEFTMARGIN = 30,
wxPRINTID_RIGHTMARGIN,
wxPRINTID_TOPMARGIN,
wxPRINTID_BOTTOMMARGIN
};
enum
{
wxPRINTID_PRINTCOLOUR = 10,
wxPRINTID_ORIENTATION,
wxPRINTID_COMMAND,
wxPRINTID_OPTIONS,
wxPRINTID_PAPERSIZE,
wxPRINTID_PRINTER
};
#if wxUSE_POSTSCRIPT
//----------------------------------------------------------------------------
// wxPostScriptNativeData
//----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPostScriptPrintNativeData: public wxPrintNativeDataBase
{
public:
wxPostScriptPrintNativeData();
virtual ~wxPostScriptPrintNativeData();
virtual bool TransferTo( wxPrintData &data ) override;
virtual bool TransferFrom( const wxPrintData &data ) override;
virtual bool Ok() const override { return IsOk(); }
virtual bool IsOk() const override { return true; }
const wxString& GetPrinterCommand() const { return m_printerCommand; }
const wxString& GetPrinterOptions() const { return m_printerOptions; }
const wxString& GetPreviewCommand() const { return m_previewCommand; }
const wxString& GetFontMetricPath() const { return m_afmPath; }
double GetPrinterScaleX() const { return m_printerScaleX; }
double GetPrinterScaleY() const { return m_printerScaleY; }
long GetPrinterTranslateX() const { return m_printerTranslateX; }
long GetPrinterTranslateY() const { return m_printerTranslateY; }
void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
void SetPrinterScaleX(double x) { m_printerScaleX = x; }
void SetPrinterScaleY(double y) { m_printerScaleY = y; }
void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
#if wxUSE_STREAMS
wxOutputStream *GetOutputStream() { return m_outputStream; }
void SetOutputStream( wxOutputStream *output ) { m_outputStream = output; }
#endif
private:
wxString m_printerCommand;
wxString m_previewCommand;
wxString m_printerOptions;
wxString m_afmPath;
double m_printerScaleX;
double m_printerScaleY;
long m_printerTranslateX;
long m_printerTranslateY;
#if wxUSE_STREAMS
wxOutputStream *m_outputStream;
#endif
private:
wxDECLARE_DYNAMIC_CLASS(wxPostScriptPrintNativeData);
};
// ----------------------------------------------------------------------------
// Simulated Print and Print Setup dialogs for non-Windows platforms (and
// Windows using PostScript print/preview)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericPrintDialog : public wxPrintDialogBase
{
public:
wxGenericPrintDialog(wxWindow *parent,
wxPrintDialogData* data = nullptr);
wxGenericPrintDialog(wxWindow *parent, wxPrintData* data);
virtual ~wxGenericPrintDialog();
void OnSetup(wxCommandEvent& event);
void OnRange(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);
virtual bool TransferDataFromWindow() override;
virtual bool TransferDataToWindow() override;
virtual int ShowModal() override;
wxPrintData& GetPrintData() override
{ return m_printDialogData.GetPrintData(); }
wxPrintDialogData& GetPrintDialogData() override { return m_printDialogData; }
wxDC *GetPrintDC() override;
public:
// wxStaticText* m_printerMessage;
wxButton* m_setupButton;
// wxButton* m_helpButton;
wxRadioBox* m_rangeRadioBox;
wxTextCtrl* m_fromText;
wxTextCtrl* m_toText;
wxTextCtrl* m_noCopiesText;
wxCheckBox* m_printToFileCheckBox;
// wxCheckBox* m_collateCopiesCheckBox;
wxPrintDialogData m_printDialogData;
protected:
void Init(wxWindow *parent);
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericPrintDialog);
};
class WXDLLIMPEXP_CORE wxGenericPrintSetupDialog : public wxDialog
{
public:
// There are no configuration options for the dialog, so we
// just pass the wxPrintData object (no wxPrintSetupDialogData class needed)
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data);
virtual ~wxGenericPrintSetupDialog();
void Init(wxPrintData* data);
void OnPrinter(wxListEvent& event);
virtual bool TransferDataFromWindow() override;
virtual bool TransferDataToWindow() override;
virtual wxComboBox *CreatePaperTypeChoice();
public:
wxListCtrl* m_printerListCtrl;
wxRadioBox* m_orientationRadioBox;
wxTextCtrl* m_printerCommandText;
wxTextCtrl* m_printerOptionsText;
wxCheckBox* m_colourCheckBox;
wxComboBox* m_paperTypeChoice;
wxPrintData m_printData;
wxPrintData& GetPrintData() { return m_printData; }
// After pressing OK, write data here.
wxPrintData* m_targetData;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_CLASS(wxGenericPrintSetupDialog);
};
#endif
// wxUSE_POSTSCRIPT
class WXDLLIMPEXP_CORE wxGenericPageSetupDialog : public wxPageSetupDialogBase
{
public:
wxGenericPageSetupDialog(wxWindow *parent = nullptr,
wxPageSetupDialogData* data = nullptr);
virtual ~wxGenericPageSetupDialog();
virtual bool TransferDataFromWindow() override;
virtual bool TransferDataToWindow() override;
virtual wxPageSetupDialogData& GetPageSetupDialogData() override;
void OnPrinter(wxCommandEvent& event);
wxComboBox *CreatePaperTypeChoice(int* x, int* y);
public:
wxButton* m_printerButton;
wxRadioBox* m_orientationRadioBox;
wxTextCtrl* m_marginLeftText;
wxTextCtrl* m_marginTopText;
wxTextCtrl* m_marginRightText;
wxTextCtrl* m_marginBottomText;
wxComboBox* m_paperTypeChoice;
wxPageSetupDialogData m_pageData;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericPageSetupDialog);
};
#endif
#endif
// __PRINTDLGH_G_

View File

@@ -0,0 +1,232 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/progdlgg.h
// Purpose: wxGenericProgressDialog class
// Author: Karsten Ballueder
// Modified by: Francesco Montorsi
// Created: 09.05.1999
// Copyright: (c) Karsten Ballueder
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __PROGDLGH_G__
#define __PROGDLGH_G__
#include "wx/dialog.h"
#include "wx/weakref.h"
class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxEventLoop;
class WXDLLIMPEXP_FWD_CORE wxGauge;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
class WXDLLIMPEXP_FWD_CORE wxWindowDisabler;
/*
Progress dialog which shows a moving progress bar.
Taken from the Mahogany project.
*/
class WXDLLIMPEXP_CORE wxGenericProgressDialog : public wxDialog
{
public:
wxGenericProgressDialog();
wxGenericProgressDialog(const wxString& title, const wxString& message,
int maximum = 100,
wxWindow *parent = nullptr,
int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
virtual ~wxGenericProgressDialog();
bool Create(const wxString& title,
const wxString& message,
int maximum = 100,
wxWindow *parent = nullptr,
int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = nullptr);
virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = nullptr);
virtual void Resume();
virtual int GetValue() const;
virtual int GetRange() const;
virtual wxString GetMessage() const;
virtual void SetRange(int maximum);
// Return whether "Cancel" or "Skip" button was pressed, always return
// false if the corresponding button is not shown.
virtual bool WasCancelled() const;
virtual bool WasSkipped() const;
// Must provide overload to avoid hiding it (and warnings about it)
virtual void Update() override { wxDialog::Update(); }
virtual bool Show( bool show = true ) override;
// This enum is an implementation detail and should not be used
// by user code.
enum State
{
Uncancelable = -1, // dialog can't be canceled
Canceled, // can be cancelled and, in fact, was
Continue, // can be cancelled but wasn't
Finished, // finished, waiting to be removed from screen
Dismissed // was closed by user after finishing
};
protected:
// Update just the m_maximum field, this is used by public SetRange() but,
// unlike it, doesn't update the controls state. This makes it useful for
// both this class and its derived classes that don't use m_gauge to
// display progress.
void SetMaximum(int maximum);
// Return the labels to use for showing the elapsed/estimated/remaining
// times respectively.
static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); }
static wxString GetEstimatedLabel() { return wxGetTranslation("Estimated time:"); }
static wxString GetRemainingLabel() { return wxGetTranslation("Remaining time:"); }
// Similar to wxWindow::HasFlag() but tests for a presence of a wxPD_XXX
// flag in our (separate) flags instead of using m_windowStyle.
bool HasPDFlag(int flag) const { return (m_pdStyle & flag) != 0; }
// Return the progress dialog style. Prefer to use HasPDFlag() if possible.
int GetPDStyle() const { return m_pdStyle; }
void SetPDStyle(int pdStyle) { m_pdStyle = pdStyle; }
// Updates estimated times from a given progress bar value and stores the
// results in provided arguments.
void UpdateTimeEstimates(int value,
unsigned long &elapsedTime,
unsigned long &estimatedTime,
unsigned long &remainingTime);
// Converts seconds to HH:mm:ss format.
static wxString GetFormattedTime(unsigned long timeInSec);
// Create a new event loop if there is no currently running one.
void EnsureActiveEventLoopExists();
// callback for optional abort button
void OnCancel(wxCommandEvent&);
// callback for optional skip button
void OnSkip(wxCommandEvent&);
// callback to disable "hard" window closing
void OnClose(wxCloseEvent&);
// called to disable the other windows while this dialog is shown
void DisableOtherWindows();
// must be called to re-enable the other windows temporarily disabled while
// the dialog was shown
void ReenableOtherWindows();
// Store the parent window as wxWindow::m_parent and also set the top level
// parent reference we store in this class itself.
void SetTopParent(wxWindow* parent);
// return the top level parent window of this dialog (may be null)
wxWindow *GetTopParent() const { return m_parentTop; }
// continue processing or not (return value for Update())
State m_state;
// the maximum value
int m_maximum;
#if defined(__WXMSW__)
// the factor we use to always keep the value in 16 bit range as the native
// control only supports ranges from 0 to 65,535
size_t m_factor;
#endif // __WXMSW__
// time when the dialog was created
unsigned long m_timeStart;
// time when the dialog was closed or cancelled
unsigned long m_timeStop;
// time between the moment the dialog was closed/cancelled and resume
unsigned long m_break;
private:
// update the label to show the given time (in seconds)
static void SetTimeLabel(unsigned long val, wxStaticText *label);
// common part of all ctors
void Init();
// create the label with given text and another one to show the time nearby
// as the next windows in the sizer, returns the created control
wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
// updates the label message
void UpdateMessage(const wxString &newmsg);
// common part of Update() and Pulse(), returns true if not cancelled
bool DoBeforeUpdate(bool *skip);
// common part of Update() and Pulse()
void DoAfterUpdate();
// shortcuts for enabling buttons
void EnableClose();
void EnableSkip(bool enable = true);
void EnableAbort(bool enable = true);
void DisableSkip() { EnableSkip(false); }
void DisableAbort() { EnableAbort(false); }
// the widget displaying current status (may be null)
wxGauge *m_gauge;
// the message displayed
wxStaticText *m_msg;
// displayed elapsed, estimated, remaining time
wxStaticText *m_elapsed,
*m_estimated,
*m_remaining;
// Reference to the parent top level window, automatically becomes null if
// it is destroyed and could be always null if it's not given at all.
wxWindowRef m_parentTop;
// Progress dialog styles: this is not the same as m_windowStyle because
// wxPD_XXX constants clash with the existing TLW styles so to be sure we
// don't have any conflicts we just use a separate variable for storing
// them.
int m_pdStyle;
// skip some portion
bool m_skip;
// the abort and skip buttons (or nullptr if none)
wxButton *m_btnAbort;
wxButton *m_btnSkip;
// saves the time when elapsed time was updated so there is only one
// update per second
unsigned long m_last_timeupdate;
// tells how often a change of the estimated time has to be confirmed
// before it is actually displayed - this reduces the frequency of updates
// of estimated and remaining time
int m_delay;
// counts the confirmations
int m_ctdelay;
unsigned long m_display_estimated;
// for wxPD_APP_MODAL case
wxWindowDisabler *m_winDisabler;
// Temporary event loop created by the dialog itself if there is no
// currently active loop when it is created.
wxEventLoop *m_tempEventLoop;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxGenericProgressDialog);
};
#endif // __PROGDLGH_G__

View File

@@ -0,0 +1,161 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/propdlg.h
// Purpose: wxPropertySheetDialog
// Author: Julian Smart
// Created: 2005-03-12
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PROPDLG_H_
#define _WX_PROPDLG_H_
#include "wx/defs.h"
#if wxUSE_BOOKCTRL
#include "wx/dialog.h"
class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
//-----------------------------------------------------------------------------
// wxPropertySheetDialog
// A platform-independent properties dialog with a notebook and standard
// buttons.
//
// To use this class, call Create from your derived class.
// Then create pages and add to the book control. Finally call CreateButtons and
// LayoutDialog.
//
// For example:
//
// MyPropertySheetDialog::Create(...)
// {
// wxPropertySheetDialog::Create(...);
//
// // Add page
// wxPanel* panel = new wxPanel(GetBookCtrl(), ...);
// GetBookCtrl()->AddPage(panel, wxT("General"));
//
// CreateButtons();
// LayoutDialog();
// }
//
// Override CreateBookCtrl and AddBookCtrl to create and add a different
// kind of book control.
//-----------------------------------------------------------------------------
enum wxPropertySheetDialogFlags
{
// Use the platform default
wxPROPSHEET_DEFAULT = 0x0001,
// Use a notebook
wxPROPSHEET_NOTEBOOK = 0x0002,
// Use a toolbook
wxPROPSHEET_TOOLBOOK = 0x0004,
// Use a choicebook
wxPROPSHEET_CHOICEBOOK = 0x0008,
// Use a listbook
wxPROPSHEET_LISTBOOK = 0x0010,
// Use a wxButtonToolBar toolbook
wxPROPSHEET_BUTTONTOOLBOOK = 0x0020,
// Use a treebook
wxPROPSHEET_TREEBOOK = 0x0040,
// Shrink dialog to fit current page
wxPROPSHEET_SHRINKTOFIT = 0x0100
};
class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog
{
public:
wxPropertySheetDialog() : wxDialog() { Init(); }
wxPropertySheetDialog(wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxASCII_STR(wxDialogNameStr))
{
Init();
Create(parent, id, title, pos, sz, style, name);
}
bool Create(wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxASCII_STR(wxDialogNameStr));
//// Accessors
// Set and get the notebook
void SetBookCtrl(wxBookCtrlBase* book) { m_bookCtrl = book; }
wxBookCtrlBase* GetBookCtrl() const { return m_bookCtrl; }
// Override function in base
virtual wxWindow* GetContentWindow() const override;
// Set and get the inner sizer
void SetInnerSizer(wxSizer* sizer) { m_innerSizer = sizer; }
wxSizer* GetInnerSizer() const { return m_innerSizer ; }
// Set and get the book style
void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; }
long GetSheetStyle() const { return m_sheetStyle ; }
// Set and get the border around the whole dialog
void SetSheetOuterBorder(int border) { m_sheetOuterBorder = border; }
int GetSheetOuterBorder() const { return m_sheetOuterBorder ; }
// Set and get the border around the book control only
void SetSheetInnerBorder(int border) { m_sheetInnerBorder = border; }
int GetSheetInnerBorder() const { return m_sheetInnerBorder ; }
/// Operations
// Creates the buttons
virtual void CreateButtons(int flags = wxOK|wxCANCEL);
// Lay out the dialog, to be called after pages have been created
virtual void LayoutDialog(int centreFlags = wxBOTH);
/// Implementation
// Creates the book control. If you want to use a different kind of
// control, override.
virtual wxBookCtrlBase* CreateBookCtrl();
// Adds the book control to the inner sizer.
virtual void AddBookCtrl(wxSizer* sizer);
// Resize dialog if necessary
void OnIdle(wxIdleEvent& event);
private:
void Init();
protected:
wxBookCtrlBase* m_bookCtrl;
wxSizer* m_innerSizer; // sizer for extra space
long m_sheetStyle;
int m_sheetOuterBorder;
int m_sheetInnerBorder;
int m_selectedPage;
wxDECLARE_DYNAMIC_CLASS(wxPropertySheetDialog);
wxDECLARE_EVENT_TABLE();
};
#endif // wxUSE_BOOKCTRL
#endif // _WX_PROPDLG_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/region.h
// Purpose: generic wxRegion class
// Author: David Elliott
// Created: 2004/04/12
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_REGION_H__
#define _WX_GENERIC_REGION_H__
class WXDLLIMPEXP_CORE wxRegionGeneric : public wxRegionBase
{
public:
wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegionGeneric(const wxRect& rect);
wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
wxRegionGeneric(const wxBitmap& bmp);
wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0);
wxRegionGeneric();
virtual ~wxRegionGeneric();
// wxRegionBase pure virtuals
virtual void Clear();
virtual bool IsEmpty() const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
friend class WXDLLIMPEXP_FWD_CORE wxRegionIteratorGeneric;
};
class WXDLLIMPEXP_CORE wxRegionIteratorGeneric : public wxObject
{
public:
wxRegionIteratorGeneric();
wxRegionIteratorGeneric(const wxRegionGeneric& region);
wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator);
virtual ~wxRegionIteratorGeneric();
wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator);
void Reset() { m_current = 0; }
void Reset(const wxRegionGeneric& region);
operator bool () const { return HaveRects(); }
bool HaveRects() const;
wxRegionIteratorGeneric& operator++();
wxRegionIteratorGeneric operator++(int);
long GetX() const;
long GetY() const;
long GetW() const;
long GetWidth() const { return GetW(); }
long GetH() const;
long GetHeight() const { return GetH(); }
wxRect GetRect() const;
private:
long m_current;
wxRegionGeneric m_region;
};
#endif // _WX_GENERIC_REGION_H__

View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/richmsgdlgg.h
// Purpose: wxGenericRichMessageDialog
// Author: Rickard Westerlund
// Created: 2010-07-04
// Copyright: (c) 2010 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_RICHMSGDLGG_H_
#define _WX_GENERIC_RICHMSGDLGG_H_
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
class WXDLLIMPEXP_FWD_CORE wxCollapsiblePane;
class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent;
class WXDLLIMPEXP_CORE wxGenericRichMessageDialog
: public wxRichMessageDialogBase
{
public:
wxGenericRichMessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxMessageBoxCaptionStr),
long style = wxOK | wxCENTRE)
: wxRichMessageDialogBase( parent, message, caption, style ),
m_checkBox(nullptr),
m_detailsPane(nullptr)
{ }
virtual bool IsCheckBoxChecked() const override;
protected:
wxCheckBox *m_checkBox;
wxCollapsiblePane *m_detailsPane;
// overrides methods in the base class
virtual void AddMessageDialogCheckBox(wxSizer *sizer) override;
virtual void AddMessageDialogDetails(wxSizer *sizer) override;
private:
void OnPaneChanged(wxCollapsiblePaneEvent& event);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxGenericRichMessageDialog);
};
#endif // _WX_GENERIC_RICHMSGDLGG_H_

View File

@@ -0,0 +1,252 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/sashwin.h
// Purpose: wxSashWindow implementation. A sash window has an optional
// sash on each edge, allowing it to be dragged. An event
// is generated when the sash is released.
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SASHWIN_H_G_
#define _WX_SASHWIN_H_G_
#include "wx/defs.h"
#if wxUSE_SASH
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/string.h"
#define wxSASH_DRAG_NONE 0
#define wxSASH_DRAG_DRAGGING 1
#define wxSASH_DRAG_LEFT_DOWN 2
enum wxSashEdgePosition {
wxSASH_TOP = 0,
wxSASH_RIGHT,
wxSASH_BOTTOM,
wxSASH_LEFT,
wxSASH_NONE = 100
};
/*
* wxSashEdge represents one of the four edges of a window.
*/
class WXDLLIMPEXP_CORE wxSashEdge
{
public:
wxSashEdge()
{ m_show = false;
m_margin = 0; }
bool m_show; // Is the sash showing?
int m_margin; // The margin size
};
/*
* wxSashWindow flags
*/
#define wxSW_NOBORDER 0x0000
//#define wxSW_3D 0x0010
#define wxSW_BORDER 0x0020
#define wxSW_3DSASH 0x0040
#define wxSW_3DBORDER 0x0080
#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER)
/*
* wxSashWindow allows any of its edges to have a sash which can be dragged
* to resize the window. The actual content window will be created as a child
* of wxSashWindow.
*/
class WXDLLIMPEXP_CORE wxSashWindow: public wxWindow
{
public:
// Default constructor
wxSashWindow()
{
Init();
}
// Normal constructor
wxSashWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"))
{
Init();
Create(parent, id, pos, size, style, name);
}
virtual ~wxSashWindow();
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"));
// Set whether there's a sash in this position
void SetSashVisible(wxSashEdgePosition edge, bool sash);
// Get whether there's a sash in this position
bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
// Get border size
int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; }
// Sets the default sash border size
void SetDefaultBorderSize(int width) { m_borderSize = width; }
// Gets the default sash border size
int GetDefaultBorderSize() const { return m_borderSize; }
// Sets the addition border size between child and sash window
void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
// Gets the addition border size between child and sash window
int GetExtraBorderSize() const { return m_extraBorderSize; }
virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; }
virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; }
virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; }
virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; }
virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; }
virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; }
virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; }
virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; }
////////////////////////////////////////////////////////////////////////////
// Implementation
// Paints the border and sash
void OnPaint(wxPaintEvent& event);
// Handles mouse events
void OnMouseEvent(wxMouseEvent& ev);
// Adjusts the panes
void OnSize(wxSizeEvent& event);
#if defined(__WXMSW__) || defined(__WXMAC__)
// Handle cursor correctly
void OnSetCursor(wxSetCursorEvent& event);
#endif // wxMSW
// Draws borders
void DrawBorders(wxDC& dc);
// Draws the sashes
void DrawSash(wxSashEdgePosition edge, wxDC& dc);
// Draws the sashes
void DrawSashes(wxDC& dc);
// Draws the sash tracker (for whilst moving the sash)
void DrawSashTracker(wxSashEdgePosition edge, int x, int y);
// Tests for x, y over sash
wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
// Resizes subwindows
void SizeWindows();
// Initialize colours
void InitColours();
private:
void Init();
wxSashEdge m_sashes[4];
int m_dragMode;
wxSashEdgePosition m_draggingEdge;
int m_oldX;
int m_oldY;
int m_borderSize;
int m_extraBorderSize;
int m_firstX;
int m_firstY;
int m_minimumPaneSizeX;
int m_minimumPaneSizeY;
int m_maximumPaneSizeX;
int m_maximumPaneSizeY;
wxCursor* m_sashCursorWE;
wxCursor* m_sashCursorNS;
wxColour m_lightShadowColour;
wxColour m_mediumShadowColour;
wxColour m_darkShadowColour;
wxColour m_hilightColour;
wxColour m_faceColour;
bool m_mouseCaptured;
wxCursor* m_currentCursor;
private:
wxDECLARE_DYNAMIC_CLASS(wxSashWindow);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxSashWindow);
};
class WXDLLIMPEXP_FWD_CORE wxSashEvent;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_SASH_DRAGGED, wxSashEvent );
enum wxSashDragStatus
{
wxSASH_STATUS_OK,
wxSASH_STATUS_OUT_OF_RANGE
};
class WXDLLIMPEXP_CORE wxSashEvent: public wxCommandEvent
{
public:
wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE)
{
m_eventType = (wxEventType) wxEVT_SASH_DRAGGED;
m_id = id;
m_edge = edge;
}
wxSashEvent(const wxSashEvent& event)
: wxCommandEvent(event),
m_edge(event.m_edge),
m_dragRect(event.m_dragRect),
m_dragStatus(event.m_dragStatus) { }
void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
wxSashEdgePosition GetEdge() const { return m_edge; }
//// The rectangle formed by the drag operation
void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
wxRect GetDragRect() const { return m_dragRect; }
//// Whether the drag caused the rectangle to be reversed (e.g.
//// dragging the top below the bottom)
void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
wxNODISCARD virtual wxEvent *Clone() const override { return new wxSashEvent(*this); }
private:
wxSashEdgePosition m_edge;
wxRect m_dragRect;
wxSashDragStatus m_dragStatus = wxSASH_STATUS_OK;
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSashEvent);
};
typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
#define wxSashEventHandler(func) \
wxEVENT_HANDLER_CAST(wxSashEventFunction, func)
#define EVT_SASH_DRAGGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_SASH_DRAGGED, id, wxSashEventHandler(fn))
#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \
wx__DECLARE_EVT2(wxEVT_SASH_DRAGGED, id1, id2, wxSashEventHandler(fn))
#endif // wxUSE_SASH
#endif
// _WX_SASHWIN_H_G_

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/scrolwin.h
// Purpose: generic wxScrollHelper
// Author: Vadim Zeitlin
// Created: 2008-12-24 (replacing old file with the same name)
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SCROLLWIN_H_
#define _WX_GENERIC_SCROLLWIN_H_
#include "wx/recguard.h"
// ----------------------------------------------------------------------------
// generic wxScrollHelper implementation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxScrollHelper : public wxScrollHelperBase
{
public:
wxScrollHelper(wxWindow *winToScroll);
// implement base class pure virtuals
virtual void AdjustScrollbars() override;
virtual bool IsScrollbarShown(int orient) const override;
protected:
virtual void DoScroll(int x, int y) override;
virtual void DoShowScrollbars(wxScrollbarVisibility horz,
wxScrollbarVisibility vert) override;
private:
// helper of AdjustScrollbars(): does the work for the single scrollbar
//
// notice that the parameters passed by non-const references are modified
// by this function
void DoAdjustScrollbar(int orient,
int clientSize,
int virtSize,
int pixelsPerUnit,
int& scrollUnits,
int& scrollPosition,
int& scrollLinesPerPage,
wxScrollbarVisibility visibility);
wxScrollbarVisibility m_xVisibility,
m_yVisibility;
wxRecursionGuardFlag m_adjustScrollFlagReentrancy;
wxDECLARE_NO_COPY_CLASS(wxScrollHelper);
};
#endif // _WX_GENERIC_SCROLLWIN_H_

View File

@@ -0,0 +1,436 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/spinctlg.h
// Purpose: generic wxSpinCtrl class
// Author: Vadim Zeitlin
// Created: 28.10.99
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SPINCTRL_H_
#define _WX_GENERIC_SPINCTRL_H_
// ----------------------------------------------------------------------------
// wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if
// wxSpinButton is available, this is what we do - but if it isn't, we still
// define wxSpinCtrl class which then has the same appearance as wxTextCtrl but
// the different interface. This allows to write programs using wxSpinCtrl
// without tons of #ifdefs.
// ----------------------------------------------------------------------------
#if wxUSE_SPINBTN
#include "wx/compositewin.h"
class WXDLLIMPEXP_FWD_CORE wxSpinButton;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class wxSpinCtrlTextGeneric; // wxTextCtrl used for the wxSpinCtrlGenericBase
// The !wxUSE_SPINBTN version's GetValue() function conflicts with the
// wxTextCtrl's GetValue() and so you have to input a dummy int value.
#define wxSPINCTRL_GETVALUE_FIX
// ----------------------------------------------------------------------------
// wxSpinCtrlGeneric is a combination of wxTextCtrl and wxSpinButton
//
// This class manages a double valued generic spinctrl through the DoGet/SetXXX
// functions that are made public as Get/SetXXX functions for int or double
// for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid
// function ambiguity.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase
: public wxNavigationEnabled<wxCompositeWindow<wxSpinCtrlBase> >
{
public:
wxSpinCtrlGenericBase() { Init(); }
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
double min = 0, double max = 100, double initial = 0,
double inc = 1,
const wxString& name = wxT("wxSpinCtrl"));
virtual ~wxSpinCtrlGenericBase();
// accessors
virtual wxString GetTextValue() const override;
// T GetValue() const
// T GetMin() const
// T GetMax() const
// T GetIncrement() const
virtual bool GetSnapToTicks() const override { return m_snap_to_ticks; }
// unsigned GetDigits() const - wxSpinCtrlDouble only
// operations
virtual void SetValue(const wxString& text) override;
// void SetValue(T val)
// void SetRange(T minVal, T maxVal)
// void SetIncrement(T inc)
virtual void SetSnapToTicks(bool snap_to_ticks) override;
// void SetDigits(unsigned digits) - wxSpinCtrlDouble only
// Select text in the textctrl
void SetSelection(long from, long to) override;
// implementation from now on
// forward these functions to all subcontrols
virtual bool Enable(bool enable = true) override;
virtual bool Show(bool show = true) override;
virtual bool SetBackgroundColour(const wxColour& colour) override;
// get the subcontrols
wxTextCtrl *GetText() const { return m_textCtrl; }
wxSpinButton *GetSpinButton() const { return m_spinButton; }
// forwarded events from children windows
void OnSpinButton(wxSpinEvent& event);
void OnTextLostFocus(wxFocusEvent& event);
void OnTextChar(wxKeyEvent& event);
void OnMouseWheel(wxMouseEvent& event);
// this window itself is used only as a container for its sub windows so it
// shouldn't accept the focus at all and any attempts to explicitly set
// focus to it should give focus to its text constol part
virtual bool AcceptsFocus() const override { return false; }
virtual void SetFocus() override;
friend class wxSpinCtrlTextGeneric;
protected:
// override the base class virtuals involved into geometry calculations
virtual wxSize DoGetBestSize() const override;
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const override;
virtual void DoMoveWindow(int x, int y, int width, int height) override;
#ifdef __WXMSW__
// and, for MSW, enabling this window itself
virtual void DoEnable(bool enable) override;
#endif // __WXMSW__
enum SendEvent
{
SendEvent_None,
SendEvent_Text
};
// generic double valued functions
double DoGetValue() const { return m_value; }
bool DoSetValue(double val, SendEvent sendEvent);
void DoSetRange(double min_val, double max_val);
void DoSetIncrement(double inc);
// update our value to reflect the text control contents (if it has been
// modified by user, do nothing otherwise)
//
// can also change the text control if its value is invalid
//
// return true if our value has changed
bool SyncSpinToText(SendEvent sendEvent);
// Send the correct event type
virtual void DoSendEvent() = 0;
// Convert the text to/from the corresponding value.
virtual bool DoTextToValue(const wxString& text, double *val) = 0;
virtual wxString DoValueToText(double val) = 0;
// check if the value is in range
bool InRange(double n) const { return (n >= m_min) && (n <= m_max); }
// adjust the value to fit the range and snap it to ticks if necessary
double AdjustAndSnap(double value) const;
// ensure that the value is in range wrapping it round if necessary
double AdjustToFitInRange(double value) const;
// Assign validator with current parameters
virtual void ResetTextValidator() = 0;
double m_value;
double m_min;
double m_max;
double m_increment;
bool m_snap_to_ticks;
int m_spin_value;
// the subcontrols
wxTextCtrl *m_textCtrl;
wxSpinButton *m_spinButton;
private:
// common part of all ctors
void Init();
// Implement pure virtual function inherited from wxCompositeWindow.
virtual wxWindowList GetCompositeWindowParts() const override;
wxDECLARE_EVENT_TABLE();
};
#else // !wxUSE_SPINBTN
#define wxSPINCTRL_GETVALUE_FIX int = 1
// ----------------------------------------------------------------------------
// wxSpinCtrl is just a text control
// ----------------------------------------------------------------------------
#include "wx/textctrl.h"
class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl
{
public:
wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100),
m_increment(1), m_snap_to_ticks(false),
m_format(wxT("%g")) { }
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
double min = 0, double max = 100, double initial = 0,
double inc = 1,
const wxString& name = wxT("wxSpinCtrl"))
{
m_min = min;
m_max = max;
m_value = initial;
m_increment = inc;
bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
wxDefaultValidator, name);
DoSetValue(initial, SendEvent_None);
return ok;
}
// accessors
// T GetValue() const
// T GetMin() const
// T GetMax() const
// T GetIncrement() const
virtual bool GetSnapToTicks() const { return m_snap_to_ticks; }
// unsigned GetDigits() const - wxSpinCtrlDouble only
// operations
virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); }
// void SetValue(T val)
// void SetRange(T minVal, T maxVal)
// void SetIncrement(T inc)
virtual void SetSnapToTicks(bool snap_to_ticks)
{ m_snap_to_ticks = snap_to_ticks; }
// void SetDigits(unsigned digits) - wxSpinCtrlDouble only
// Select text in the textctrl
//void SetSelection(long from, long to);
protected:
// generic double valued
double DoGetValue() const
{
double n;
if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) )
n = INT_MIN;
return n;
}
bool DoSetValue(double val, SendEvent sendEvent)
{
wxString str(wxString::Format(m_format, val));
switch ( sendEvent )
{
case SendEvent_None:
wxTextCtrl::ChangeValue(str);
break;
case SendEvent_Text:
wxTextCtrl::SetValue(str);
break;
}
return true;
}
void DoSetRange(double min_val, double max_val)
{
m_min = min_val;
m_max = max_val;
}
void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused
double m_value;
double m_min;
double m_max;
double m_increment;
bool m_snap_to_ticks;
wxString m_format;
};
#endif // wxUSE_SPINBTN/!wxUSE_SPINBTN
#if !defined(wxHAS_NATIVE_SPINCTRL)
//-----------------------------------------------------------------------------
// wxSpinCtrl
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase
{
public:
wxSpinCtrl() { Init(); }
wxSpinCtrl(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
int min = 0, int max = 100, int initial = 0,
const wxString& name = wxT("wxSpinCtrl"))
{
Init();
Create(parent, id, value, pos, size, style, min, max, initial, name);
}
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
int min = 0, int max = 100, int initial = 0,
const wxString& name = wxT("wxSpinCtrl"))
{
return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size,
style, min, max, initial, 1, name);
}
// accessors
int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); }
int GetMin() const { return int(m_min); }
int GetMax() const { return int(m_max); }
int GetIncrement() const { return int(m_increment); }
// operations
virtual void SetValue(const wxString& value) override
{ wxSpinCtrlGenericBase::SetValue(value); }
void SetValue( int value ) { DoSetValue(value, SendEvent_None); }
void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); }
void SetIncrement(int inc) { DoSetIncrement(inc); }
virtual int GetBase() const override { return m_base; }
virtual bool SetBase(int base) override;
protected:
virtual void DoSendEvent() override;
virtual bool DoTextToValue(const wxString& text, double *val) override;
virtual wxString DoValueToText(double val) override;
virtual void ResetTextValidator() override;
private:
// Common part of all ctors.
void Init()
{
m_base = 10;
}
int m_base;
wxDECLARE_DYNAMIC_CLASS(wxSpinCtrl);
};
#endif // wxHAS_NATIVE_SPINCTRL
//-----------------------------------------------------------------------------
// wxSpinCtrlDouble
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase
{
public:
wxSpinCtrlDouble() { Init(); }
wxSpinCtrlDouble(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
double min = 0, double max = 100, double initial = 0,
double inc = 1,
const wxString& name = wxT("wxSpinCtrlDouble"))
{
Init();
Create(parent, id, value, pos, size, style,
min, max, initial, inc, name);
}
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_ARROW_KEYS,
double min = 0, double max = 100, double initial = 0,
double inc = 1,
const wxString& name = wxT("wxSpinCtrlDouble"));
// accessors
double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); }
double GetMin() const { return m_min; }
double GetMax() const { return m_max; }
double GetIncrement() const { return m_increment; }
unsigned GetDigits() const { return m_digits; }
// operations
void SetValue(const wxString& value) override
{ wxSpinCtrlGenericBase::SetValue(value); }
void SetValue(double value) { DoSetValue(value, SendEvent_None); }
void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); }
void SetIncrement(double inc);
void SetDigits(unsigned digits);
// We don't implement bases support for floating point numbers, this is not
// very useful in practice.
virtual int GetBase() const override { return 10; }
virtual bool SetBase(int WXUNUSED(base)) override { return false; }
protected:
virtual void DoSendEvent() override;
virtual bool DoTextToValue(const wxString& text, double *val) override;
virtual wxString DoValueToText(double val) override;
virtual void ResetTextValidator() override;
unsigned m_digits;
private:
// Common part of all ctors.
void Init()
{
DoSetDigits(0);
}
// Just set the number of digits and the format unconditionally.
void DoSetDigits(unsigned digits);
// Call DoSetDigits() and update the appearance.
void DoSetDigitsAndUpdate(unsigned digits);
wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble);
};
#endif // _WX_GENERIC_SPINCTRL_H_

View File

@@ -0,0 +1,96 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/splash.h
// Purpose: Splash screen class
// Author: Julian Smart
// Created: 28/6/2000
// Copyright: (c) Julian Smart
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPLASH_H_
#define _WX_SPLASH_H_
#include "wx/bitmap.h"
#include "wx/eventfilter.h"
#include "wx/frame.h"
#include "wx/timer.h"
/*
* A window for displaying a splash screen
*/
#define wxSPLASH_CENTRE_ON_PARENT 0x01
#define wxSPLASH_CENTRE_ON_SCREEN 0x02
#define wxSPLASH_NO_CENTRE 0x00
#define wxSPLASH_TIMEOUT 0x04
#define wxSPLASH_NO_TIMEOUT 0x00
class WXDLLIMPEXP_FWD_CORE wxSplashScreenWindow;
/*
* wxSplashScreen
*/
class WXDLLIMPEXP_CORE wxSplashScreen: public wxFrame,
public wxEventFilter
{
public:
// for RTTI macros only
wxSplashScreen() { Init(); }
wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds,
wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP);
virtual ~wxSplashScreen();
void OnCloseWindow(wxCloseEvent& event);
void OnNotify(wxTimerEvent& event);
long GetSplashStyle() const { return m_splashStyle; }
wxSplashScreenWindow* GetSplashWindow() const { return m_window; }
int GetTimeout() const { return m_milliseconds; }
// Override wxEventFilter method to hide splash screen on any user input.
virtual int FilterEvent(wxEvent& event) override;
protected:
// Common part of all ctors.
void Init();
wxSplashScreenWindow* m_window;
long m_splashStyle;
int m_milliseconds;
wxTimer m_timer;
wxDECLARE_DYNAMIC_CLASS(wxSplashScreen);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxSplashScreen);
};
/*
* wxSplashScreenWindow
*/
class WXDLLIMPEXP_CORE wxSplashScreenWindow: public wxWindow
{
public:
wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
void OnPaint(wxPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
wxBitmap& GetBitmap() { return m_bitmap; }
protected:
wxBitmap m_bitmap;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxSplashScreenWindow);
};
#endif
// _WX_SPLASH_H_

View File

@@ -0,0 +1,463 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/splitter.h
// Purpose: wxSplitterWindow class
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SPLITTER_H_
#define _WX_GENERIC_SPLITTER_H_
#include "wx/window.h" // base class declaration
#include "wx/containr.h" // wxControlContainer
#include "wx/overlay.h"
class WXDLLIMPEXP_FWD_CORE wxSplitterEvent;
// ---------------------------------------------------------------------------
// splitter constants
// ---------------------------------------------------------------------------
enum wxSplitMode
{
wxSPLIT_HORIZONTAL = 1,
wxSPLIT_VERTICAL
};
enum
{
wxSPLIT_DRAG_NONE,
wxSPLIT_DRAG_DRAGGING,
wxSPLIT_DRAG_LEFT_DOWN
};
// ---------------------------------------------------------------------------
// wxSplitterWindow maintains one or two panes, with
// an optional vertical or horizontal split which
// can be used with the mouse or programmatically.
// ---------------------------------------------------------------------------
// TODO:
// 1) Perhaps make the borders sensitive to dragging in order to create a split.
// The MFC splitter window manages scrollbars as well so is able to
// put sash buttons on the scrollbars, but we probably don't want to go down
// this path.
// 2) for wxWidgets 2.0, we must find a way to set the WS_CLIPCHILDREN style
// to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be
// standard).
class WXDLLIMPEXP_CORE wxSplitterWindow: public wxNavigationEnabled<wxWindow>
{
public:
////////////////////////////////////////////////////////////////////////////
// Public API
// Default constructor
wxSplitterWindow()
{
Init();
}
// Normal constructor
wxSplitterWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_3D,
const wxString& name = wxT("splitter"))
{
Init();
Create(parent, id, pos, size, style, name);
}
virtual ~wxSplitterWindow();
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_3D,
const wxString& name = wxT("splitter"));
// Gets the only or left/top pane
wxWindow *GetWindow1() const { return m_windowOne; }
// Gets the right/bottom pane
wxWindow *GetWindow2() const { return m_windowTwo; }
// Sets the split mode
void SetSplitMode(int mode)
{
wxASSERT_MSG( mode == wxSPLIT_VERTICAL || mode == wxSPLIT_HORIZONTAL,
wxT("invalid split mode") );
m_splitMode = (wxSplitMode)mode;
}
// Gets the split mode
wxSplitMode GetSplitMode() const { return m_splitMode; }
// Initialize with one window
void Initialize(wxWindow *window);
// Associates the given window with window 2, drawing the appropriate sash
// and changing the split mode.
// Does nothing and returns false if the window is already split.
// A sashPosition of 0 means choose a default sash position,
// negative sashPosition specifies the size of right/lower pane as its
// absolute value rather than the size of left/upper pane.
virtual bool SplitVertically(wxWindow *window1,
wxWindow *window2,
int sashPosition = 0)
{ return DoSplit(wxSPLIT_VERTICAL, window1, window2, sashPosition); }
virtual bool SplitHorizontally(wxWindow *window1,
wxWindow *window2,
int sashPosition = 0)
{ return DoSplit(wxSPLIT_HORIZONTAL, window1, window2, sashPosition); }
// Removes the specified (or second) window from the view
// Doesn't actually delete the window.
bool Unsplit(wxWindow *toRemove = nullptr);
// Replaces one of the windows with another one (neither old nor new
// parameter should be null)
bool ReplaceWindow(wxWindow *winOld, wxWindow *winNew);
// Make sure the child window sizes are updated. This is useful
// for reducing flicker by updating the sizes before a
// window is shown, if you know the overall size is correct.
void UpdateSize();
// Is the window split?
bool IsSplit() const { return (m_windowTwo != nullptr); }
// Sets the border size
void SetBorderSize(int WXUNUSED(width)) { }
// Hide or show the sash and test whether it's currently hidden.
void SetSashInvisible(bool invisible = true);
bool IsSashInvisible() const { return HasFlag(wxSP_NOSASH); }
// Gets the current sash size which may be 0 if it's hidden and the default
// sash size.
int GetSashSize() const;
int GetDefaultSashSize() const;
// Gets the border size
int GetBorderSize() const;
// Set the sash position
void SetSashPosition(int position, bool redraw = true);
// Gets the sash position
int GetSashPosition() const { return m_sashPosition; }
// Set the sash gravity
void SetSashGravity(double gravity);
// Gets the sash gravity
double GetSashGravity() const { return m_sashGravity; }
// If this is zero, we can remove panes by dragging the sash.
void SetMinimumPaneSize(int min);
int GetMinimumPaneSize() const { return m_minimumPaneSize; }
// NB: the OnXXX() functions below are for backwards compatibility only,
// don't use them in new code but handle the events instead!
// called when the sash position is about to change, may return a new value
// for the sash or -1 to prevent the change from happening at all
virtual int OnSashPositionChanging(int newSashPosition);
// Called when the sash position is about to be changed, return
// false from here to prevent the change from taking place.
// Repositions sash to minimum position if pane would be too small.
// newSashPosition here is always positive or zero.
virtual bool OnSashPositionChange(int newSashPosition);
// If the sash is moved to an extreme position, a subwindow
// is removed from the splitter window, and the app is
// notified. The app should delete or hide the window.
virtual void OnUnsplit(wxWindow *removed);
// Called when the sash is double-clicked.
// The default behaviour is to remove the sash if the
// minimum pane size is zero.
virtual void OnDoubleClickSash(int x, int y);
////////////////////////////////////////////////////////////////////////////
// Implementation
// Paints the border and sash
void OnPaint(wxPaintEvent& event);
// Handles mouse events
void OnMouseEvent(wxMouseEvent& ev);
// Aborts dragging mode
void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
// Adjusts the panes
void OnSize(wxSizeEvent& event);
void OnDPIChanged(wxDPIChangedEvent& event);
// In live mode, resize child windows in idle time
void OnInternalIdle() override;
// Draws the sash
virtual void DrawSash(wxDC& dc);
// Draws the sash tracker (for whilst moving the sash)
virtual void DrawSashTracker(int x, int y);
// Tests for x, y over sash
virtual bool SashHitTest(int x, int y);
// Resizes subwindows
virtual void SizeWindows();
#ifdef __WXMAC__
virtual bool MacClipGrandChildren() const override { return true ; }
#endif
// Sets the sash size: this doesn't do anything and shouldn't be used at
// all any more.
wxDEPRECATED_INLINE( void SetSashSize(int WXUNUSED(width)), return; )
// Get the sash position that was last used before Unsplit() was called.
// Horizontal and vertical components correspond to the split in the
// corresponding direction, and are 0 if the splitter hadn't been split in
// this direction at all.
wxPoint GetLastSplitPosition() const;
// Set the default initial sash position to use when the splitter is split.
void SetLastSplitPosition(const wxPoint& pos);
protected:
// event handlers
#if defined(__WXMSW__) || defined(__WXMAC__)
void OnSetCursor(wxSetCursorEvent& event);
#endif // wxMSW
// common part of all ctors
void Init();
// common part of SplitVertically() and SplitHorizontally()
bool DoSplit(wxSplitMode mode,
wxWindow *window1, wxWindow *window2,
int sashPosition);
// adjusts sash position with respect to min. pane and window sizes
int AdjustSashPosition(int sashPos) const;
// get either width or height depending on the split mode
int GetWindowSize() const;
// convert the user specified sash position which may be > 0 (as is), < 0
// (specifying the size of the right pane) or 0 (use default) to the real
// position to be passed to DoSetSashPosition()
int ConvertSashPosition(int sashPos) const;
// set the real sash position, sashPos here must be positive
//
// returns true if the sash position has been changed, false otherwise
bool DoSetSashPosition(int sashPos);
// set the sash position and send an event about it having been changed
void SetSashPositionAndNotify(int sashPos);
// callbacks executed when we detect that the mouse has entered or left
// the sash
virtual void OnEnterSash();
virtual void OnLeaveSash();
// set the cursor appropriate for the current split mode
void SetResizeCursor();
// redraw the splitter if its "hotness" changed if necessary
void RedrawIfHotSensitive(bool isHot);
// return the best size of the splitter equal to best sizes of its
// subwindows
virtual wxSize DoGetBestSize() const override;
wxSplitMode m_splitMode;
wxWindow* m_windowOne;
wxWindow* m_windowTwo;
int m_dragMode;
int m_oldX; // current tracker position if not live mode
int m_oldY; // current tracker position if not live mode
int m_sashPosition; // Number of pixels from left or top
double m_sashGravity;
wxSize m_lastSize;
int m_requestedSashPosition;
int m_sashPositionCurrent; // while dragging
wxPoint m_ptStart; // mouse position when dragging started
int m_sashStart; // sash position when dragging started
int m_minimumPaneSize;
wxPoint m_lastSplitPosition;
wxCursor m_sashCursorWE;
wxCursor m_sashCursorNS;
wxOverlay m_overlay;
// when in live mode, set this to true to resize children in idle
bool m_needUpdating:1;
bool m_permitUnsplitAlways:1;
bool m_isHot:1;
private:
wxDECLARE_DYNAMIC_CLASS(wxSplitterWindow);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxSplitterWindow);
};
// ----------------------------------------------------------------------------
// event class and macros
// ----------------------------------------------------------------------------
// we reuse the same class for all splitter event types because this is the
// usual wxWin convention, but the three event types have different kind of
// data associated with them, so the accessors can be only used if the real
// event type matches with the one for which the accessors make sense
class WXDLLIMPEXP_CORE wxSplitterEvent : public wxNotifyEvent
{
public:
wxSplitterEvent(wxEventType type = wxEVT_NULL,
wxSplitterWindow *splitter = nullptr)
: wxNotifyEvent(type)
{
SetEventObject(splitter);
if (splitter) m_id = splitter->GetId();
m_data.resize.oldSize = 0;
m_data.resize.newSize = 0;
}
wxSplitterEvent(const wxSplitterEvent& event)
: wxNotifyEvent(event), m_data(event.m_data)
{ }
// SASH_POS_CHANGED methods
// setting the sash position to -1 prevents the change from taking place at
// all
void SetSashPosition(int pos)
{
wxASSERT( GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGED
|| GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING
|| GetEventType() == wxEVT_SPLITTER_SASH_POS_RESIZE);
m_data.resize.pos = pos;
}
int GetSashPosition() const
{
wxASSERT( GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGED
|| GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING
|| GetEventType() == wxEVT_SPLITTER_SASH_POS_RESIZE);
return m_data.resize.pos;
}
void SetSize(int oldSize, int newSize)
{
wxASSERT(GetEventType() == wxEVT_SPLITTER_SASH_POS_RESIZE);
m_data.resize.oldSize = oldSize;
m_data.resize.newSize = newSize;
}
int GetOldSize() const
{
wxASSERT(GetEventType() == wxEVT_SPLITTER_SASH_POS_RESIZE);
return m_data.resize.oldSize;
}
int GetNewSize() const
{
wxASSERT(GetEventType() == wxEVT_SPLITTER_SASH_POS_RESIZE);
return m_data.resize.newSize;
}
// UNSPLIT event methods
wxWindow *GetWindowBeingRemoved() const
{
wxASSERT( GetEventType() == wxEVT_SPLITTER_UNSPLIT );
return m_data.win;
}
// DCLICK event methods
int GetX() const
{
wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED );
return m_data.pt.x;
}
int GetY() const
{
wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED );
return m_data.pt.y;
}
wxNODISCARD virtual wxEvent *Clone() const override { return new wxSplitterEvent(*this); }
private:
friend class WXDLLIMPEXP_FWD_CORE wxSplitterWindow;
// data for the different types of event
union
{
struct
{
int pos; // position for SASH_POS_* events
int oldSize; // window size for SASH_POS_RESIZE event
int newSize; // window size for SASH_POS_RESIZE event
} resize;
wxWindow *win; // window being removed for UNSPLIT event
struct
{
int x, y;
} pt; // position of double click for DCLICK event
} m_data;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSplitterEvent);
};
typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&);
#define wxSplitterEventHandler(func) \
wxEVENT_HANDLER_CAST(wxSplitterEventFunction, func)
#define wx__DECLARE_SPLITTEREVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_SPLITTER_ ## evt, id, wxSplitterEventHandler(fn))
#define EVT_SPLITTER_SASH_POS_CHANGED(id, fn) \
wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGED, id, fn)
#define EVT_SPLITTER_SASH_POS_CHANGING(id, fn) \
wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGING, id, fn)
#define EVT_SPLITTER_SASH_POS_RESIZE(id, fn) \
wx__DECLARE_SPLITTEREVT(SASH_POS_RESIZE, id, fn)
#define EVT_SPLITTER_DCLICK(id, fn) \
wx__DECLARE_SPLITTEREVT(DOUBLECLICKED, id, fn)
#define EVT_SPLITTER_UNSPLIT(id, fn) \
wx__DECLARE_SPLITTEREVT(UNSPLIT, id, fn)
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED wxEVT_SPLITTER_SASH_POS_CHANGED
#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING wxEVT_SPLITTER_SASH_POS_CHANGING
#define wxEVT_COMMAND_SPLITTER_DOUBLECLICKED wxEVT_SPLITTER_DOUBLECLICKED
#define wxEVT_COMMAND_SPLITTER_UNSPLIT wxEVT_SPLITTER_UNSPLIT
#endif // _WX_GENERIC_SPLITTER_H_

View File

@@ -0,0 +1,231 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/srchctlg.h
// Purpose: generic wxSearchCtrl class
// Author: Vince Harron
// Created: 2006-02-19
// Copyright: Vince Harron
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SEARCHCTRL_H_
#define _WX_GENERIC_SEARCHCTRL_H_
#if wxUSE_SEARCHCTRL
#include "wx/bitmap.h"
class WXDLLIMPEXP_FWD_CORE wxSearchButton;
class WXDLLIMPEXP_FWD_CORE wxSearchTextCtrl;
// ----------------------------------------------------------------------------
// wxSearchCtrl is a combination of wxTextCtrl and wxSearchButton
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
{
public:
// creation
// --------
wxSearchCtrl();
wxSearchCtrl(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxSearchCtrlNameStr));
virtual ~wxSearchCtrl();
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxSearchCtrlNameStr));
#if wxUSE_MENUS
// get/set search button menu
// --------------------------
virtual void SetMenu( wxMenu* menu ) override;
virtual wxMenu* GetMenu() override;
#endif // wxUSE_MENUS
// get/set search options
// ----------------------
virtual void ShowSearchButton( bool show ) override;
virtual bool IsSearchButtonVisible() const override;
virtual void ShowCancelButton( bool show ) override;
virtual bool IsCancelButtonVisible() const override;
virtual void SetDescriptiveText(const wxString& text) override;
virtual wxString GetDescriptiveText() const override;
// accessors
// ---------
virtual wxString GetRange(long from, long to) const override;
virtual bool IsEditable() const override;
// If the return values from and to are the same, there is no selection.
virtual void GetSelection(long* from, long* to) const override;
virtual wxString GetStringSelection() const override;
// operations
// ----------
virtual void ChangeValue(const wxString& value) override;
// editing
virtual void Clear() override;
virtual void Replace(long from, long to, const wxString& value) override;
virtual void Remove(long from, long to) override;
// set the max number of characters which may be entered in a single line
// text control
virtual void SetMaxLength(unsigned long WXUNUSED(len)) override;
// writing text inserts it at the current position, appending always
// inserts it at the end
virtual void WriteText(const wxString& text) override;
virtual void AppendText(const wxString& text) override;
// insert the character which would have resulted from this key event,
// return true if anything has been inserted
virtual bool EmulateKeyPress(const wxKeyEvent& event);
// Clipboard operations
virtual void Copy() override;
virtual void Cut() override;
virtual void Paste() override;
virtual bool CanCopy() const override;
virtual bool CanCut() const override;
virtual bool CanPaste() const override;
// Undo/redo
virtual void Undo() override;
virtual void Redo() override;
virtual bool CanUndo() const override;
virtual bool CanRedo() const override;
// Insertion point
virtual void SetInsertionPoint(long pos) override;
virtual void SetInsertionPointEnd() override;
virtual long GetInsertionPoint() const override;
virtual wxTextPos GetLastPosition() const override;
virtual void SetSelection(long from, long to) override;
virtual void SelectAll() override;
virtual void SetEditable(bool editable) override;
// Autocomplete
virtual bool DoAutoCompleteStrings(const wxArrayString &choices) override;
virtual bool DoAutoCompleteFileNames(int flags) override;
virtual bool DoAutoCompleteCustom(wxTextCompleter *completer) override;
virtual bool ShouldInheritColours() const override;
// wxWindow overrides
virtual bool SetFont(const wxFont& font) override;
virtual bool SetBackgroundColour(const wxColour& colour) override;
// search control generic only
void SetSearchBitmap( const wxBitmap& bitmap );
void SetCancelBitmap( const wxBitmap& bitmap );
#if wxUSE_MENUS
void SetSearchMenuBitmap( const wxBitmap& bitmap );
#endif // wxUSE_MENUS
protected:
virtual void DoSetValue(const wxString& value, int flags) override;
virtual wxString DoGetValue() const override;
// override the base class virtuals involved into geometry calculations
virtual wxSize DoGetBestClientSize() const override;
void Init();
void OnCancelButton( wxCommandEvent& event );
void OnSize( wxSizeEvent& event );
void OnDPIChanged(wxDPIChangedEvent& event);
bool HasMenu() const
{
#if wxUSE_MENUS
return m_menu != nullptr;
#else // !wxUSE_MENUS
return false;
#endif // wxUSE_MENUS/!wxUSE_MENUS
}
private:
friend class wxSearchButton;
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Implement wxMSW-specific pure virtual function by forwarding it to the
// real text entry.
virtual WXHWND GetEditHWND() const override;
#endif
// Implement pure virtual function inherited from wxCompositeWindow.
virtual wxWindowList GetCompositeWindowParts() const override;
// Position the child controls using the current window size.
void LayoutControls();
#if wxUSE_MENUS
void PopupSearchMenu();
#endif // wxUSE_MENUS
void RecalcBitmaps();
enum class BitmapType
{
Search,
Cancel,
#if wxUSE_MENUS
Menu
#endif // wxUSE_MENUS
};
wxBitmap RenderBitmap(const wxSize& size, BitmapType bitmapType);
// the subcontrols
wxSearchTextCtrl *m_text;
wxSearchButton *m_searchButton;
wxSearchButton *m_cancelButton;
#if wxUSE_MENUS
wxMenu *m_menu;
#endif // wxUSE_MENUS
bool m_searchBitmapUser;
bool m_cancelBitmapUser;
#if wxUSE_MENUS
bool m_searchMenuBitmapUser;
#endif // wxUSE_MENUS
wxBitmap m_searchBitmap;
wxBitmap m_cancelBitmap;
#if wxUSE_MENUS
wxBitmap m_searchMenuBitmap;
#endif // wxUSE_MENUS
private:
wxDECLARE_DYNAMIC_CLASS(wxSearchCtrl);
wxDECLARE_EVENT_TABLE();
};
#endif // wxUSE_SEARCHCTRL
#endif // _WX_GENERIC_SEARCHCTRL_H_

View File

@@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/statbmpg.h
// Purpose: wxGenericStaticBitmap header
// Author: Marcin Wojdyr, Stefan Csomor
// Created: 2008-06-16
// Copyright: wxWidgets developers
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_STATBMP_H_
#define _WX_GENERIC_STATBMP_H_
#include "wx/statbmp.h"
class WXDLLIMPEXP_CORE wxGenericStaticBitmap : public wxStaticBitmapBase
{
public:
wxGenericStaticBitmap() = default;
wxGenericStaticBitmap(wxWindow *parent,
wxWindowID id,
const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr))
{
Create(parent, id, bitmap, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
virtual void SetBitmap(const wxBitmapBundle& bitmap) override
{
m_bitmapBundle = bitmap;
InvalidateBestSize();
SetSize(GetBestSize());
Refresh();
}
virtual void SetScaleMode(ScaleMode scaleMode) override
{
m_scaleMode = scaleMode;
Refresh();
}
virtual ScaleMode GetScaleMode() const override { return m_scaleMode; }
private:
void OnPaint(wxPaintEvent& event);
ScaleMode m_scaleMode;
wxDECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap);
};
#endif //_WX_GENERIC_STATBMP_H_

View File

@@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/statline.h
// Purpose: a generic wxStaticLine class
// Author: Vadim Zeitlin
// Created: 28.06.99
// Copyright: (c) 1998 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_STATLINE_H_
#define _WX_GENERIC_STATLINE_H_
class wxStaticBox;
// ----------------------------------------------------------------------------
// wxStaticLine
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxStaticLine : public wxStaticLineBase
{
wxDECLARE_DYNAMIC_CLASS(wxStaticLine);
public:
// constructors and pseudo-constructors
wxStaticLine() { m_statbox = nullptr; }
wxStaticLine( wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxASCII_STR(wxStaticLineNameStr) )
{
Create(parent, id, pos, size, style, name);
}
virtual ~wxStaticLine();
bool Create( wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxASCII_STR(wxStaticLineNameStr) );
// it's necessary to override this wxWindow function because we
// will want to return the main widget for m_statbox
//
WXWidget GetMainWidget() const;
// override wxWindow methods to make things work
virtual void DoSetSize(int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoMoveWindow(int x, int y, int width, int height);
protected:
// we implement the static line using a static box
wxStaticBox *m_statbox;
};
#endif // _WX_GENERIC_STATLINE_H_

View File

@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/stattextg.h
// Purpose: wxGenericStaticText header
// Author: Marcin Wojdyr
// Created: 2008-06-26
// Copyright: Marcin Wojdyr
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_STATTEXTG_H_
#define _WX_GENERIC_STATTEXTG_H_
// prevent it from including the platform-specific wxStaticText declaration as
// this is not going to compile if it derives from wxGenericStaticText defined
// below (currently this is only the case in wxUniv but it could also happen
// with other ports)
#define wxNO_PORT_STATTEXT_INCLUDE
#include "wx/stattext.h"
#undef wxNO_PORT_STATTEXT_INCLUDE
class WXDLLIMPEXP_CORE wxGenericStaticText : public wxStaticTextBase
{
public:
wxGenericStaticText() { Init(); }
wxGenericStaticText(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxStaticTextNameStr))
{
Init();
Create(parent, id, label, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxStaticTextNameStr));
virtual ~wxGenericStaticText();
// overridden base class virtual methods
virtual void SetLabel(const wxString& label) override;
virtual bool SetFont(const wxFont &font) override;
protected:
virtual wxSize DoGetBestClientSize() const override;
virtual wxString WXGetVisibleLabel() const override { return m_label; }
virtual void WXSetVisibleLabel(const wxString& label) override;
void DoSetSize(int x, int y, int width, int height, int sizeFlags) override;
#if wxUSE_MARKUP
virtual bool DoSetLabelMarkup(const wxString& markup) override;
#endif // wxUSE_MARKUP
private:
void Init()
{
#if wxUSE_MARKUP
m_markupText = nullptr;
#endif // wxUSE_MARKUP
}
void OnPaint(wxPaintEvent& event);
void DoDrawLabel(wxDC& dc, const wxRect& rect);
// These fields are only used if m_markupText == nullptr.
wxString m_label;
int m_mnemonic;
#if wxUSE_MARKUP
class wxMarkupText *m_markupText;
#endif // wxUSE_MARKUP
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericStaticText);
};
#endif // _WX_GENERIC_STATTEXTG_H_

View File

@@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/statusbr.h
// Purpose: wxStatusBarGeneric class
// Author: Julian Smart
// Modified by: VZ at 05.02.00 to derive from wxStatusBarBase
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_STATUSBR_H_
#define _WX_GENERIC_STATUSBR_H_
#include "wx/defs.h"
#if wxUSE_STATUSBAR
#include "wx/pen.h"
#include "wx/arrstr.h"
// ----------------------------------------------------------------------------
// wxStatusBarGeneric
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxStatusBarGeneric : public wxStatusBarBase
{
public:
wxStatusBarGeneric() { Init(); }
wxStatusBarGeneric(wxWindow *parent,
wxWindowID winid = wxID_ANY,
long style = wxSTB_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxStatusBarNameStr))
{
Init();
Create(parent, winid, style, name);
}
virtual ~wxStatusBarGeneric();
bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY,
long style = wxSTB_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxStatusBarNameStr));
// implement base class methods
virtual void SetStatusWidths(int n, const int widths_field[]) override;
virtual bool GetFieldRect(int i, wxRect& rect) const override;
virtual void SetMinHeight(int height) override;
virtual int GetBorderX() const override { return m_borderX; }
virtual int GetBorderY() const override { return m_borderY; }
// implementation only (not part of wxStatusBar public API):
int GetFieldFromPoint(const wxPoint& point) const;
protected:
virtual void DoUpdateStatusText(int number) override;
// event handlers
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnLeftDown(wxMouseEvent& event);
void OnRightDown(wxMouseEvent& event);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
virtual int GetEffectiveFieldStyle(int i) const { return m_panes[i].GetStyle(); }
virtual void DrawFieldText(wxDC& dc, const wxRect& rc, int i, int textHeight);
virtual void DrawField(wxDC& dc, int i, int textHeight);
void SetBorderX(int x);
void SetBorderY(int y);
virtual void InitColours();
// true if the status bar shows the size grip: for this it must have
// wxSTB_SIZEGRIP style and the window it is attached to must be resizable
// and not maximized (note that currently size grip is only used in wxGTK)
bool ShowsSizeGrip() const;
// returns the position and the size of the size grip
wxRect GetSizeGripRect() const;
// common part of all ctors
void Init();
// the last known size, fields widths must be updated whenever it's out of
// date
wxSize m_lastClientSize;
// the absolute widths of the status bar panes in pixels
wxArrayInt m_widthsAbs;
int m_borderX;
int m_borderY;
wxPen m_mediumShadowPen;
wxPen m_hilightPen;
virtual wxSize DoGetBestSize() const override;
private:
// Update m_lastClientSize and m_widthsAbs from the current size.
void DoUpdateFieldWidths();
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBarGeneric);
};
#endif // wxUSE_STATUSBAR
#endif
// _WX_GENERIC_STATUSBR_H_

View File

@@ -0,0 +1,357 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/tabg.h
// Purpose: Generic tabbed dialogs; used by generic wxNotebook
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __TABGH_G__
#define __TABGH_G__
#define WXTAB_VERSION 1.1
#include "wx/hashmap.h"
#include "wx/string.h"
#include "wx/dialog.h"
#include "wx/panel.h"
#include "wx/list.h"
class WXDLLIMPEXP_FWD_CORE wxTabView;
/*
* A wxTabControl is the internal and visual representation
* of the tab.
*/
class WXDLLIMPEXP_CORE wxTabControl: public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wxTabControl);
public:
wxTabControl(wxTabView *v = nullptr);
virtual ~wxTabControl(void);
virtual void OnDraw(wxDC& dc, bool lastInRow);
void SetLabel(const wxString& str) { m_controlLabel = str; }
wxString GetLabel(void) const { return m_controlLabel; }
void SetFont(const wxFont& f) { m_labelFont = f; }
wxFont *GetFont(void) const { return (wxFont*) & m_labelFont; }
void SetSelected(bool sel) { m_isSelected = sel; }
bool IsSelected(void) const { return m_isSelected; }
void SetPosition(int x, int y) { m_offsetX = x; m_offsetY = y; }
void SetSize(int x, int y) { m_width = x; m_height = y; }
void SetRowPosition(int r) { m_rowPosition = r; }
int GetRowPosition() const { return m_rowPosition; }
void SetColPosition(int c) { m_colPosition = c; }
int GetColPosition() const { return m_colPosition; }
int GetX(void) const { return m_offsetX; }
int GetY(void) const { return m_offsetY; }
int GetWidth(void) const { return m_width; }
int GetHeight(void) const { return m_height; }
int GetId(void) const { return m_id; }
void SetId(int i) { m_id = i; }
virtual bool HitTest(int x, int y) const ;
protected:
wxTabView* m_view;
wxString m_controlLabel;
bool m_isSelected;
wxFont m_labelFont;
int m_offsetX; // Offsets from top-left of tab view area (the area below the tabs)
int m_offsetY;
int m_width;
int m_height;
int m_id;
int m_rowPosition; // Position in row from 0
int m_colPosition; // Position in col from 0
};
/*
* Each wxTabLayer is a list of tabs. E.g. there
* are 3 layers in the MS Word Options dialog.
*/
class WXDLLIMPEXP_CORE wxTabLayer: public wxList
{
};
/*
* The wxTabView controls and draws the tabbed object
*/
WX_DECLARE_LIST(wxTabLayer, wxTabLayerList);
#define wxTAB_STYLE_DRAW_BOX 1 // Draws 3D boxes round tab layers
#define wxTAB_STYLE_COLOUR_INTERIOR 2 // Colours interior of tabs, otherwise draws outline
class WXDLLIMPEXP_CORE wxTabView: public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wxTabView);
public:
wxTabView(long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
virtual ~wxTabView();
inline int GetNumberOfLayers() const { return m_layers.GetCount(); }
inline wxTabLayerList& GetLayers() { return m_layers; }
inline void SetWindow(wxWindow* wnd) { m_window = wnd; }
inline wxWindow* GetWindow(void) const { return m_window; }
// Automatically positions tabs
wxTabControl *AddTab(int id, const wxString& label, wxTabControl *existingTab = nullptr);
// Remove the tab without deleting the window
bool RemoveTab(int id);
void ClearTabs(bool deleteTabs = true);
bool SetTabText(int id, const wxString& label);
wxString GetTabText(int id) const;
// Layout tabs (optional, e.g. if resizing window)
void LayoutTabs();
// Draw all tabs
virtual void Draw(wxDC& dc);
// Process mouse event, return false if we didn't process it
virtual bool OnEvent(wxMouseEvent& event);
// Called when a tab is activated
virtual void OnTabActivate(int activateId, int deactivateId);
// Allows vetoing
virtual bool OnTabPreActivate(int WXUNUSED(activateId), int WXUNUSED(deactivateId) ) { return true; }
// Allows use of application-supplied wxTabControl classes.
virtual wxTabControl *OnCreateTabControl(void) { return new wxTabControl(this); }
void SetHighlightColour(const wxColour& col);
void SetShadowColour(const wxColour& col);
void SetBackgroundColour(const wxColour& col);
inline void SetTextColour(const wxColour& col) { m_textColour = col; }
inline wxColour GetHighlightColour(void) const { return m_highlightColour; }
inline wxColour GetShadowColour(void) const { return m_shadowColour; }
inline wxColour GetBackgroundColour(void) const { return m_backgroundColour; }
inline wxColour GetTextColour(void) const { return m_textColour; }
inline const wxPen *GetHighlightPen(void) const { return m_highlightPen; }
inline const wxPen *GetShadowPen(void) const { return m_shadowPen; }
inline const wxPen *GetBackgroundPen(void) const { return m_backgroundPen; }
inline const wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; }
inline void SetViewRect(const wxRect& rect) { m_tabViewRect = rect; }
inline wxRect GetViewRect(void) const { return m_tabViewRect; }
// Calculate tab width to fit to view, and optionally adjust the view
// to fit the tabs exactly.
int CalculateTabWidth(int noTabs, bool adjustView = false);
inline void SetTabStyle(long style) { m_tabStyle = style; }
inline long GetTabStyle(void) const { return m_tabStyle; }
inline void SetTabSize(int w, int h) { m_tabWidth = w; m_tabHeight = h; }
inline int GetTabWidth(void) const { return m_tabWidth; }
inline int GetTabHeight(void) const { return m_tabHeight; }
inline void SetTabSelectionHeight(int h) { m_tabSelectionHeight = h; }
inline int GetTabSelectionHeight(void) const { return m_tabSelectionHeight; }
// Returns the total height of the tabs component -- this may be several
// times the height of a tab, if there are several tab layers (rows).
int GetTotalTabHeight();
inline int GetTopMargin(void) const { return m_topMargin; }
inline void SetTopMargin(int margin) { m_topMargin = margin; }
void SetTabSelection(int sel, bool activateTool = true);
inline int GetTabSelection() const { return m_tabSelection; }
// Find tab control for id
wxTabControl *FindTabControlForId(int id) const ;
// Find tab control for layer, position (starting from zero)
wxTabControl *FindTabControlForPosition(int layer, int position) const ;
inline int GetHorizontalTabOffset() const { return m_tabHorizontalOffset; }
inline int GetHorizontalTabSpacing() const { return m_tabHorizontalSpacing; }
inline void SetHorizontalTabOffset(int sp) { m_tabHorizontalOffset = sp; }
inline void SetHorizontalTabSpacing(int sp) { m_tabHorizontalSpacing = sp; }
inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; }
inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; }
inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; }
inline void SetTabFont(const wxFont& f) { m_tabFont = f; }
inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; }
inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; }
// Find the node and the column at which this control is positioned.
wxList::compatibility_iterator FindTabNodeAndColumn(wxTabControl *control, int *col) const ;
// Do the necessary to change to this tab
virtual bool ChangeTab(wxTabControl *control);
// Move the selected tab to the bottom layer, if necessary,
// without calling app activation code
bool MoveSelectionTab(wxTabControl *control);
inline int GetNumberOfTabs() const { return m_noTabs; }
protected:
// List of layers, from front to back.
wxTabLayerList m_layers;
// Selected tab
int m_tabSelection;
// Usual tab height
int m_tabHeight;
// The height of the selected tab
int m_tabSelectionHeight;
// Usual tab width
int m_tabWidth;
// Space between tabs
int m_tabHorizontalSpacing;
// Space between top of normal tab and text
int m_tabVerticalTextSpacing;
// Horizontal offset of each tab row above the first
int m_tabHorizontalOffset;
// The distance between the bottom of the first tab row
// and the top of the client area (i.e. the margin)
int m_topMargin;
// The position and size of the view above which the tabs are placed.
// I.e., the internal client area of the sheet.
wxRect m_tabViewRect;
// Bitlist of styles
long m_tabStyle;
// Colours
wxColour m_highlightColour;
wxColour m_shadowColour;
wxColour m_backgroundColour;
wxColour m_textColour;
// Pen and brush cache
const wxPen* m_highlightPen;
const wxPen* m_shadowPen;
const wxPen* m_backgroundPen;
const wxBrush* m_backgroundBrush;
wxFont m_tabFont;
wxFont m_tabSelectedFont;
int m_noTabs;
wxWindow* m_window;
};
/*
* A dialog box class that is tab-friendly
*/
class WXDLLIMPEXP_CORE wxTabbedDialog : public wxDialog
{
wxDECLARE_DYNAMIC_CLASS(wxTabbedDialog);
public:
wxTabbedDialog(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long windowStyle = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxASCII_STR(wxDialogNameStr));
virtual ~wxTabbedDialog();
wxTabView *GetTabView() const { return m_tabView; }
void SetTabView(wxTabView *v) { m_tabView = v; }
void OnCloseWindow(wxCloseEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
protected:
wxTabView* m_tabView;
private:
wxDECLARE_EVENT_TABLE();
};
/*
* A panel class that is tab-friendly
*/
class WXDLLIMPEXP_CORE wxTabbedPanel : public wxPanel
{
wxDECLARE_DYNAMIC_CLASS(wxTabbedPanel);
public:
wxTabbedPanel(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long windowStyle = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr));
virtual ~wxTabbedPanel();
wxTabView *GetTabView() const { return m_tabView; }
void SetTabView(wxTabView *v) { m_tabView = v; }
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
protected:
wxTabView* m_tabView;
private:
wxDECLARE_EVENT_TABLE();
};
WX_DECLARE_HASH_MAP(int, wxWindow*, wxIntegerHash, wxIntegerEqual,
wxIntToWindowHashMap);
class WXDLLIMPEXP_CORE wxPanelTabView : public wxTabView
{
wxDECLARE_DYNAMIC_CLASS(wxPanelTabView);
public:
wxPanelTabView(wxPanel *pan, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
virtual ~wxPanelTabView(void);
// Called when a tab is activated
virtual void OnTabActivate(int activateId, int deactivateId);
// Specific to this class
void AddTabWindow(int id, wxWindow *window);
wxWindow *GetTabWindow(int id) const ;
void ClearWindows(bool deleteWindows = true);
wxWindow *GetCurrentWindow() const { return m_currentWindow; }
void ShowWindowForTab(int id);
// wxList& GetWindows() const { return (wxList&) m_tabWindows; }
protected:
// List of panels, one for each tab. Indexed
// by tab ID.
wxIntToWindowHashMap m_tabWindows;
wxWindow* m_currentWindow;
wxPanel* m_panel;
};
#endif

View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/textdlgg.h
// Purpose: wxTextEntryDialog class
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEXTDLGG_H_
#define _WX_TEXTDLGG_H_
#include "wx/defs.h"
#if wxUSE_TEXTDLG
#include "wx/dialog.h"
#if wxUSE_VALIDATORS
#include "wx/valtext.h"
#include "wx/textctrl.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
extern WXDLLIMPEXP_DATA_CORE(const char) wxGetTextFromUserPromptStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[];
#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE)
// ----------------------------------------------------------------------------
// wxTextEntryDialog: a dialog with text control, [ok] and [cancel] buttons
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxTextEntryDialog : public wxDialog
{
public:
wxTextEntryDialog()
{
m_textctrl = nullptr;
m_dialogStyle = 0;
}
wxTextEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxGetTextFromUserPromptStr),
const wxString& value = wxEmptyString,
long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition,
const wxSize sz = wxDefaultSize)
{
Create(parent, message, caption, value, style, pos, sz);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxGetTextFromUserPromptStr),
const wxString& value = wxEmptyString,
long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition,
const wxSize sz = wxDefaultSize);
void SetValue(const wxString& val);
wxString GetValue() const { return m_value; }
void SetMaxLength(unsigned long len);
void ForceUpper();
#if wxUSE_VALIDATORS
void SetTextValidator( const wxTextValidator& validator );
void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE );
wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); }
#endif // wxUSE_VALIDATORS
virtual bool TransferDataToWindow() override;
virtual bool TransferDataFromWindow() override;
// implementation only
void OnOK(wxCommandEvent& event);
protected:
wxTextCtrl *m_textctrl;
wxString m_value;
long m_dialogStyle;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxTextEntryDialog);
wxDECLARE_NO_COPY_CLASS(wxTextEntryDialog);
};
// ----------------------------------------------------------------------------
// wxPasswordEntryDialog: dialog with password control, [ok] and [cancel]
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPasswordEntryDialog : public wxTextEntryDialog
{
public:
wxPasswordEntryDialog() = default;
wxPasswordEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxGetPasswordFromUserPromptStr),
const wxString& value = wxEmptyString,
long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition)
{
Create(parent, message, caption, value, style, pos);
}
bool Create(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxGetPasswordFromUserPromptStr),
const wxString& value = wxEmptyString,
long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition);
private:
wxDECLARE_DYNAMIC_CLASS(wxPasswordEntryDialog);
wxDECLARE_NO_COPY_CLASS(wxPasswordEntryDialog);
};
// ----------------------------------------------------------------------------
// function to get a string from user
// ----------------------------------------------------------------------------
WXDLLIMPEXP_CORE wxString
wxGetTextFromUser(const wxString& message,
const wxString& caption = wxASCII_STR(wxGetTextFromUserPromptStr),
const wxString& default_value = wxEmptyString,
wxWindow *parent = nullptr,
wxCoord x = wxDefaultCoord,
wxCoord y = wxDefaultCoord,
bool centre = true);
WXDLLIMPEXP_CORE wxString
wxGetPasswordFromUser(const wxString& message,
const wxString& caption = wxASCII_STR(wxGetPasswordFromUserPromptStr),
const wxString& default_value = wxEmptyString,
wxWindow *parent = nullptr,
wxCoord x = wxDefaultCoord,
wxCoord y = wxDefaultCoord,
bool centre = true);
#endif
// wxUSE_TEXTDLG
#endif // _WX_TEXTDLGG_H_

View File

@@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/timectrl.h
// Purpose: Generic implementation of wxTimePickerCtrl.
// Author: Paul Breen, Vadim Zeitlin
// Created: 2011-09-22
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_TIMECTRL_H_
#define _WX_GENERIC_TIMECTRL_H_
#include "wx/containr.h"
#include "wx/compositewin.h"
typedef wxTimePickerCtrlCommonBase<wxDateTimePickerCtrlBase> wxTimePickerCtrlGenericBase;
class WXDLLIMPEXP_ADV wxTimePickerCtrlGeneric
: public wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlGenericBase> >
{
public:
typedef wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlGenericBase> > Base;
// Creating the control.
wxTimePickerCtrlGeneric() { Init(); }
virtual ~wxTimePickerCtrlGeneric();
wxTimePickerCtrlGeneric(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTP_DEFAULT,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTimePickerCtrlNameStr)
{
Init();
(void)Create(parent, id, date, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTP_DEFAULT,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTimePickerCtrlNameStr);
// Implement pure virtual wxTimePickerCtrlBase methods.
virtual void SetValue(const wxDateTime& date) override;
virtual wxDateTime GetValue() const override;
protected:
virtual wxSize DoGetBestSize() const override;
virtual void DoMoveWindow(int x, int y, int width, int height) override;
private:
void Init();
// Return the list of the windows composing this one.
virtual wxWindowList GetCompositeWindowParts() const override;
// Implementation data.
class wxTimePickerGenericImpl* m_impl;
wxDECLARE_NO_COPY_CLASS(wxTimePickerCtrlGeneric);
};
#endif // _WX_GENERIC_TIMECTRL_H_

View File

@@ -0,0 +1,422 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/treectlg.h
// Purpose: wxTreeCtrl class
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1997,1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _GENERIC_TREECTRL_H_
#define _GENERIC_TREECTRL_H_
#if wxUSE_TREECTRL
#include "wx/brush.h"
#include "wx/pen.h"
#include "wx/scrolwin.h"
// -----------------------------------------------------------------------------
// forward declaration
// -----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxTreeItemData;
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
// private implementation classes
class wxGenericTreeItem;
class wxTreeTextCtrl;
// -----------------------------------------------------------------------------
// wxGenericTreeCtrl - the tree control
// -----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericTreeCtrl : public wxTreeCtrlBase,
public wxScrollHelper
{
public:
// creation
// --------
wxGenericTreeCtrl() : wxTreeCtrlBase(), wxScrollHelper(this) { Init(); }
wxGenericTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_DEFAULT_STYLE,
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxTreeCtrlNameStr))
: wxTreeCtrlBase(),
wxScrollHelper(this)
{
Init();
Create(parent, id, pos, size, style, validator, name);
}
virtual ~wxGenericTreeCtrl();
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_DEFAULT_STYLE,
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxTreeCtrlNameStr));
// implement base class pure virtuals
// ----------------------------------
virtual unsigned int GetCount() const override;
virtual unsigned int GetIndent() const override { return m_indent; }
virtual void SetIndent(unsigned int indent) override;
virtual void SetStateImages(const wxVector<wxBitmapBundle>& images) override;
virtual void SetImageList(wxImageList *imageList) override;
virtual void SetStateImageList(wxImageList *imageList) override;
virtual wxString GetItemText(const wxTreeItemId& item) const override;
virtual int GetItemImage(const wxTreeItemId& item,
wxTreeItemIcon which = wxTreeItemIcon_Normal) const override;
virtual wxTreeItemData *GetItemData(const wxTreeItemId& item) const override;
virtual wxColour GetItemTextColour(const wxTreeItemId& item) const override;
virtual wxColour GetItemBackgroundColour(const wxTreeItemId& item) const override;
virtual wxFont GetItemFont(const wxTreeItemId& item) const override;
virtual void SetItemText(const wxTreeItemId& item, const wxString& text) override;
virtual void SetItemImage(const wxTreeItemId& item,
int image,
wxTreeItemIcon which = wxTreeItemIcon_Normal) override;
virtual void SetItemData(const wxTreeItemId& item, wxTreeItemData *data) override;
virtual void SetItemHasChildren(const wxTreeItemId& item, bool has = true) override;
virtual void SetItemBold(const wxTreeItemId& item, bool bold = true) override;
virtual void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true) override;
virtual void SetItemTextColour(const wxTreeItemId& item, const wxColour& col) override;
virtual void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col) override;
virtual void SetItemFont(const wxTreeItemId& item, const wxFont& font) override;
virtual bool IsVisible(const wxTreeItemId& item) const override;
virtual bool ItemHasChildren(const wxTreeItemId& item) const override;
virtual bool IsExpanded(const wxTreeItemId& item) const override;
virtual bool IsSelected(const wxTreeItemId& item) const override;
virtual bool IsBold(const wxTreeItemId& item) const override;
virtual size_t GetChildrenCount(const wxTreeItemId& item,
bool recursively = true) const override;
// navigation
// ----------
virtual wxTreeItemId GetRootItem() const override { return m_anchor; }
virtual wxTreeItemId GetSelection() const override
{
wxASSERT_MSG( !HasFlag(wxTR_MULTIPLE),
wxT("must use GetSelections() with this control") );
return m_current;
}
virtual size_t GetSelections(wxArrayTreeItemIds&) const override;
virtual wxTreeItemId GetFocusedItem() const override { return m_current; }
virtual void ClearFocusedItem() override;
virtual void SetFocusedItem(const wxTreeItemId& item) override;
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const override;
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item,
wxTreeItemIdValue& cookie) const override;
virtual wxTreeItemId GetNextChild(const wxTreeItemId& item,
wxTreeItemIdValue& cookie) const override;
virtual wxTreeItemId GetLastChild(const wxTreeItemId& item) const override;
virtual wxTreeItemId GetNextSibling(const wxTreeItemId& item) const override;
virtual wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const override;
virtual wxTreeItemId GetFirstVisibleItem() const override;
virtual wxTreeItemId GetNextVisible(const wxTreeItemId& item) const override;
virtual wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const override;
// operations
// ----------
virtual wxTreeItemId AddRoot(const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = nullptr) override;
virtual void Delete(const wxTreeItemId& item) override;
virtual void DeleteChildren(const wxTreeItemId& item) override;
virtual void DeleteAllItems() override;
virtual void Expand(const wxTreeItemId& item) override;
virtual void Collapse(const wxTreeItemId& item) override;
virtual void CollapseAndReset(const wxTreeItemId& item) override;
virtual void Toggle(const wxTreeItemId& item) override;
virtual void Unselect() override;
virtual void UnselectAll() override;
virtual void SelectItem(const wxTreeItemId& item, bool select = true) override;
virtual void SelectChildren(const wxTreeItemId& parent) override;
virtual void EnsureVisible(const wxTreeItemId& item) override;
virtual void ScrollTo(const wxTreeItemId& item) override;
virtual wxTextCtrl *EditLabel(const wxTreeItemId& item,
wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)) override;
virtual wxTextCtrl *GetEditControl() const override;
virtual void EndEditLabel(const wxTreeItemId& item,
bool discardChanges = false) override;
virtual void EnableBellOnNoMatch(bool on = true) override;
virtual void SortChildren(const wxTreeItemId& item) override;
// items geometry
// --------------
virtual bool GetBoundingRect(const wxTreeItemId& item,
wxRect& rect,
bool textOnly = false) const override;
// this version specific methods
// -----------------------------
wxImageList *GetButtonsImageList() const
{
return m_imagesButtons.GetImageList();
}
void SetButtonsImageList(wxImageList *imageList);
void AssignButtonsImageList(wxImageList *imageList);
void SetDropEffectAboveItem( bool above = false ) { m_dropEffectAboveItem = above; }
bool GetDropEffectAboveItem() const { return m_dropEffectAboveItem; }
wxTreeItemId GetNext(const wxTreeItemId& item) const;
// implementation only from now on
// overridden base class virtuals
virtual bool SetBackgroundColour(const wxColour& colour) override;
virtual bool SetForegroundColour(const wxColour& colour) override;
virtual void Refresh(bool eraseBackground = true, const wxRect *rect = nullptr) override;
virtual bool SetFont( const wxFont &font ) override;
virtual void SetWindowStyleFlag(long styles) override;
// callbacks
void OnPaint( wxPaintEvent &event );
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnKeyDown( wxKeyEvent &event );
void OnChar( wxKeyEvent &event );
void OnMouse( wxMouseEvent &event );
void OnGetToolTip( wxTreeEvent &event );
void OnSize( wxSizeEvent &event );
void OnInternalIdle( ) override;
virtual wxVisualAttributes GetDefaultAttributes() const override
{
return GetClassDefaultAttributes(GetWindowVariant());
}
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// implementation helpers
void AdjustMyScrollbars();
WX_FORWARD_TO_SCROLL_HELPER()
protected:
friend class wxGenericTreeItem;
friend class wxTreeRenameTimer;
friend class wxTreeFindTimer;
friend class wxTreeTextCtrl;
wxFont m_normalFont;
wxFont m_boldFont;
wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current,
*m_key_current,
// A hint to select a parent item after deleting a child
*m_select_me;
unsigned int m_indent;
int m_lineHeight;
wxPen m_dottedPen;
wxBrush m_hilightBrush,
m_hilightUnfocusedBrush;
bool m_hasFocus;
bool m_dirty;
bool m_isDragging; // true between BEGIN/END drag events
bool m_lastOnSame; // last click on the same item as prev
wxWithImages m_imagesButtons;
int m_dragCount;
wxPoint m_dragStart;
wxGenericTreeItem *m_dropTarget;
wxCursor m_oldCursor; // cursor is changed while dragging
wxGenericTreeItem *m_oldSelection;
wxGenericTreeItem *m_underMouse; // for visual effects
enum { NoEffect, BorderEffect, AboveEffect, BelowEffect } m_dndEffect;
wxGenericTreeItem *m_dndEffectItem;
wxTreeTextCtrl *m_textCtrl;
wxTimer *m_renameTimer;
// incremental search data
wxString m_findPrefix;
wxTimer *m_findTimer;
// This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1
// if it is globally enabled but has been temporarily disabled because we
// had already beeped for this particular search.
int m_findBell;
bool m_dropEffectAboveItem;
// the common part of all ctors
void Init();
// overridden wxWindow methods
virtual void DoThaw() override;
virtual void OnImagesChanged() override;
void UpdateAfterImageListChange();
// misc helpers
void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted);
void DrawBorder(const wxTreeItemId& item);
void DrawLine(const wxTreeItemId& item, bool below);
void DrawDropEffect(wxGenericTreeItem *item);
void DoSelectItem(const wxTreeItemId& id,
bool unselect_others = true,
bool extended_select = false);
virtual int DoGetItemState(const wxTreeItemId& item) const override;
virtual void DoSetItemState(const wxTreeItemId& item, int state) override;
virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent,
size_t previous,
const wxString& text,
int image,
int selectedImage,
wxTreeItemData *data) override;
virtual wxTreeItemId DoInsertAfter(const wxTreeItemId& parent,
const wxTreeItemId& idPrevious,
const wxString& text,
int image = -1, int selImage = -1,
wxTreeItemData *data = nullptr) override;
virtual wxTreeItemId DoTreeHitTest(const wxPoint& point, int& flags) const override;
// called by wxTextTreeCtrl when it marks itself for deletion
void ResetTextControl();
// find the first item starting with the given prefix after the given item
wxTreeItemId FindItem(const wxTreeItemId& id, const wxString& prefix) const;
bool HasButtons() const { return HasFlag(wxTR_HAS_BUTTONS); }
void CalculateLineHeight();
int GetLineHeight(wxGenericTreeItem *item) const;
void PaintLevel( wxGenericTreeItem *item, wxDC& dc, int level, int &y );
void PaintItem( wxGenericTreeItem *item, wxDC& dc);
void CalculateLevel( wxGenericTreeItem *item, wxReadOnlyDC &dc, int level, int &y );
void CalculatePositions();
void RefreshSubtree( wxGenericTreeItem *item );
void RefreshLine( wxGenericTreeItem *item );
// redraw all selected items
void RefreshSelected();
// RefreshSelected() recursive helper
void RefreshSelectedUnder(wxGenericTreeItem *item);
void OnRenameTimer();
bool OnRenameAccept(wxGenericTreeItem *item, const wxString& value);
void OnRenameCancelled(wxGenericTreeItem *item);
void FillArray(wxGenericTreeItem*, wxArrayTreeItemIds&) const;
void SelectItemRange( wxGenericTreeItem *item1, wxGenericTreeItem *item2 );
bool TagAllChildrenUntilLast(wxGenericTreeItem *crt_item, wxGenericTreeItem *last_item, bool select);
bool TagNextChildren(wxGenericTreeItem *crt_item, wxGenericTreeItem *last_item, bool select);
void UnselectAllChildren( wxGenericTreeItem *item );
void ChildrenClosing(wxGenericTreeItem* item);
void DoDirtyProcessing();
virtual wxSize DoGetBestSize() const override;
private:
void OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
InitVisualAttributes();
}
// (Re)initialize colours, fonts, pens, brushes used by the control using
// the current system colours and font.
void InitVisualAttributes();
// Reset the state of the last find (i.e. keyboard incremental search)
// operation.
void ResetFindState();
// Find the next item, either looking inside the collapsed items or not.
enum
{
Next_Any = 0,
Next_Visible = 1
};
wxTreeItemId DoGetNext(const wxTreeItemId& item, int flags = 0) const;
// True if we're using custom colours/font, respectively, or false if we're
// using the default colours and should update them whenever system colours
// change.
bool m_hasExplicitFgCol:1,
m_hasExplicitBgCol:1,
m_hasExplicitFont:1;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl);
wxDECLARE_NO_COPY_CLASS(wxGenericTreeCtrl);
};
// Also define wxTreeCtrl to be wxGenericTreeCtrl on all platforms without a
// native version, i.e. all but MSW and Qt.
#if !(defined(__WXMSW__) || defined(__WXQT__)) || defined(__WXUNIVERSAL__)
/*
* wxTreeCtrl has to be a real class or we have problems with
* the run-time information.
*/
class WXDLLIMPEXP_CORE wxTreeCtrl: public wxGenericTreeCtrl
{
wxDECLARE_DYNAMIC_CLASS(wxTreeCtrl);
public:
wxTreeCtrl() = default;
wxTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_DEFAULT_STYLE,
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxTreeCtrlNameStr))
: wxGenericTreeCtrl(parent, id, pos, size, style, validator, name)
{
}
};
#endif // !(__WXMSW__ || __WXQT__) || __WXUNIVERSAL__
#endif // wxUSE_TREECTRL
#endif // _GENERIC_TREECTRL_H_

View File

@@ -0,0 +1,176 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/wizard.h
// Purpose: declaration of generic wxWizard class
// Author: Vadim Zeitlin
// Modified by: Robert Vazan (sizers)
// Created: 28.09.99
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_WIZARD_H_
#define _WX_GENERIC_WIZARD_H_
// ----------------------------------------------------------------------------
// wxWizard
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxStaticBitmap;
class WXDLLIMPEXP_FWD_CORE wxWizardEvent;
class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
class WXDLLIMPEXP_FWD_CORE wxWizardSizer;
class WXDLLIMPEXP_CORE wxWizard : public wxWizardBase
{
public:
// ctor
wxWizard() { Init(); }
wxWizard(wxWindow *parent,
int id = wxID_ANY,
const wxString& title = wxEmptyString,
const wxBitmapBundle& bitmap = wxBitmapBundle(),
const wxPoint& pos = wxDefaultPosition,
long style = wxDEFAULT_DIALOG_STYLE)
{
Init();
Create(parent, id, title, bitmap, pos, style);
}
bool Create(wxWindow *parent,
int id = wxID_ANY,
const wxString& title = wxEmptyString,
const wxBitmapBundle& bitmap = wxBitmapBundle(),
const wxPoint& pos = wxDefaultPosition,
long style = wxDEFAULT_DIALOG_STYLE);
void Init();
virtual ~wxWizard();
// implement base class pure virtuals
virtual bool RunWizard(wxWizardPage *firstPage) override;
virtual wxWizardPage *GetCurrentPage() const override;
virtual void SetPageSize(const wxSize& size) override;
virtual wxSize GetPageSize() const override;
virtual void FitToPage(const wxWizardPage *firstPage) override;
virtual wxSizer *GetPageAreaSizer() const override;
virtual void SetBorder(int border) override;
/// set/get bitmap
wxBitmap GetBitmap() const { return m_bitmap.GetBitmapFor(this); }
void SetBitmap(const wxBitmapBundle& bitmap);
// implementation only from now on
// -------------------------------
// is the wizard running?
bool IsRunning() const { return m_page != nullptr; }
// show the prev/next page, but call TransferDataFromWindow on the current
// page first and return false without changing the page if
// TransferDataFromWindow() returns false - otherwise, returns true
virtual bool ShowPage(wxWizardPage *page, bool goingForward = true);
// do fill the dialog with controls
// this is app-overridable to, for example, set help and tooltip text
virtual void DoCreateControls();
// Do the adaptation
virtual bool DoLayoutAdaptation() override;
// Set/get bitmap background colour
void SetBitmapBackgroundColour(const wxColour& colour) { m_bitmapBackgroundColour = colour; }
const wxColour& GetBitmapBackgroundColour() const { return m_bitmapBackgroundColour; }
// Set/get bitmap placement (centred, tiled etc.)
void SetBitmapPlacement(int placement) { m_bitmapPlacement = placement; }
int GetBitmapPlacement() const { return m_bitmapPlacement; }
// Set/get minimum bitmap width
void SetMinimumBitmapWidth(int w) { m_bitmapMinimumWidth = w; }
int GetMinimumBitmapWidth() const { return m_bitmapMinimumWidth; }
// Tile bitmap
static bool TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap);
protected:
// for compatibility only, doesn't do anything any more
void FinishLayout() { }
// Do fit, and adjust to screen size if necessary
virtual void DoWizardLayout();
// Resize bitmap if necessary
virtual bool ResizeBitmap(wxBitmap& bmp);
// was the dialog really created?
bool WasCreated() const { return m_btnPrev != nullptr; }
// event handlers
void OnCancel(wxCommandEvent& event);
void OnBackOrNext(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnWizEvent(wxWizardEvent& event);
void AddBitmapRow(wxBoxSizer *mainColumn);
void AddStaticLine(wxBoxSizer *mainColumn);
void AddBackNextPair(wxBoxSizer *buttonRow);
void AddButtonRow(wxBoxSizer *mainColumn);
// This function can be used as event handle for wxEVT_DPI_CHANGED event.
void WXHandleDPIChanged(wxDPIChangedEvent& event);
// the page size requested by user
wxSize m_sizePage;
// the dialog position from the ctor
wxPoint m_posWizard;
// wizard state
wxWizardPage *m_page; // the current page or nullptr
wxWizardPage *m_firstpage; // the page RunWizard started on or nullptr
wxBitmapBundle m_bitmap; // the default bitmap to show
// wizard controls
wxButton *m_btnPrev, // the "<Back" button
*m_btnNext; // the "Next>" or "Finish" button
wxStaticBitmap *m_statbmp; // the control for the bitmap
// cached labels so their translations stay consistent
wxString m_nextLabel,
m_finishLabel;
// Border around page area sizer requested using SetBorder()
int m_border;
// Whether RunWizard() was called
bool m_started;
// Whether was modal (modeless has to be destroyed on finish or cancel)
bool m_wasModal;
// True if pages are laid out using the sizer
bool m_usingSizer;
// Page area sizer will be inserted here with padding
wxBoxSizer *m_sizerBmpAndPage;
// Actual position and size of pages
wxWizardSizer *m_sizerPage;
// Bitmap background colour if resizing bitmap
wxColour m_bitmapBackgroundColour;
// Bitmap placement flags
int m_bitmapPlacement;
// Minimum bitmap width
int m_bitmapMinimumWidth;
friend class wxWizardSizer;
wxDECLARE_DYNAMIC_CLASS(wxWizard);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxWizard);
};
#endif // _WX_GENERIC_WIZARD_H_