summaryrefslogtreecommitdiff
path: root/plugins/Modernb/_disabled_src/skinpp_object_glyph.cpp
blob: 7e4c8302629b4d4ddbc3bb7112301e8dda8f1b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**************************************************************************\

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

****************************************************************************

Created: Nov 27, 2006

Author:  Artem Shpynov aka FYR:  ashpynov@gmail.com

****************************************************************************

File contains implementation of skinpp_GLYPH class 

\**************************************************************************/
#include <windows.h>
#include <win2k.h>
#include "newpluginapi.h"	//this is common header for miranda plugin api
#include "m_system.h"
#include "m_database.h"

#include <string>
#include <map>
#include <list>

#include "XMLParser/XMLParser.h"

#include "skinpp.h"
#include "skinpp_private.h"
#include "skinpp_object_glyph.h"

skinpp_GLYPH::skinpp_GLYPH()
{
    m_bOpacity=0;
    m_nX = m_nY = m_nWidth =  m_nHeigh = 0;
    m_hBitmap = NULL;
    m_lpImageFileName = NULL;
    m_nLeft = m_nTop = m_nRight = m_nBottom = 0; 
    m_bFillMode = FM_STRETCH_BOTH;
};

skinpp_GLYPH::~skinpp_GLYPH()
{
    //if (m_hBitmap) skinpp_FreeBitmap(m_hBitmap);
    if (m_lpImageFileName) free(m_lpImageFileName);
}

int skinpp_GLYPH::GetObjectDataFromXMLNode(XMLNode * lpNode)
{ 
    // Early return if current object is empty (should not occur)
    if (!this) return E_FAIL; 
    
    // call parent class to get common object data
    if (FAILED(skinpp_SKINOBJECT::GetObjectDataFromXMLNode(lpNode))) return E_FAIL;
    
    // get opacity, default is '255'
    m_bOpacity=(BYTE)lpNode->GetAttributeInt("opacity",255);
   
    // get image section
    XMLNode * lpImageNode=lpNode->GetNode("image");
    if (lpImageNode)
    {
        // file - get image filename - if empty - use internal image 
        string file=lpImageNode->GetAttributeString("file");
        if (m_lpImageFileName) free(m_lpImageFileName);
        m_lpImageFileName=NULL;
        if (strlen(file.c_str())) strdup(file.c_str());
        // if old bitmap is exists - free it
        //if (m_hBitmap) skinpp_FreeBitmap(m_hBitmap);
        m_hBitmap=NULL;
  
        //x, y
        m_nX=lpImageNode->GetAttributeInt("x");
        m_nY=lpImageNode->GetAttributeInt("y");
        
        //width, height
        m_nWidth=lpImageNode->GetAttributeInt("width");
        m_nHeigh=lpImageNode->GetAttributeInt("height");
    }

    // get resize section
    XMLNode * lpResizeNode=lpNode->GetNode("resize");
    if (lpResizeNode)
    {
        // left, top, right, bottom
        m_nLeft=lpResizeNode->GetAttributeInt("left");
        m_nTop=lpResizeNode->GetAttributeInt("top");
        m_nRight=lpResizeNode->GetAttributeInt("right");
        m_nBottom=lpResizeNode->GetAttributeInt("bottom");

        // mode default is 'stretch'
        string mode=lpResizeNode->GetAttributeString("mode","stretch");        
        char * szMode=(char*)mode.c_str();
        if (strcmpi(szMode,"vtile"))        m_bFillMode=FM_TILE_VERTICAL;
        else if (strcmpi(szMode,"htile"))   m_bFillMode=FM_TILE_HORIZONTAL;
        else if (strcmpi(szMode,"tile"))    m_bFillMode=FM_TILE_BOTH;
        else                                m_bFillMode=FM_STRETCH_BOTH;
    }
    return S_OK;
}

int skinpp_GLYPH::PutObjectDataToXMLNode(XMLNode * lpNode)
{
    return 0;
}

int skinpp_GLYPH::Draw(HDC hDC, int nX, int nY, int nWidth, int nHeight, RECT * rcClipRect)
{
    return 0;
}