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

📄 win32.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
"dbwwwbbwwwgh"," dbwwwwwwgh "," dggwwwwggh ","  hhgggghh  ","    hhhh    "};static const char *pressed_checked_radio_xpm[] = {/* columns rows colors chars-per-pixel */"12 12 6 1","  c None","w c white","b c black","d c #7f7f7f","g c #c0c0c0","h c #e0e0e0",/* pixels */"    dddd    ","  ddbbbbdd  "," dbbggggbbh "," dbgggggggh ","dbgggbbggggh","dbggbbbbgggh","dbggbbbbgggh","dbgggbbggggh"," dbgggggggh "," dggggggggh ","  hhgggghh  ","    hhhh    "};static const char *pressed_disabled_checked_radio_xpm[] = {/* columns rows colors chars-per-pixel */"12 12 6 1","  c None","w c white","b c black","d c #7f7f7f","g c #c0c0c0","h c #e0e0e0",/* pixels */"    dddd    ","  ddbbbbdd  "," dbbggggbbh "," dbgggggggh ","dbgggddggggh","dbggddddgggh","dbggddddgggh","dbgggddggggh"," dbgggggggh "," dggggggggh ","  hhgggghh  ","    hhhh    ",};static const char *unchecked_radio_xpm[] = {/* columns rows colors chars-per-pixel */"12 12 6 1","  c None","w c white","b c black","d c #7f7f7f","g c #c0c0c0","h c #e0e0e0",/* pixels */"    dddd    ","  ddbbbbdd  "," dbbwwwwbbh "," dbwwwwwwgh ","dbwwwwwwwwgh","dbwwwwwwwwgh","dbwwwwwwwwgh","dbwwwwwwwwgh"," dbwwwwwwgh "," dggwwwwggh ","  hhgggghh  ","    hhhh    "};static const char *pressed_unchecked_radio_xpm[] = {/* columns rows colors chars-per-pixel */"12 12 6 1","  c None","w c white","b c black","d c #7f7f7f","g c #c0c0c0","h c #e0e0e0",/* pixels */"    dddd    ","  ddbbbbdd  "," dbbggggbbh "," dbgggggggh ","dbgggggggggh","dbgggggggggh","dbgggggggggh","dbgggggggggh"," dbgggggggh "," dggggggggh ","  hhgggghh  ","    hhhh    "};const char **wxWin32Renderer::ms_xpmIndicators[IndicatorType_Max]                                              [IndicatorState_MaxMenu]                                              [IndicatorStatus_Max] ={    // checkboxes first    {        // normal state        { checked_xpm, unchecked_xpm, undetermined_xpm },        // pressed state        { pressed_checked_xpm, pressed_unchecked_xpm, pressed_undetermined_xpm },        // disabled state        { pressed_disabled_checked_xpm, pressed_unchecked_xpm, pressed_disabled_checked_xpm },    },    // radio    {        // normal state        { checked_radio_xpm, unchecked_radio_xpm, NULL },        // pressed state        { pressed_checked_radio_xpm, pressed_unchecked_radio_xpm, NULL },        // disabled state        { pressed_disabled_checked_radio_xpm, pressed_unchecked_radio_xpm, NULL },    },    // menu    {        // normal state        { checked_menu_xpm, NULL, NULL },        // selected state        { selected_checked_menu_xpm, NULL, NULL },        // disabled state        { disabled_checked_menu_xpm, NULL, NULL },        // disabled selected state        { selected_disabled_checked_menu_xpm, NULL, NULL },    }};const char **wxWin32Renderer::ms_xpmChecked[IndicatorStatus_Max] ={    checked_item_xpm,    unchecked_item_xpm};// ============================================================================// implementation// ============================================================================WX_IMPLEMENT_THEME(wxWin32Theme, win32, wxTRANSLATE("Win32 theme"));// ----------------------------------------------------------------------------// wxWin32Theme// ----------------------------------------------------------------------------wxWin32Theme::wxWin32Theme(){    m_scheme = NULL;    m_renderer = NULL;    m_artProvider = NULL;}wxWin32Theme::~wxWin32Theme(){    delete m_renderer;    delete m_scheme;    delete m_artProvider;}wxRenderer *wxWin32Theme::GetRenderer(){    if ( !m_renderer )    {        m_renderer = new wxWin32Renderer(GetColourScheme());    }    return m_renderer;}wxArtProvider *wxWin32Theme::GetArtProvider(){    if ( !m_artProvider )    {        m_artProvider = new wxWin32ArtProvider;    }    return m_artProvider;}wxInputHandler *wxWin32Theme::GetInputHandler(const wxString& control,                              wxInputConsumer *consumer){    wxInputHandler *handler = NULL;    int n = m_handlerNames.Index(control);    if ( n == wxNOT_FOUND )    {        static wxWin32InputHandler s_handlerDef;        wxInputHandler * const          handlerStd = consumer->DoGetStdInputHandler(&s_handlerDef);        // create a new handler        if ( control == wxINP_HANDLER_TOPLEVEL )        {            static wxWin32FrameInputHandler s_handler(handlerStd);            handler = &s_handler;        }#if wxUSE_CHECKBOX        else if ( control == wxINP_HANDLER_CHECKBOX )        {            static wxWin32CheckboxInputHandler s_handler(handlerStd);            handler = &s_handler;        }#endif // wxUSE_CHECKBOX#if wxUSE_SCROLLBAR        else if ( control == wxINP_HANDLER_SCROLLBAR )        {            static wxWin32ScrollBarInputHandler                s_handler(GetRenderer(), handlerStd);            handler = &s_handler;        }#endif // wxUSE_SCROLLBAR#if wxUSE_STATUSBAR        else if ( control == wxINP_HANDLER_STATUSBAR )        {            static wxWin32StatusBarInputHandler s_handler(handlerStd);            handler = &s_handler;        }#endif // wxUSE_STATUSBAR#if wxUSE_TEXTCTRL        else if ( control == wxINP_HANDLER_TEXTCTRL )        {            static wxWin32TextCtrlInputHandler s_handler(handlerStd);            handler = &s_handler;        }#endif // wxUSE_TEXTCTRL        else // 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;}wxColourScheme *wxWin32Theme::GetColourScheme(){    if ( !m_scheme )    {        m_scheme = new wxWin32ColourScheme;    }    return m_scheme;}// ============================================================================// wxWin32ColourScheme// ============================================================================wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const{    wxColour col;    if ( win->UseBgCol() )    {        // use the user specified colour        col = win->GetBackgroundColour();    }    if ( !win->ShouldInheritColours() )    {#if wxUSE_TEXTCTRL        wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);#endif // wxUSE_TEXTCTRL#if wxUSE_LISTBOX        wxListBox* listBox = wxDynamicCast(win, wxListBox);#endif // wxUSE_LISTBOX#if wxUSE_TEXTCTRL        if ( text#if wxUSE_LISTBOX         || listBox#endif          )        {            if ( !win->IsEnabled() ) // not IsEditable()                col = Get(CONTROL);            else            {                if ( !col.Ok() )                {                    // doesn't depend on the state                    col = Get(WINDOW);                }            }        }#endif // wxUSE_TEXTCTRL        if (!col.Ok())            col = Get(CONTROL); // Most controls should be this colour, not 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 & wxCONTROL_PRESSED) != 0 )        {#if wxUSE_SCROLLBAR            if ( wxDynamicCast(win, wxScrollBar) )                col = Get(flags & wxCONTROL_PRESSED ? SCROLLBAR_PRESSED                                                    : SCROLLBAR);            else#endif // wxUSE_SCROLLBAR                col = Get(CONTROL);        }    }    return col;}wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col) const{    switch ( col )    {        // use the system colours under Windows#if defined(__WXMSW__)        case WINDOW:            return wxColour(GetSysColor(COLOR_WINDOW));        case CONTROL_PRESSED:        case CONTROL_CURRENT:        case CONTROL:           return wxColour(GetSysColor(COLOR_BTNFACE));        case CONTROL_TEXT:      return wxColour(GetSysColor(COLOR_BTNTEXT));#if defined(COLOR_3DLIGHT)        case SCROLLBAR:         return wxColour(GetSysColor(COLOR_3DLIGHT));#else        case SCROLLBAR:         return wxColour(0xe0e0e0);#endif        case SCROLLBAR_PRESSED: return wxColour(GetSysColor(COLOR_BTNTEXT));        case HIGHLIGHT:         return wxColour(GetSysColor(COLOR_HIGHLIGHT));        case HIGHLIGHT_TEXT:    return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT));#if defined(COLOR_3DDKSHADOW)        case SHADOW_DARK:       return wxColour(GetSysColor(COLOR_3DDKSHADOW));#else        case SHADOW_DARK:       return wxColour(GetSysColor(COLOR_3DHADOW));#endif        case CONTROL_TEXT_DISABLED:        case SHADOW_HIGHLIGHT:  return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT));        case SHADOW_IN:         return wxColour(GetSysColor(COLOR_BTNFACE));        case CONTROL_TEXT_DISABLED_SHADOW:        case SHADOW_OUT:        return wxColour(GetSysColor(COLOR_BTNSHADOW));        case TITLEBAR:          return wxColour(GetSysColor(COLOR_INACTIVECAPTION));        case TITLEBAR_ACTIVE:   return wxColour(GetSysColor(COLOR_ACTIVECAPTION));        case TITLEBAR_TEXT:     return wxColour(GetSysColor(COLOR_INACTIVECAPTIONTEXT));        case TITLEBAR_ACTIVE_TEXT: return wxColour(GetSysColor(COLOR_CAPTIONTEXT));        case DESKTOP:           return wxColour(0x808000);#else // !__WXMSW__        // use the standard Windows colours elsewhere        case WINDOW:            return *wxWHITE;        case CONTROL_PRESSED:        case CONTROL_CURRENT:        case CONTROL:           return wxColour(0xc0c0c0);        case CONTROL_TEXT:      return *wxBLACK;        case SCROLLBAR:         return wxColour(0xe0e0e0);        case SCROLLBAR_PRESSED: return *wxBLACK;        case HIGHLIGHT:         return wxColour(0x800000);        case HIGHLIGHT_TEXT:    return wxColour(0xffffff);        case SHADOW_DARK:       return *wxBLACK;        case CONTROL_TEXT_DISABLED:return wxColour(0xe0e0e0);        case SHADOW_HIGHLIGHT:  return wxColour(0xffffff);        case SHADOW_IN:         return wxColour(0xc0c0c0);        case CONTROL_TEXT_DISABLED_SHADOW:        case SHADOW_OUT:        return wxColour(0x7f7f7f);        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 wxColour(0x808000);#endif // __WXMSW__        case GAUGE:             return Get(HIGHLIGHT);        case MAX:        default:            wxFAIL_MSG(_T("invalid standard colour"));            return *wxBLACK;    }}// ============================================================================// wxWin32Renderer// ============================================================================// ----------------------------------------------------------------------------// construction// ----------------------------------------------------------------------------wxWin32Renderer::wxWin32Renderer(const wxColourScheme *scheme)               : wxStdRenderer(scheme){    // init data    m_sizeScrollbarArrow = wxSize(16, 16);    // init the arrow bitmaps    static const size_t ARROW_WIDTH = 7;    static const size_t ARROW_LENGTH = 4;    wxMask *mask;    wxMemoryDC dcNormal,               dcDisabled,               dcInverse;

⌨️ 快捷键说明

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