#include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags
#include "wx/bitmap.h" // wxBitmap used by-value
-class WXDLLIMPEXP_CORE wxTextCtrl;
-class WXDLLEXPORT wxComboPopup;
+class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
+class WXDLLIMPEXP_FWD_CORE wxComboPopup;
//
// New window styles for wxComboCtrlBase
wxCC_POPUP_ON_MOUSE_UP = 0x0002,
// All text is not automatically selected on click
wxCC_NO_TEXT_AUTO_SELECT = 0x0004,
+ // Drop-button stays down as long as popup is displayed.
+ wxCC_BUTTON_STAYS_DOWN = 0x0008,
+ // Drop-button covers the entire control.
+ wxCC_FULL_BUTTON = 0x0010,
+ // Drop-button goes over the custom-border (used under WinVista).
+ wxCC_BUTTON_COVERS_BORDER = 0x0020,
// Internal use: signals creation is complete
wxCC_IFLAG_CREATED = 0x0100,
// Internal use: really put button outside
wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200,
- // Internal use: SetTextIndent has been called
- wxCC_IFLAG_INDENT_SET = 0x0400,
+ // Internal use: SetMargins has been succesfully called
+ wxCC_IFLAG_LEFT_MARGIN_SET = 0x0400,
// Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800,
// Internal use: Secondary popup window type should be used (if available).
wxCC_IFLAG_USE_ALT_POPUP = 0x1000,
// Internal use: Skip popup animation.
- wxCC_IFLAG_DISABLE_POPUP_ANIM = 0x2000
+ wxCC_IFLAG_DISABLE_POPUP_ANIM = 0x2000,
+ // Internal use: Drop-button is a bitmap button or has non-default size
+ // (but can still be on either side of the control).
+ wxCC_IFLAG_HAS_NONSTANDARD_BUTTON = 0x4000
};
BitmapButton = 0x0002, // Button may be replaced with bitmap
ButtonSpacing = 0x0004, // Button can have spacing from the edge
// of the control
- TextIndent = 0x0008, // SetTextIndent can be used
+ TextIndent = 0x0008, // SetMargins can be used to control
+ // left margin.
PaintControl = 0x0010, // Combo control itself can be custom painted
PaintWritable = 0x0020, // A variable-width area in front of writable
// combo control's textctrl can be custom
};
-class WXDLLEXPORT wxComboCtrlBase : public wxControl
+class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxControl
{
friend class wxComboPopup;
public:
// show/hide popup window
virtual void ShowPopup();
- virtual void HidePopup();
+ virtual void HidePopup(bool generateEvent=false);
// Override for totally custom combo action
virtual void OnButtonClick();
const wxBitmap& bmpHover = wxNullBitmap,
const wxBitmap& bmpDisabled = wxNullBitmap );
+#if WXWIN_COMPATIBILITY_2_6
//
// This will set the space in pixels between left edge of the control and the
// text, regardless whether control is read-only (ie. no wxTextCtrl) or not.
// Platform-specific default can be set with value-1.
// Remarks
// * This method may do nothing on some native implementations.
- void SetTextIndent( int indent );
+ wxDEPRECATED( void SetTextIndent( int indent ) );
// Returns actual indentation in pixels.
- wxCoord GetTextIndent() const
- {
- return m_absIndent;
- }
+ wxDEPRECATED( wxCoord GetTextIndent() const );
+#endif
// Returns area covered by the text field.
const wxRect& GetTextRect() const
bool ShouldDrawFocus() const
{
const wxWindow* curFocus = FindFocus();
- return ( !IsPopupShown() &&
- (curFocus == this || (m_btn && curFocus == m_btn)) &&
+ return ( IsPopupWindowState(Hidden) &&
+ (curFocus == m_mainCtrlWnd || (m_btn && curFocus == m_btn)) &&
(m_windowStyle & wxCB_READONLY) );
}
const wxBitmap& GetBitmapHover() const { return m_bmpHover; }
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
+ // Margins functions mirrored from TextEntryBase
+ // (wxComboCtrl does not inherit from wxTextEntry, but may embed a
+ // wxTextCtrl, so we need these). Also note that these functions
+ // have replaced SetTextIndent() in wxWidgets 2.9.1 and later.
+ bool SetMargins(const wxPoint& pt)
+ { return DoSetMargins(pt); }
+ bool SetMargins(wxCoord left, wxCoord top = -1)
+ { return DoSetMargins(wxPoint(left, top)); }
+ wxPoint GetMargins() const
+ { return DoGetMargins(); }
+
// Return internal flags
wxUint32 GetInternalFlags() const { return m_iFlags; }
bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; }
// common code to be called on popup hide/dismiss
- void OnPopupDismiss();
+ void OnPopupDismiss(bool generateEvent);
// PopupShown states
enum
// Set value returned by GetMainWindowOfCompositeControl
void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; }
+ // This is public so we can access it from wxComboCtrlTextCtrl
+ virtual wxWindow *GetMainWindowOfCompositeControl()
+ { return m_mainCtrlWnd; }
+
protected:
//
// called from wxSizeEvent handler
virtual void OnResize() = 0;
- // Return native text identation (for pure text, not textctrl)
+ // Return native text identation
+ // (i.e. text margin, for pure text, not textctrl)
virtual wxCoord GetNativeTextIndent() const;
// Called in syscolourchanged handler and base create
// Installs standard input handler to combo (and optionally to the textctrl)
void InstallInputHandlers();
- // flags for DrawButton()
+ // Flags for DrawButton
enum
{
- Draw_PaintBg = 1
+ Button_PaintBackground = 0x0001, // Paints control background below the button
+ Button_BitmapOnly = 0x0002 // Only paints the bitmap
};
// Draws dropbutton. Using wxRenderer or bitmaps, as appropriate.
- void DrawButton( wxDC& dc, const wxRect& rect, int flags = Draw_PaintBg );
+ // Flags are defined above.
+ virtual void DrawButton( wxDC& dc, const wxRect& rect, int flags = Button_PaintBackground );
// Call if cursor is on button area or mouse is captured for the button.
//bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside );
// Standard textctrl positioning routine. Just give it platform-dependant
// textctrl coordinate adjustment.
- void PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust );
+ virtual void PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust );
// event handlers
void OnSizeEvent( wxSizeEvent& event );
void OnFocusEvent(wxFocusEvent& event);
+ void OnIdleEvent(wxIdleEvent& event);
void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event);
virtual void DoSetToolTip( wxToolTip *tip );
#endif
- virtual wxWindow *GetMainWindowOfCompositeControl()
- { return m_mainCtrlWnd; }
+ // margins functions
+ virtual bool DoSetMargins(const wxPoint& pt);
+ virtual wxPoint DoGetMargins() const;
// This is used when m_text is hidden (readonly).
wxString m_valueString;
// selection indicator.
wxCoord m_widthCustomPaint;
- // absolute text indentation, in pixels
- wxCoord m_absIndent;
+ // left margin, in pixels
+ wxCoord m_marginLeft;
// side on which the popup is aligned
int m_anchorSide;
// is the popup window currenty shown?
wxByte m_popupWinState;
+ // should the focus be reset to the textctrl in idle time?
+ bool m_resetFocus;
+
private:
void Init();
wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called
};
+class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
+
-class WXDLLEXPORT wxComboPopup
+class WXDLLIMPEXP_CORE wxComboPopup
{
friend class wxComboCtrlBase;
public:
wxComboPopup()
{
- m_combo = (wxComboCtrlBase*) NULL;
+ m_combo = NULL;
m_iFlags = 0;
}
// variable has been initialized before the call.
// NOTE: It is not in constructor so the derived class doesn't need to redefine
// a default constructor of its own.
- virtual void Init() { };
+ virtual void Init() { }
virtual ~wxComboPopup();
return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false;
}
+ // Returns pointer to the associated parent wxComboCtrl.
+ wxComboCtrl* GetComboCtrl() const;
+
// Default PaintComboControl behaviour
static void DefaultPaintComboControl( wxComboCtrlBase* combo,
wxDC& dc,