📄 odcombo.h
字号:
///////////////////////////////////////////////////////////////////////////////
// Name: odcombo.h
// Purpose: wxPGComboBox and related classes interface
// Author: Jaakko Salli
// (loosely based on wxUniv combo.h by Vadim Zeitlin)
// Modified by:
// Created: Jan-25-2005
// RCS-ID: $Id:
// Copyright: (c) 2005 Jaakko Salli
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ODCOMBO_H_
#define _WX_ODCOMBO_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "odcombobox.h"
#endif
#include "wx/choice.h"
//#include "wx/popupwin.h"
class WXDLLEXPORT wxVListBox;
class WXDLLEXPORT wxTextCtrl;
class WXDLLEXPORT wxButton;
// Temp stuff
#ifdef WXMAKINGDLL_PROPGRID
#define WXDLLEXPORT_PGODC WXEXPORT
//#elif defined(WXUSINGDLL)
// #define WXDLLEXPORT_PGODC WXIMPORT
#else // not making nor using DLL
#define WXDLLEXPORT_PGODC
#endif
class WXDLLEXPORT_PGODC wxPGComboBox;
// ----------------------------------------------------------------------------
// wxComboPopupInterface is the interface class that lies between
// the wxPGComboBox and its popup window.
// ----------------------------------------------------------------------------
//
// Callback flags
//
// when set, we are painting the selected item in control, not in the popup
#define wxODCB_CB_PAINTING_CONTROL 0x0001
typedef void (wxEvtHandler::* wxComboPaintCallback)(wxPGComboBox* pCb,
int item,
wxDC& dc,
wxRect& rect,
int flags );
class WXDLLEXPORT_PGODC wxComboPopupInterface : public wxEvtHandler
{
friend class wxPGComboBox;
public:
wxComboPopupInterface();
virtual ~wxComboPopupInterface();
// default implementation does nothing
virtual void Clear();
// default implementation does nothing
virtual void Delete( int item );
// wxComboBox::FindString
// default implementation returns wxNOT_FOUND
virtual int FindString(const wxString& s) const;
// default implementation returns NULL
//virtual void* GetClientData( int item ) const;
// default implementation returns 0
virtual int GetCount() const;
// wxComboBox::GetString
// default implementation returns empty string
virtual wxString GetString( int item ) const;
// default implementation does nothing
virtual void Insert( const wxString& item, int pos );
// default implementation does nothing
//virtual void SetClientData( int item, void* clientData );
// wxComboBox::SetSelection
// default implementation does nothing
virtual void SetSelection( int item );
// wxComboBox::SetString
// default implementation does nothing
virtual void SetString( int item, const wxString& str );
// wxComboBox::SetValue
// default implementation does nothing
virtual void SetValueFromString ( const wxString& value );
// default implementation returns NULL
//virtual wxArrayString* GetArrayString();
// default implementation returns false
//virtual bool IsValueInt() const;
// returns TRUE if item is hilited
virtual bool IsHighlighted ( int item ) const;
// called by wxOwnerDrawComboBox after assigned to it
// If returns TRUE, then GeneratePopup is called immediately
// (instead of at the first time it is shown). Default returns
// TRUE.
virtual bool Init( wxPGComboBox* combo );
// returns pointer to created popup control
// parent = wxPopupWindow where combo popup should be placed
// if NULL, then it is not necesary to create the popup
// minWidth = preferred minimum width for window
// maxHeight = absolute maximum height for window
// prefHeight = preferred height. Only applies if > 0,
// and should only be rounded down, if necessary.
// isVolatile = set to true if window should be destroyed
// when hidden. If not then this method is still called.
// In this case, the existing window, with adjusted
// dimensions should be returned.
virtual wxWindow* GeneratePopup( wxWindow* parent, int minWidth,
int maxHeight, int prefHeight ) = 0;
// Returns pointer to the current value (if integer).
// With the default popup, for example, this returns pointer
// to int.
virtual const int* GetIntPtr () const;
// gets displayed string representation of the value
virtual wxString GetValueAsString() const = 0;
//
// Helper methods.
//wxPopupWindow* CreatePopupWindow () const;
// Event handler handles this.
//wxWindow* m_handledWnd;
//inline wxWindow* GetPopupControl() const { wxASSERT(m_popupAsWnd); return m_popupAsWnd; }
inline wxComboPaintCallback GetCallback() const { return m_callback; }
protected:
// TODO: Once popup transient window works Ok, remove these.
void OnMouseEvent( wxMouseEvent& event );
//void OnFocusChange ( wxFocusEvent& event );
wxPGComboBox* m_combo;
//wxWindow* m_popupAsWnd;
// Must be in all interfaces to paint the combobox too (in some cases)
wxComboPaintCallback m_callback;
private:
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// wxPGComboBox: a generic wxComboBox that allows custom paint items
// and even a completely custom popup control.
// ----------------------------------------------------------------------------
// New window styles
// if used, control itself is not custom paint using callback
// even if this is not used, writable combo is never custom paint
// until SetCustomPaintArea is called
#define wxODCB_STD_CONTROL_PAINT 0x0100
// Causes double-clicking to cycle the item instead of showing
// the popup. Shift-pressed causes cycling direction to reverse.
#define wxODCB_DOUBLE_CLICK_CYCLES 0x0200
#define wxOwnerDrawnComboBoxBase wxChoiceBase
class WXDLLEXPORT_PGODC wxPGComboBox : public wxOwnerDrawnComboBoxBase
{
friend class wxComboPopupWindow;
public:
// ctors and such
wxPGComboBox() { Init(); }
wxPGComboBox(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n,
const wxString choices[],
wxComboPaintCallback callback,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
Init();
(void)Create(parent, id, value, pos, size, n, choices,
callback, style, validator, name);
}
wxPGComboBox(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
wxComboPopupInterface* iface = (wxComboPopupInterface*) NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
Init();
(void)Create(parent, id, value, pos, size, iface,
style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
wxComboPopupInterface* iface = (wxComboPopupInterface*) NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
wxPGComboBox(wxWindow *parent,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -