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

📄 metal.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////// Name:        src/univ/themes/metal.cpp// Purpose:     wxUniversal theme implementing Win32-like LNF// Author:      Vadim Zeitlin, Robert Roebling// Modified by:// Created:     06.08.00// RCS-ID:      $Id: metal.cpp,v 1.23 2006/10/26 15:33:10 VS Exp $// Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)// Licence:     wxWindows licence///////////////////////////////////////////////////////////////////////////////// ===========================================================================// declarations// ===========================================================================// ---------------------------------------------------------------------------// headers// ---------------------------------------------------------------------------// For compilers that support precompilation, includes "wx.h".#include "wx/wxprec.h"#ifdef __BORLANDC__    #pragma hdrstop#endif#include "wx/univ/theme.h"#if wxUSE_THEME_METAL#ifndef WX_PRECOMP    #include "wx/timer.h"    #include "wx/intl.h"    #include "wx/dc.h"    #include "wx/window.h"    #include "wx/dcmemory.h"    #include "wx/button.h"    #include "wx/listbox.h"    #include "wx/checklst.h"    #include "wx/combobox.h"    #include "wx/scrolbar.h"    #include "wx/slider.h"    #include "wx/textctrl.h"    #include "wx/toolbar.h"    #include "wx/menu.h"    #include "wx/settings.h"    #include "wx/toplevel.h"#endif // WX_PRECOMP#include "wx/notebook.h"#include "wx/spinbutt.h"#include "wx/artprov.h"#include "wx/univ/scrtimer.h"#include "wx/univ/renderer.h"#include "wx/univ/inpcons.h"#include "wx/univ/inphand.h"#include "wx/univ/colschem.h"// ----------------------------------------------------------------------------// wxMetalRenderer: draw the GUI elements in Metal style// ----------------------------------------------------------------------------class wxMetalRenderer : public wxDelegateRenderer{    // FIXME cut'n'paste from Win32    enum wxArrowDirection    {        Arrow_Left,        Arrow_Right,        Arrow_Up,        Arrow_Down,        Arrow_Max    };    enum wxArrowStyle    {        Arrow_Normal,        Arrow_Disabled,        Arrow_Pressed,        Arrow_Inverted,        Arrow_InvertedDisabled,        Arrow_StateMax    };public:    wxMetalRenderer(wxRenderer *renderer, wxColourScheme* scheme);    virtual void DrawButtonSurface(wxDC& dc,                                   const wxColour& WXUNUSED(col),                                   const wxRect& rect,                                   int WXUNUSED(flags))        { DrawMetal(dc, rect); }    virtual void DrawScrollbarThumb(wxDC& dc,                                    wxOrientation orient,                                    const wxRect& rect,                                    int flags);    virtual void DrawScrollbarShaft(wxDC& dc,                                    wxOrientation orient,                                    const wxRect& rectBar,                                    int flags);    virtual void GetComboBitmaps(wxBitmap *bmpNormal,                                 wxBitmap *bmpFocus,                                 wxBitmap *bmpPressed,                                 wxBitmap *bmpDisabled);    virtual void DrawArrow(wxDC& dc,                           wxDirection dir,                           const wxRect& rect,                           int flags = 0);protected:    void DrawArrowButton(wxDC& dc,                         const wxRect& rectAll,                         wxArrowDirection arrowDir,                         wxArrowStyle arrowStyle);    void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);    void DrawShadedRect(wxDC& dc, wxRect *rect,                        const wxPen& pen1, const wxPen& pen2);    void DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed = false);    void DrawArrow(wxDC& dc, const wxRect& rect,                   wxArrowDirection arrowDir, wxArrowStyle arrowStyle);    void DrawMetal(wxDC &dc, const wxRect &rect );private:    wxPen m_penBlack,          m_penDarkGrey,          m_penLightGrey,          m_penHighlight;    wxBitmap m_bmpArrows[Arrow_StateMax][Arrow_Max];};// ----------------------------------------------------------------------------// wxMetalTheme// ----------------------------------------------------------------------------class wxMetalTheme : public wxDelegateTheme{public:    wxMetalTheme() : wxDelegateTheme(_T("win32")), m_renderer(NULL) {}    ~wxMetalTheme() { delete m_renderer; }protected:    virtual wxRenderer *GetRenderer()    {        if ( !m_renderer )        {            m_renderer = new wxMetalRenderer(m_theme->GetRenderer(),                                             GetColourScheme());        }        return m_renderer;    }    wxRenderer *m_renderer;    WX_DECLARE_THEME(Metal)};WX_IMPLEMENT_THEME(wxMetalTheme, Metal, wxTRANSLATE("Metal theme"));// ============================================================================// implementation// ============================================================================// ----------------------------------------------------------------------------// wxMetalRenderer// ----------------------------------------------------------------------------wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)               : wxDelegateRenderer(renderer){    // init colours and pens    m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);    m_penDarkGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_OUT), 0, wxSOLID);    m_penLightGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_IN), 0, wxSOLID);    m_penHighlight = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_HIGHLIGHT), 0, wxSOLID);    // init the arrow bitmaps    static const size_t ARROW_WIDTH = 7;    static const size_t ARROW_LENGTH = 4;    wxMask *mask;    wxMemoryDC dcNormal,               dcDisabled,               dcInverse;    for ( size_t n = 0; n < Arrow_Max; n++ )    {        bool isVertical = n > Arrow_Right;        int w, h;        if ( isVertical )        {            w = ARROW_WIDTH;            h = ARROW_LENGTH;        }        else        {            h = ARROW_WIDTH;            w = ARROW_LENGTH;        }        // disabled arrow is larger because of the shadow        m_bmpArrows[Arrow_Normal][n].Create(w, h);        m_bmpArrows[Arrow_Disabled][n].Create(w + 1, h + 1);        dcNormal.SelectObject(m_bmpArrows[Arrow_Normal][n]);        dcDisabled.SelectObject(m_bmpArrows[Arrow_Disabled][n]);        dcNormal.SetBackground(*wxWHITE_BRUSH);        dcDisabled.SetBackground(*wxWHITE_BRUSH);        dcNormal.Clear();        dcDisabled.Clear();        dcNormal.SetPen(m_penBlack);        dcDisabled.SetPen(m_penDarkGrey);        // calculate the position of the point of the arrow        wxCoord x1, y1;        if ( isVertical )        {            x1 = (ARROW_WIDTH - 1)/2;            y1 = n == Arrow_Up ? 0 : ARROW_LENGTH - 1;        }        else // horizontal        {            x1 = n == Arrow_Left ? 0 : ARROW_LENGTH - 1;            y1 = (ARROW_WIDTH - 1)/2;        }        wxCoord x2 = x1,                y2 = y1;        if ( isVertical )            x2++;        else            y2++;        for ( size_t i = 0; i < ARROW_LENGTH; i++ )        {            dcNormal.DrawLine(x1, y1, x2, y2);            dcDisabled.DrawLine(x1, y1, x2, y2);            if ( isVertical )            {                x1--;                x2++;                if ( n == Arrow_Up )                {                    y1++;                    y2++;                }                else // down arrow                {                    y1--;                    y2--;                }            }            else // left or right arrow            {                y1--;                y2++;                if ( n == Arrow_Left )                {

⌨️ 快捷键说明

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