X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e569b493727b8e4306b404c71b5a2284034f9134..d0332cbc07d487c30d83515fb3351790565ec1de:/include/wx/combo.h diff --git a/include/wx/combo.h b/include/wx/combo.h index 902c0bc5b9..0c31d0bb50 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -86,8 +86,8 @@ enum 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). @@ -118,7 +118,8 @@ struct wxComboCtrlFeatures 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 @@ -157,7 +158,7 @@ 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(); @@ -302,19 +303,18 @@ public: const wxBitmap& bmpHover = wxNullBitmap, const wxBitmap& bmpDisabled = wxNullBitmap ); +#if WXWIN_COMPATIBILITY_2_8 // // 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 @@ -385,6 +385,21 @@ public: const wxBitmap& GetBitmapHover() const { return m_bmpHover; } const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } + // Hint functions mirrored from TextEntryBase + virtual bool SetHint(const wxString& hint); + virtual wxString GetHint() const; + + // 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; } @@ -392,7 +407,7 @@ public: 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 @@ -416,6 +431,16 @@ public: protected: + // Returns true if hint text should be drawn in the control + bool ShouldUseHintText(int flags = 0) const + { + return ( !m_text && + !(flags & wxCONTROL_ISSUBMENU) && + !m_valueString.length() && + m_hintText.length() && + !ShouldDrawFocus() ); + } + // // Override these for customization purposes // @@ -423,7 +448,8 @@ 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 @@ -471,6 +497,10 @@ protected: // override the base class virtuals involved in geometry calculations virtual wxSize DoGetBestSize() const; + // also set the embedded wxTextCtrl colours + virtual bool SetForegroundColour(const wxColour& colour); + virtual bool SetBackgroundColour(const wxColour& colour); + // NULL popup can be used to indicate default in a derived class virtual void DoSetPopupControl(wxComboPopup* popup); @@ -493,6 +523,7 @@ protected: void OnTextCtrlEvent(wxCommandEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event); void OnKeyEvent(wxKeyEvent& event); + void OnCharEvent(wxKeyEvent& event); // Set customization flags (directs how wxComboCtrlBase helpers behave) void Customize( wxUint32 flags ) { m_iFlags |= flags; } @@ -521,9 +552,16 @@ protected: virtual void DoSetToolTip( wxToolTip *tip ); #endif + // margins functions + virtual bool DoSetMargins(const wxPoint& pt); + virtual wxPoint DoGetMargins() const; + // This is used when m_text is hidden (readonly). wxString m_valueString; + // This is used when control is unfocused and m_valueString is empty + wxString m_hintText; + // the text control and button we show all the time wxTextCtrl* m_text; wxWindow* m_btn; @@ -572,8 +610,8 @@ protected: // 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; @@ -617,7 +655,7 @@ protected: // should the focus be reset to the textctrl in idle time? bool m_resetFocus; - + private: void Init(); @@ -644,6 +682,8 @@ enum wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called }; +class WXDLLIMPEXP_FWD_CORE wxComboCtrl; + class WXDLLIMPEXP_CORE wxComboPopup { @@ -651,7 +691,7 @@ class WXDLLIMPEXP_CORE wxComboPopup public: wxComboPopup() { - m_combo = (wxComboCtrlBase*) NULL; + m_combo = NULL; m_iFlags = 0; } @@ -687,10 +727,14 @@ public: // Default implementation draws value as string. virtual void PaintComboControl( wxDC& dc, const wxRect& rect ); - // Receives key events from the parent wxComboCtrl. + // Receives wxEVT_KEY_DOWN key events from the parent wxComboCtrl. // Events not handled should be skipped, as usual. virtual void OnComboKeyEvent( wxKeyEvent& event ); + // Receives wxEVT_CHAR key events from the parent wxComboCtrl. + // Events not handled should be skipped, as usual. + virtual void OnComboCharEvent( wxKeyEvent& event ); + // Implement if you need to support special action when user // double-clicks on the parent wxComboCtrl. virtual void OnComboDoubleClick(); @@ -721,6 +765,9 @@ public: 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,