예제 #1
0
void CSimpleFrame::BuildSkinSubmenu( wxMenu *submenu) {
    unsigned int i;
    wxMenuItem *skinItem;
    wxArrayString astrSkins;
    wxString strSelectedSkin;
    CSkinManager* pSkinManager = wxGetApp().GetSkinManager();

    wxASSERT(pSkinManager);
    wxASSERT(wxDynamicCast(pSkinManager, CSkinManager));


    // The "Default" skin menu item is localized, but 
    // the name of the default skin is not localized
    skinItem = submenu->AppendRadioItem(
        ID_SGDEFAULTSKINSELECTOR,
        _("Default")
    );

    astrSkins = pSkinManager->GetCurrentSkins();
    strSelectedSkin = pSkinManager->GetSelectedSkin();
    
    if (strSelectedSkin == pSkinManager->GetDefaultSkinName()) {
        skinItem->Check(true);
    }
          
    // Skins list always contains the Default entry
    if (astrSkins.GetCount() <= 1) {
        skinItem->Check(true);
        skinItem->Enable(false);
        return; // No non-default skins
    }
 
//    I'd like to put a separator here, but we can't separate radio items
    
    for (i = 0; i < astrSkins.GetCount(); i++) {
        if (astrSkins[i] == pSkinManager->GetDefaultSkinName()) {
            continue;
        }

        skinItem = submenu->AppendRadioItem(
            ID_SGFIRSTSKINSELECTOR + i,
            astrSkins[i]
        );
        if (astrSkins[i] == strSelectedSkin) {
            skinItem->Check(true);
        }
    }
}
예제 #2
0
void CSimpleFrame::OnSelectDefaultSkin( wxCommandEvent& WXUNUSED(event) ) {
    CSkinManager* pSkinManager = wxGetApp().GetSkinManager();

    wxASSERT(pSkinManager);
    wxASSERT(wxDynamicCast(pSkinManager, CSkinManager));

    // The "Default" skin menu item is localized, but 
    // the name of the default skin is not localized
    pSkinManager->ReloadSkin(pSkinManager->GetDefaultSkinName());
}
예제 #3
0
void CSimpleFrame::OnSelectSkin( wxCommandEvent& event ){
    CSkinManager *pSkinManager = wxGetApp().GetSkinManager();
    wxMenuItem *oldItem, *selectedItem;
    wxMenuBar *pMenuBar = GetMenuBar();
    int newSkinId = event.GetId();
    int oldSkinID;
    
    wxASSERT(pSkinManager);
    wxASSERT(wxDynamicCast(pSkinManager, CSkinManager));
    
    
    selectedItem = pMenuBar->FindItem(newSkinId);
    if (!selectedItem) return;

    wxString oldSkinName = pSkinManager->GetSelectedSkin();
    wxString newSkinName = selectedItem->GetItemLabelText();
    if (newSkinName == oldSkinName) return;

    if (oldSkinName == pSkinManager->GetDefaultSkinName()) {
        // The "Default" skin menu item is localized, but 
        // the name of the default skin is not localized
        oldSkinID = ID_SGDEFAULTSKINSELECTOR;
    } else {
        oldSkinID = m_pSubmenuSkins->FindItem(oldSkinName);
    }
    oldItem = m_pSubmenuSkins->FindItem(oldSkinID);
    if (oldItem) {
        oldItem->Check(false);
    }

    selectedItem->Check(true);
    pSkinManager->ReloadSkin(newSkinName);
    
    wxGetApp().SaveState();
    wxConfigBase::Get(FALSE)->Flush();
}