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

📄 gtk.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    virtual void Press(wxScrollBar *scrollbar, bool doIt)    {        // only arrows can be pressed        if ( !IsArrow() )            return;        wxStdScrollBarInputHandler::Press(scrollbar, doIt);    }    // any button can be used to drag the scrollbar under GTK+    virtual bool IsAllowedButton(int WXUNUSED(button)) const { return true; }    bool IsArrow() const    {        return m_htLast == wxHT_SCROLLBAR_ARROW_LINE_1 ||                m_htLast == wxHT_SCROLLBAR_ARROW_LINE_2;    }};#endif // wxUSE_SCROLLBAR#if wxUSE_CHECKBOXclass wxGTKCheckboxInputHandler : public wxStdInputHandler{public:    wxGTKCheckboxInputHandler(wxInputHandler *handler)        : wxStdInputHandler(handler) { }    virtual bool HandleKey(wxInputConsumer *control,                           const wxKeyEvent& event,                           bool pressed);};#endif // wxUSE_CHECKBOX#if wxUSE_TEXTCTRLclass wxGTKTextCtrlInputHandler : public wxStdInputHandler{public:    wxGTKTextCtrlInputHandler(wxInputHandler *handler)        : wxStdInputHandler(handler) { }    virtual bool HandleKey(wxInputConsumer *control,                           const wxKeyEvent& event,                           bool pressed);};#endif // wxUSE_TEXTCTRL// ----------------------------------------------------------------------------// wxGTKColourScheme: uses the standard GTK colours// ----------------------------------------------------------------------------class wxGTKColourScheme : public wxColourScheme{public:    virtual wxColour Get(StdColour col) const;    virtual wxColour GetBackground(wxWindow *win) const;};// ----------------------------------------------------------------------------// wxGTKArtProvider// ----------------------------------------------------------------------------class wxGTKArtProvider : public wxArtProvider{protected:    virtual wxBitmap CreateBitmap(const wxArtID& id,                                  const wxArtClient& client,                                  const wxSize& size);};// ----------------------------------------------------------------------------// wxGTKTheme// ----------------------------------------------------------------------------WX_DEFINE_ARRAY_PTR(wxInputHandler *, wxArrayHandlers);class wxGTKTheme : public wxTheme{public:    wxGTKTheme();    virtual ~wxGTKTheme();    virtual wxRenderer *GetRenderer();    virtual wxArtProvider *GetArtProvider();    virtual wxInputHandler *GetInputHandler(const wxString& control,                                            wxInputConsumer *consumer);    virtual wxColourScheme *GetColourScheme();private:    wxGTKRenderer *m_renderer;    wxGTKArtProvider *m_artProvider;    // the names of the already created handlers and the handlers themselves    // (these arrays are synchronized)    wxSortedArrayString m_handlerNames;    wxArrayHandlers m_handlers;    wxGTKColourScheme *m_scheme;    WX_DECLARE_THEME(gtk)};// ============================================================================// implementation// ============================================================================WX_IMPLEMENT_THEME(wxGTKTheme, gtk, wxTRANSLATE("GTK+ theme"));// ----------------------------------------------------------------------------// wxGTKTheme// ----------------------------------------------------------------------------wxGTKTheme::wxGTKTheme(){    m_scheme = NULL;    m_renderer = NULL;    m_artProvider = NULL;}wxGTKTheme::~wxGTKTheme(){    delete m_renderer;    delete m_scheme;    delete m_artProvider;}wxRenderer *wxGTKTheme::GetRenderer(){    if ( !m_renderer )    {        m_renderer = new wxGTKRenderer(GetColourScheme());    }    return m_renderer;}wxArtProvider *wxGTKTheme::GetArtProvider(){    if ( !m_artProvider )    {        m_artProvider = new wxGTKArtProvider;    }    return m_artProvider;}wxColourScheme *wxGTKTheme::GetColourScheme(){    if ( !m_scheme )    {        m_scheme = new wxGTKColourScheme;    }    return m_scheme;}wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control,                                            wxInputConsumer *consumer){    wxInputHandler *handler = NULL;    int n = m_handlerNames.Index(control);    if ( n == wxNOT_FOUND )    {        static wxGTKInputHandler s_handlerDef;        wxInputHandler * const          handlerStd = consumer->DoGetStdInputHandler(&s_handlerDef);        // create a new handler#if wxUSE_CHECKBOX        if ( control == wxINP_HANDLER_CHECKBOX )        {            static wxGTKCheckboxInputHandler s_handler(handlerStd);            handler = &s_handler;        }        else#endif // wxUSE_CHECKBOX#if wxUSE_SCROLLBAR        if ( control == wxINP_HANDLER_SCROLLBAR )        {            static wxGTKScrollBarInputHandler s_handler(m_renderer, handlerStd);            handler = &s_handler;        }        else#endif // wxUSE_SCROLLBAR#if wxUSE_TEXTCTRL        if ( control == wxINP_HANDLER_TEXTCTRL )        {            static wxGTKTextCtrlInputHandler s_handler(handlerStd);            handler = &s_handler;        }        else#endif // wxUSE_TEXTCTRL        {            // no special handler for this control            handler = handlerStd;        }        n = m_handlerNames.Add(control);        m_handlers.Insert(handler, n);    }    else // we already have it    {        handler = m_handlers[n];    }    return handler;}// ============================================================================// wxGTKColourScheme// ============================================================================wxColour wxGTKColourScheme::GetBackground(wxWindow *win) const{    wxColour col;    if ( win->UseBgCol() )    {        // use the user specified colour        col = win->GetBackgroundColour();    }    if ( !win->ShouldInheritColours() )    {        // doesn't depend on the state        if ( !col.Ok() )        {            col = Get(WINDOW);        }    }    else    {        int flags = win->GetStateFlags();        // the colour set by the user should be used for the normal state        // and for the states for which we don't have any specific colours        if ( !col.Ok() || (flags != 0) )        {#if wxUSE_SCROLLBAR            if ( wxDynamicCast(win, wxScrollBar) )                col = Get(SCROLLBAR);            else#endif //wxUSE_SCROLLBAR                 if ( (flags & wxCONTROL_CURRENT) && win->CanBeHighlighted() )                col = Get(CONTROL_CURRENT);            else if ( flags & wxCONTROL_PRESSED )                col = Get(CONTROL_PRESSED);            else                col = Get(CONTROL);        }    }    return col;}wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col) const{    switch ( col )    {        case WINDOW:            return *wxWHITE;        case SHADOW_DARK:       return *wxBLACK;        case SHADOW_HIGHLIGHT:  return *wxWHITE;        case SHADOW_IN:         return wxColour(0xd6d6d6);        case SHADOW_OUT:        return wxColour(0x969696);        case CONTROL:           return wxColour(0xd6d6d6);        case CONTROL_PRESSED:   return wxColour(0xc3c3c3);        case CONTROL_CURRENT:   return wxColour(0xeaeaea);        case CONTROL_TEXT:      return *wxBLACK;        case CONTROL_TEXT_DISABLED:                                return wxColour(0x757575);        case CONTROL_TEXT_DISABLED_SHADOW:                                return *wxWHITE;        case SCROLLBAR:        case SCROLLBAR_PRESSED: return wxColour(0xc3c3c3);        case HIGHLIGHT:         return wxColour(0x9c0000);        case HIGHLIGHT_TEXT:    return wxColour(0xffffff);        case GAUGE:             return Get(CONTROL_CURRENT);        case TITLEBAR:          return wxColour(0xaeaaae);        case TITLEBAR_ACTIVE:   return wxColour(0x820300);        case TITLEBAR_TEXT:     return wxColour(0xc0c0c0);        case TITLEBAR_ACTIVE_TEXT:                                return *wxWHITE;        case DESKTOP:           return *wxBLACK;        case MAX:        default:            wxFAIL_MSG(_T("invalid standard colour"));            return *wxBLACK;    }}// ============================================================================// wxGTKRenderer// ============================================================================// ----------------------------------------------------------------------------// construction// ----------------------------------------------------------------------------wxGTKRenderer::wxGTKRenderer(const wxColourScheme *scheme)             : wxStdRenderer(scheme){    m_sizeScrollbarArrow = wxSize(15, 14);    m_penGrey = wxPen(wxSCHEME_COLOUR(scheme, SCROLLBAR));}// ----------------------------------------------------------------------------// border stuff// ----------------------------------------------------------------------------void wxGTKRenderer::DrawAntiShadedRectSide(wxDC& dc,                                           const wxRect& rect,                                           const wxPen& pen1,                                           const wxPen& pen2,                                           wxDirection dir){    dc.SetPen(dir == wxLEFT || dir == wxUP ? pen1 : pen2);    switch ( dir )    {        case wxLEFT:            dc.DrawLine(rect.GetLeft(), rect.GetTop(),                        rect.GetLeft(), rect.GetBottom() + 1);            break;        case wxUP:            dc.DrawLine(rect.GetLeft(), rect.GetTop(),                        rect.GetRight() + 1, rect.GetTop());            break;        case wxRIGHT:            dc.DrawLine(rect.GetRight(), rect.GetTop(),                        rect.GetRight(), rect.GetBottom() + 1);            break;        case wxDOWN:            dc.DrawLine(rect.GetLeft(), rect.GetBottom(),                        rect.GetRight() + 1, rect.GetBottom());            break;        default:            wxFAIL_MSG(_T("unknown rectangle side"));    }}void wxGTKRenderer::DrawAntiShadedRect(wxDC& dc, wxRect *rect,                                       const wxPen& pen1, const wxPen& pen2){    // draw the rectangle    dc.SetPen(pen1);    dc.DrawLine(rect->GetLeft(), rect->GetTop(),                rect->GetLeft(), rect->GetBottom() + 1);    dc.DrawLine(rect->GetLeft() + 1, rect->GetTop(),                rect->GetRight() + 1, rect->GetTop());    dc.SetPen(pen2);    dc.DrawLine(rect->GetRight(), rect->GetTop() + 1,                rect->GetRight(), rect->GetBottom());    dc.DrawLine(rect->GetLeft() + 1, rect->GetBottom(),                rect->GetRight() + 1, rect->GetBottom());    // adjust the rect    rect->Inflate(-1);}void wxGTKRenderer::DrawInnerShadedRect(wxDC& dc, wxRect *rect){    DrawAntiShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);    DrawAntiShadedRect(dc, rect, m_penBlack, m_penHighlight);}void wxGTKRenderer::DrawAntiRaisedBorder(wxDC& dc, wxRect *rect){    DrawShadedRect(dc, rect, m_penHighlight, m_penBlack);    DrawAntiShadedRect(dc, rect, m_penLightGrey, m_penDarkGrey);}void wxGTKRenderer::DrawSunkenBorder(wxDC& dc, wxRect *rect){    DrawAntiShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);    DrawShadedRect(dc, rect, m_penBlack, m_penLightGrey);}voidwxGTKRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int WXUNUSED(flags)){    dc.SetBrush(*wxTRANSPARENT_BRUSH);    wxRect rectFocus = rect;    DrawRect(dc, &rectFocus, m_penBlack);}void wxGTKRenderer::DrawTextBorder(wxDC& dc,                                   wxBorder border,                                   const wxRect& rectOrig,                                   int flags,                                   wxRect *rectIn){    wxRect rect = rectOrig;    if ( border != wxBORDER_NONE )

⌨️ 快捷键说明

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