⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odcombo.h

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 H
📖 第 1 页 / 共 2 页
字号:
               wxWindowID id,
               const wxString& value,
               const wxPoint& pos,
               const wxSize& size,
               const wxArrayString& choices,
               wxComboPaintCallback callback = (wxComboPaintCallback) NULL,
               long style = 0,
               const wxValidator& validator = wxDefaultValidator,
               const wxString& name = wxComboBoxNameStr);

    bool Create(wxWindow *parent,
                wxWindowID id,
                const wxString& value = wxEmptyString,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                int n = 0,
                const wxString choices[] = (const wxString *) NULL,
                wxComboPaintCallback callback = (wxComboPaintCallback) NULL,
                long style = 0,
                const wxValidator& validator = wxDefaultValidator,
                const wxString& name = wxComboBoxNameStr);

    bool Create(wxWindow *parent,
                wxWindowID id,
                const wxString& value,
                const wxPoint& pos,
                const wxSize& size,
                const wxArrayString& choices,
                wxComboPaintCallback callback = (wxComboPaintCallback) NULL,
                long style = 0,
                const wxValidator& validator = wxDefaultValidator,
                const wxString& name = wxComboBoxNameStr);

    virtual ~wxPGComboBox();

// a combo control needs a control for popup window it displays
    //void SetPopupControl(wxComboPopup *popup);
    wxComboPopupInterface* GetPopupInterface() const { return m_popupInterface; }

    // show/hide popup window
    void ShowPopup();
    void HidePopup( bool sendEvent = true );

    // common code to be called on popup hide
    void OnPopupDismiss();

    // return true if the popup is currently shown
    bool IsPopupShown() const { return (m_isPopupShown > 0); }

    // get the popup window containing the popup control
    wxWindow *GetPopupWindow() const { return m_winPopup; }

    // get the popup control/panel in window
    wxWindow *GetPopupControl() const { return m_popup; }

    // get the text control which is part of the combobox
    wxTextCtrl *GetText() const { return m_text; }

    // get the dropdown button which is part of the combobox
    wxWindow *GetButton() const { return m_btn; }

    // implementation only from now on
    // -------------------------------

    // notifications from wxComboPopup (shouldn't be called by anybody else)

    // forward these functions to all subcontrols
    virtual bool Enable(bool enable = true);
    virtual bool Show(bool show = true);
    virtual bool SetFont(const wxFont& font);
    virtual void SetFocus();
    virtual void SetFocusFromKbd();
    void SetId( wxWindowID winid );

    // Return TRUE if item is hilited in the combo
    bool IsHighlighted ( int item ) const;

#if wxUSE_TOOLTIPS
    virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS

    // the wxUniversal-specific methods
    // --------------------------------

    // implement the combobox interface

    // wxTextCtrl methods
    virtual wxString GetValue() const;
    virtual void SetValue(const wxString& value);
    virtual void Copy();
    virtual void Cut();
    virtual void Paste();
    virtual void SetInsertionPoint(long pos);
    virtual void SetInsertionPointEnd();
    virtual long GetInsertionPoint() const;
    virtual long GetLastPosition() const;
    virtual void Replace(long from, long to, const wxString& value);
    virtual void Remove(long from, long to);
    virtual void SetSelection(long from, long to);
    //virtual void SetEditable(bool editable);

    // wxControlWithItems methods
    virtual void Clear();
    virtual void Delete(int n);
    virtual int GetCount() const;
    virtual wxString GetString(int n) const;
    virtual void SetString(int n, const wxString& s);
    virtual int FindString(const wxString& s) const;
    virtual void Select(int n);
    virtual int GetSelection() const;
    void SetSelection(int n) { Select(n); }

    // wxPGComboBox-only methods

    // Adjust popup size.
    //   extLeft = how many pixels the popup extends to the left
    //   extRight = how many pixels the popup extends to the right
    //   prefHeight = preferred popup height
    void SetPopupExtents( int extLeft, int extRight = 0, int prefHeight = -1 );

    // set width of custom paint area in writable combo
    // in read-only, used to indicate area that is not covered by the
    // "blue" colour drawn when control is focused.
    void SetCustomPaintArea( int width );

    void SetPopupInterface( wxComboPopupInterface* iface );

    inline void PreventNextButtonPopup()
    {
        m_isPopupShown = -1;
    }

    //void SetStringSelection(const wxString& WXUNUSED(s)) {  }

    wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST

    //inline bool HasClientObjectData () const { return false; }

protected:

    // override the base class virtuals involved into geometry calculations
    //virtual wxSize DoGetBestClientSize() const;
    virtual void DoMoveWindow(int x, int y, int width, int height);
    /*virtual void DoSetSize(int x, int y,
                           int width, int height,
                           int sizeFlags = wxSIZE_AUTO);*/
    virtual wxSize DoGetBestSize() const;

    // event handlers
    void OnMouseEvent( wxMouseEvent& event );
    void OnPaint( wxPaintEvent& event );
    void OnResize( wxSizeEvent& event );
    //void OnKey(wxKeyEvent& event);
    void OnFocusEvent( wxFocusEvent& event );
    void OnButtonClick(wxCommandEvent& event);

    // common part of all ctors
    void Init();

    // clears all allocated client datas
    void ClearClientDatas();

    virtual int DoAppend(const wxString& item);
    virtual int DoInsert(const wxString& item, int pos);
    virtual void DoSetItemClientData(int n, void* clientData);
    virtual void* DoGetItemClientData(int n) const;
    virtual void DoSetItemClientObject(int n, wxClientData* clientData);
    virtual wxClientData* DoGetItemClientObject(int n) const;

    // get the associated listbox
    //wxListBox *GetLBox() const { return m_lbox; }

    // This is used when m_text is hidden (readonly).
    wxString    m_valueString;

    // the text control and button we show all the time
    wxTextCtrl *m_text;
    wxWindow *m_btn;

    // the popup control/panel
    wxWindow *m_popup;

    // popup interface
    wxComboPopupInterface*  m_popupInterface;

    // popup window containing the window managed by the interface .
    wxWindow *m_winPopup;

    // this is for this control itself
    wxEvtHandler *m_extraEvtHandler;

    // this is for text
    wxEvtHandler *m_textEvtHandler;

    // this is for the top level window
    wxEvtHandler *m_toplevEvtHandler;

    // holder for client datas
    wxArrayPtrVoid m_clientDatas;

    // how much popup should expand to the left/right of the control
    wxCoord m_extLeft;
    wxCoord m_extRight;

    // preferred popup height. default is -1.
    wxCoord m_heightPopup;

    // how much of writable combo is custom-paint by callback?
    // also used to indicate area that is not covered by "blue"
    // selection indicator.
    wxCoord m_widthCustomPaint;

    // FIXME: Only necessary for GTK and its kind
    wxCoord m_widthCustomBorder;

    // is the popup window currenty shown?
    // < 0 is special value
    int m_isPopupShown;

    // is the data type of interface 'int'?
    bool m_hasIntValue;

    // TODO: Remove after real popup works ok.
    unsigned char m_fakePopupUsage;

    // should popup be destroyed on close?
    //bool m_isPopupVolatile;

private:
    DECLARE_EVENT_TABLE()

    DECLARE_DYNAMIC_CLASS(wxPGComboBox)
};

#endif // _WX_ODCOMBO_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -