|
|
1.1 root 1: /******************************************************************************\
2: *
3: * SPINCUBE.H
4: *
5: \******************************************************************************/
6:
7: #include <custcntl.h>
8:
9:
10:
11: /******************************************************************************\
12: * SYMBOLIC CONSTANTS
13: \******************************************************************************/
14:
15: #define SPINCUBECLASS "Spincube"
16: #define SPINCUBEDESCRIPTION "An animated control"
17: #define SPINCUBEDEFAULTTEXT ":-)"
18:
19: #define CCHSTYLE 20 // size of style string, i.e. "SS_ERASE"
20:
21: #define NUM_SPINCUBE_STYLES 2
22:
23: #define SS_ERASE 0x0001 // spincube window styles
24: #define SS_INMOTION 0x0002
25:
26:
27: #define SPINCUBE_EXTRA 4 // number of extra bytes for spincube class
28:
29: #define SPIN_EVENT 1 // timer event id to repaint control
30: #define SPIN_INTERVAL 75 // milliseconds between repaints. what
31: // would be really cool is a way to
32: // dynamically adjust the interval-
33: // on real fast machines we might
34: // almost be able to get decent-looking
35: // animation! :)
36:
37: #define DID_ERASE 101 // dialog control id's
38: #define DID_INMOTION 102
39: #define DID_OK 103
40:
41: #define GWL_SPINCUBEDATA 0 // offset of control's instance data
42:
43: #define SPINCUBE_REPAINT_BKGND 0x00000001
44:
45: #define DO_ERASE(hwnd) GetWindowLong(hwnd,GWL_STYLE) & SS_ERASE \
46: ? TRUE : FALSE
47:
48: #define IN_MOTION(hwnd) GetWindowLong(hwnd,GWL_STYLE) & SS_INMOTION \
49: ? TRUE : FALSE
50:
51: #define REPAINT_BKGND(pSCI) pSCI->iOptions&SPINCUBE_REPAINT_BKGND \
52: ? TRUE : FALSE
53:
54:
55:
56: /******************************************************************************\
57: * TYPEDEFs
58: \******************************************************************************/
59:
60: typedef struct
61: {
62: HDC hdcCompat; // the DC that will contain our off-screen
63: // image
64: HBITMAP hbmCompat; // The bitmap that will contain the actual
65: // image, i.e. we will always do our
66: // drawing on this bmp & then blt the
67: // result to the screen.
68:
69: float fCurrentXRotation; // Angle (in radians) to rotate cube about
70: float fCurrentYRotation; // x, y, z axis
71: float fCurrentZRotation;
72:
73: float fCurrentXRotationInc; // Amount to inc rotation angle each
74: float fCurrentYRotationInc; // time we repaint (and are in motion)
75: float fCurrentZRotationInc;
76:
77: int iCurrentXTranslation; // Distance (in pels) to translate cube
78: int iCurrentYTranslation;
79: int iCurrentZTranslation;
80:
81: int iCurrentXTranslationInc; // Amount to inc translation distance each
82: int iCurrentYTranslationInc; // time we repaint (and are in motion)
83: int iCurrentZTranslationInc;
84:
85: RECT rcCubeBoundary; // Bounding rectangle (in 2D) of the last
86: // cube drawn. We invalidate only this
87: // region when we're doing animation
88: // and get the WM_TIMER- it's alot more
89: // efficient that invalidating the whole
90: // control (there's less screen flashing.
91:
92: int iOptions; // Contains the current options for this
93: // ctrl, i.e. erase background.
94:
95: } SPINCUBEINFO, *PSPINCUBEINFO;
96:
97:
98:
99: /******************************************************************************\
100: * FUNCTION PROTOTYPES
101: \******************************************************************************/
102:
103: INT CALLBACK SpincubeSizeToText (DWORD, DWORD, HFONT, LPSTR);
104: BOOL CALLBACK SpincubeStyle (HWND, LPCCSTYLE);
105: LRESULT CALLBACK SpincubeWndProc (HWND, UINT, WPARAM, LPARAM);
106: LRESULT CALLBACK SpincubeDlgProc (HWND, UINT, WPARAM, LPARAM);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.