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

📄 cpsk_skin.c

📁 VC++视频开发实例集锦(包括“远程视频监控”"语音识别系统"等13个经典例子)
💻 C
📖 第 1 页 / 共 2 页
字号:

////////////////////////////////////////////////////////////////////////////////



#include "stdafx.h"
#include "globals.h"
#include "resource.h"
#include "CompositeFile.h"


void CPSK_DestroySkin(CPs_Skin* pSkin);
CPs_Skin* CPSK_LoadSkin(CP_COMPOSITEFILE hComposite, const char* pcSkinFile, const unsigned int iFileSize);
CPs_Skin* glb_pSkin = NULL;
////////////////////////////////////////////////////////////////////////////////
//
//
//
void CPSK_Initialise()
{
    char* pcSkinFile;
    unsigned int iFileSize;

    CP_COMPOSITEFILE hComposite;

    hComposite = CF_Create_FromResource(NULL, IDR_DEFAULTSKIN, "SKIN");
    //hComposite = CF_Create_FromFile("P:\\Skin\\Default.CPSkin");

    CF_GetSubFile(hComposite, "Skin.def", &pcSkinFile, &iFileSize);
    glb_pSkin = CPSK_LoadSkin(hComposite, pcSkinFile, iFileSize);

    free(pcSkinFile);
    CF_Destroy(hComposite);
}
//
//
//
void CPSK_Uninitialise()
{
    if(glb_pSkin)
        CPSK_DestroySkin(glb_pSkin);
    glb_pSkin = NULL;
}
//
//
//
void CPSK_DestroySkin(CPs_Skin* pSkin)
{
    if(pSkin->mpl_hfFont)
        DeleteObject(pSkin->mpl_hfFont);
    CPIG_DestroyImage(pSkin->mpl_pBackground);
    CPIG_DestroyImage(pSkin->mpl_pListBackground);
    CPIG_DestroyImage(pSkin->mpl_pListHeader_Up);
    CPIG_DestroyImage(pSkin->mpl_pListHeader_Down);
    CPIG_DestroyImage(pSkin->mpl_pHScrollBar_Bk);
    CPIG_DestroyImage(pSkin->mpl_pHScrollBar_TrackUp);
    CPIG_DestroyImage(pSkin->mpl_pHScrollBar_TrackDn);
    CPIG_DestroyImage_WithState(pSkin->mpl_pHScrollBar_Left);
    CPIG_DestroyImage_WithState(pSkin->mpl_pHScrollBar_Right);
    CPIG_DestroyImage(pSkin->mpl_pVScrollBar_Bk);
    CPIG_DestroyImage(pSkin->mpl_pVScrollBar_TrackUp);
    CPIG_DestroyImage(pSkin->mpl_pVScrollBar_TrackDn);
    CPIG_DestroyImage_WithState(pSkin->mpl_pVScrollBar_Up);
    CPIG_DestroyImage_WithState(pSkin->mpl_pVScrollBar_Down);
    CPIG_DestroyImage(pSkin->mpl_pSelection);

    // Remove the command targets
    {
        CPs_CommandTarget* pCT_Cursor = pSkin->mpl_pCommandTargets;
        CPs_CommandTarget* pCT_Cursor_Next;
        while(pCT_Cursor)
        {
            CPIG_DestroyImage_WithState(pCT_Cursor->m_pStateImage);
            pCT_Cursor_Next = (CPs_CommandTarget*)pCT_Cursor->m_pNext;
            free(pCT_Cursor);
            pCT_Cursor = pCT_Cursor_Next;
        }
    }

    // Remove the indicators
    {
        CPs_Indicator* pCT_Cursor = pSkin->mpl_pIndicators;
        CPs_Indicator* pCT_Cursor_Next;
        while(pCT_Cursor)
        {
            pCT_Cursor_Next = (CPs_Indicator*)pCT_Cursor->m_pNext;
            free(pCT_Cursor->m_pcName);
            free(pCT_Cursor);
            pCT_Cursor = pCT_Cursor_Next;
        }
    }

    free(pSkin);
}
//
//
//
COLORREF CPSK_DecodeColour(const char* pcColour)
{
    DWORD dwColour;
    if(sscanf(pcColour, "#%x", &dwColour) == 1)
    {
        // Swap red and blue bytes
        return ((dwColour&0x0000FF)<<16) | (dwColour&0x00FF00) | ((dwColour&0xFF0000)>>16);
    }

    return 0;
}
//
//
//
void CPSK_ReadSkinCommand_Define(CP_COMPOSITEFILE hComposite, CPs_Skin* pSkin, const char* pcParams)
{
    char cSymbol[32];
    char cValue[128];

    // Decode params
    if(sscanf(pcParams, " %32[A-Za-z_] = \"%128[^\"]\"", cSymbol, cValue) != 2)
        return;

    if(stricmp(cSymbol, "CoolSkinVersion") == 0)
    {
        sscanf(cValue, " %d ", &pSkin->m_dwSkinVersion);
    }
    else if(stricmp(cSymbol, "Transparent_MaskColour") == 0)
    {
        pSkin->m_clrTransparent = CPSK_DecodeColour(cValue);
    }
    else if(stricmp(cSymbol, "Playlist_Font") == 0)
    {
        // Clean up old object if the skindef has more than one font
        if(pSkin->mpl_hfFont)
            DeleteObject(pSkin->mpl_hfFont);

        pSkin->mpl_hfFont = CreateFont(-12, 0, 0, 0, FW_NORMAL,
                                       FALSE, FALSE, FALSE,
                                       ANSI_CHARSET,
                                       OUT_TT_PRECIS,
                                       CLIP_DEFAULT_PRECIS,
                                       ANTIALIASED_QUALITY,
                                       DEFAULT_PITCH | FF_SWISS,
                                       cValue);
    }
    else if(stricmp(cSymbol, "Playlist_Colour_Text") == 0)
    {
        pSkin->mpl_ListTextColour = CPSK_DecodeColour(cValue);
    }
    else if(stricmp(cSymbol, "Playlist_Colour_Selected") == 0)
    {
        pSkin->mpl_ListTextColour_Selected = CPSK_DecodeColour(cValue);
    }
    else if(stricmp(cSymbol, "Playlist_Colour_Playing") == 0)
    {
        pSkin->mpl_ListTextColour_HotItem = CPSK_DecodeColour(cValue);
    }
    else if(stricmp(cSymbol, "Playlist_Colour_HeaderText") == 0)
    {
        pSkin->mpl_ListHeaderColour = CPSK_DecodeColour(cValue);
    }
    else if(stricmp(cSymbol, "Playlist_ListBorders") == 0)
    {
        if(sscanf(cValue, " %d , %d ,  %d , %d ",
                  &pSkin->mpl_rList_Border.left,
                  &pSkin->mpl_rList_Border.right,
                  &pSkin->mpl_rList_Border.top,
                  &pSkin->mpl_rList_Border.bottom) != 4)
        {
            SetRect(&pSkin->mpl_rList_Border, 0, 0, 0, 0);
        }
    }
    else if(stricmp(cSymbol, "Playlist_MinSize") == 0)
    {
        if(sscanf(cValue, " %d , %d ",
                  &pSkin->mpl_szMinWindow.cx,
                  &pSkin->mpl_szMinWindow.cy) != 2)
        {
            pSkin->mpl_szMinWindow.cx = 400;
            pSkin->mpl_szMinWindow.cy = 200;
        }
    }
}
//
//
//
void CPSK_ReadSkinCommand_TiledDraw(CP_COMPOSITEFILE hComposite, CPs_Skin* pSkin, const char* pcParams)
{
    char cElement[32];
    char cFile[128];
    RECT rTileBorders;
    CPs_Image** ppImage;
    RECT* pRect;

    // Decode params
    if(sscanf(pcParams, " %32[A-Za-z_-] , \"%128[^\"]\" , %d , %d , %d , %d ",
              cElement, cFile,
              &rTileBorders.left, &rTileBorders.top, &rTileBorders.right, &rTileBorders.bottom) != 6)
    {
        return;
    }

    // Decide which data members are affected
    if(stricmp(cElement, "Playlist_Background") == 0)
    {
        pRect = &pSkin->mpl_rBackground_SourceTile;
        ppImage = &pSkin->mpl_pBackground;
    }
    else if(stricmp(cElement, "Playlist_ListBackground") == 0)
    {
        pRect = &pSkin->mpl_rListBackground_SourceTile;
        ppImage = &pSkin->mpl_pListBackground;
    }
    else if(stricmp(cElement, "Playlist_Header_up") == 0)
    {
        pRect = &pSkin->mpl_rListHeader_SourceTile;
        ppImage = &pSkin->mpl_pListHeader_Up;
    }
    else if(stricmp(cElement, "Playlist_Header_dn") == 0)
    {
        pRect = &pSkin->mpl_rListHeader_SourceTile;
        ppImage = &pSkin->mpl_pListHeader_Down;
    }
    else if(stricmp(cElement, "Playlist_Selection") == 0)
    {
        pRect = &pSkin->mpl_rSelection_Tile;
        ppImage = &pSkin->mpl_pSelection;
    }
    else if(stricmp(cElement, "Playlist_Focus") == 0)
    {
        pRect = &pSkin->mpl_rFocus_Tile;
        ppImage = &pSkin->mpl_pFocus;
    }
    else if(stricmp(cElement, "HScrollBar_Background") == 0)
    {
        pRect = &pSkin->mpl_rHScrollBar_Bk_Tile;
        ppImage = &pSkin->mpl_pHScrollBar_Bk;
    }
    else if(stricmp(cElement, "HScrollBar_Tracker_up") == 0)
    {
        pRect = &pSkin->mpl_rHScrollBar_Track_Tile;
        ppImage = &pSkin->mpl_pHScrollBar_TrackUp;
    }
    else if(stricmp(cElement, "HScrollBar_Tracker_dn") == 0)
    {
        pRect = &pSkin->mpl_rHScrollBar_Track_Tile;
        ppImage = &pSkin->mpl_pHScrollBar_TrackDn;
    }
    else if(stricmp(cElement, "VScrollBar_Background") == 0)
    {
        pRect = &pSkin->mpl_rVScrollBar_Bk_Tile;
        ppImage = &pSkin->mpl_pVScrollBar_Bk;
    }
    else if(stricmp(cElement, "VScrollBar_Tracker_up") == 0)
    {
        pRect = &pSkin->mpl_rVScrollBar_Track_Tile;
        ppImage = &pSkin->mpl_pVScrollBar_TrackUp;
    }
    else if(stricmp(cElement, "VScrollBar_Tracker_dn") == 0)

⌨️ 快捷键说明

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