summaryrefslogtreecommitdiff
path: root/Plugins/emoticons/sdk/m_anismiley.h
blob: 19cdb6268bc405ebb3a3c2af5525c700193b58d0 (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
123
#ifndef m_anismiley_h__
#define m_anismiley_h__


#define IASF_UNICODE 1
#ifdef UNICODE
#define IASF_TCHAR IASF_UNICODE
#else
#define IASF_TCHAR 0
#endif

typedef struct _tagINSERTANISMILEY
{
    size_t  cbSize;
    HWND    hWnd;
    union
    {
        const char *    szFilename;
        const wchar_t * wcFilename;
        const TCHAR *   tcsFilename;
    };
    COLORREF    dwBackColor;
    int         nHeight; // 0 to use default
    DWORD       dwFlags;
    union
    {
        const char *    szText;
        const wchar_t * wcText;
        const TCHAR *   tcsText;
    };
	int         nWidth; // 0 to use default
    union
    {
        const char *    szFlashVars;
        const wchar_t * wcFlashVars;
        const TCHAR *   tcsFlashVars;
    };
}INSERTANISMILEY;
#define MS_INSERTANISMILEY "mAnimator/InsertSmiley"

#if defined ServiceExists && defined CallService && !defined InsertAnimatedSmiley

static BOOL InsertAnimatedSmiley(HWND _hwnd, const TCHAR * _szFilename, COLORREF _dwBack, int _nWidth, int _nHeight, const TCHAR * _szText, const TCHAR * _szFlashVars)
{
    static int bServiceExists=-1;        
    INSERTANISMILEY ias={0};
    if (bServiceExists==-1)
        bServiceExists=ServiceExists(MS_INSERTANISMILEY);        
    if (!bServiceExists) return FALSE;
    ias.cbSize=sizeof(INSERTANISMILEY);
    ias.hWnd=_hwnd;
    ias.tcsFilename=_szFilename;
    ias.dwFlags=IASF_TCHAR;
    ias.nWidth=_nWidth;
    ias.nHeight=_nHeight;
    ias.dwBackColor=_dwBack;
    ias.tcsText=_szText;
	ias.tcsFlashVars=_szFlashVars;
    return (BOOL) CallService(MS_INSERTANISMILEY,(WPARAM)&ias, 0);
};

#endif // defined ServiceExists && defined CallService


#if !defined(NM_FIREVIEWCHANGE)

/**
	NM_FIREVIEWCHANGE is WM_NOTIFY Message for notify parent of host window about smiley are going to be repaint

	The proposed action is next: Owner of RichEdit windows received NM_FIREVIEWCHANGE through WM_NOTIFY
	twice first time before painting|invalidating (FVCN_PREFIRE) and second time - after (FVCN_POSTFIRE).
	The Owner window may change any values of received FVCNDATA_NMHDR structure in order to raise needed action.
	For example it may substitute FVCA_INVALIDATE to FVCA_CUSTOMDRAW event to force painting on self offscreen context.
	
	It can be:
	FVCA_CUSTOMDRAW - in this case you need to provide valid HDC to draw on and valid RECT of smiley
	FVCA_INVALIDATE - to invalidate specified rect of window 
	FVCA_NONE		- skip any action. But be aware - animation will be stopped till next repainting of smiley.
	FVCA_SENDVIEWCHANGE - to notify richedit ole about object changed. Be aware Richedit will fully reconstruct itself

	Another point is moment of received smiley rect - it is only valid if FVCA_DRAW is initially set, 
	and it is PROBABLY valid if FVCA_INVALIDATE is set. And it most probably invalid in case of FVCA_SENDVIEWCHANGE.
	The smiley position is relative last full paint HDC. Usually it is relative to top-left corner of host 
	richedit (NOT it client area) in windows coordinates. 

*/

// Type of Event one of
#define FVCN_PREFIRE        1
#define FVCN_POSTFIRE       2

// Action of event are going to be done
#define FVCA_NONE           0
#define FVCA_DRAW           1   // do not modify hdc in case of _DRAW, Use _CUSTOMDRAW
#define FVCA_CUSTOMDRAW     2
#define FVCA_INVALIDATE     3
#define FVCA_SENDVIEWCHANGE 4
#define FVCA_SKIPDRAW		5

// Extended NMHDR structure for WM_NOTIFY
typedef struct  
{   
    //NMHDR structure
    HWND hwndFrom;              // Window of smiley host
    UINT idFrom;                // ignored
    UINT code;                  // NM_FIREVIEWCHANGE
    
    size_t      cbSize;
    BYTE        bEvent;         // FVCN_ value - pre- or post- painting
    BYTE        bAction;        // FVCA_ keys
    HDC         hDC;            // Canvas to draw on
    RECT        rcRect;         // Valid/should be in case of FVCA_DRAW
    COLORREF    clrBackground;  // color to fill background if fTransparent is not set
    BOOL        fTransparent;   // if need to fill back color
    LPARAM      lParam;         // used by host window PreFire and PostFire event
} FVCNDATA_NMHDR;

// Code of WM_NOTIFY message (code)
#define NM_FIREVIEWCHANGE   NM_FIRST+1;

#endif

#endif // m_anismiley_h__