source: golgotha/src/max_plugin/sdk_inc/custcont.h @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
  • Property svn:keywords set to Id
File size: 15.3 KB
Line 
1/**********************************************************************
2 *<
3        FILE: custcont.h
4
5        DESCRIPTION: Custom Controls for Jaguar
6
7        CREATED BY: Rolf Berteig
8
9        HISTORY: created 17 November, 1994
10
11 *>     Copyright (c) 1994, All Rights Reserved.
12 **********************************************************************/
13
14#ifndef __CUSTCONT__
15#define __CUSTCONT__
16
17#include "winutil.h"
18
19void CoreExport InitCustomControls( HINSTANCE hInst );
20
21
22
23class ICustomControl {
24        public:
25                virtual HWND GetHwnd()=0;
26                virtual void Enable()=0;
27                virtual void Disable()=0;
28                virtual BOOL IsEnabled()=0;
29        };
30
31// This is a bitmap brush where the bitmap is a gray and white checker board.
32HBRUSH CoreExport GetLTGrayBrush();
33HBRUSH CoreExport GetDKGrayBrush();
34
35// The standard font...
36HFONT CoreExport GetFixedFont();
37
38// The hand cursor used for panning.
39HCURSOR CoreExport GetPanCursor();
40
41//---------------------------------------------------------------------------//
42// Spinner control
43
44
45#define SPINNERWINDOWCLASS      _T("SpinnerControl")
46
47
48// LOWORD(wParam) = ctrlID,
49// HIWORD(wParam) = TRUE if user is dragging the spinner interactively.
50// lParam = pointer to ISpinnerControl
51#define CC_SPINNER_CHANGE               WM_USER + 600   
52
53// LOWORD(wParam) = ctrlID,
54// lParam = pointer to ISpinnerControl
55#define CC_SPINNER_BUTTONDOWN   WM_USER + 601
56
57// LOWORD(wParam) = ctrlID,
58// HIWORD(wParam) = FALSE if user cancelled - TRUE otherwise
59// lParam = pointer to ISpinnerControl
60#define CC_SPINNER_BUTTONUP             WM_USER + 602
61
62
63enum EditSpinnerType {
64        EDITTYPE_INT,
65        EDITTYPE_FLOAT,
66        EDITTYPE_UNIVERSE,
67        EDITTYPE_POS_INT,
68        EDITTYPE_POS_FLOAT,
69        EDITTYPE_POS_UNIVERSE,
70        EDITTYPE_TIME
71        };
72
73class ISpinnerControl : public ICustomControl {
74        public:
75                virtual float GetFVal()=0;
76                virtual int GetIVal()=0;
77                virtual void SetAutoScale(BOOL on=TRUE)=0;
78                virtual void SetScale( float s )=0;
79                virtual void SetValue( float v, int notify )=0;
80                virtual void SetValue( int v, int notify )=0;
81                virtual void SetLimits( int min, int max, int limitCurValue = TRUE )=0;
82                virtual void SetLimits( float min, float max, int limitCurValue = TRUE )=0;
83                virtual void LinkToEdit( HWND hEdit, EditSpinnerType type )=0;
84                virtual void SetIndeterminate(BOOL i=TRUE)=0;
85                virtual BOOL IsIndeterminate()=0;
86                virtual void SetResetValue(float v)=0;
87                virtual void SetResetValue(int v)=0;
88        };
89
90ISpinnerControl CoreExport *GetISpinner( HWND hCtrl );
91void CoreExport ReleaseISpinner( ISpinnerControl *isc );
92
93CoreExport void SetSnapSpinner(BOOL b);
94CoreExport BOOL GetSnapSpinner();
95CoreExport void SetSnapSpinValue(float f);
96CoreExport float GetSnapSpinValue();
97
98CoreExport void SetSpinnerPrecision(int p);
99CoreExport int GetSpinnerPrecision();
100
101
102//---------------------------------------------------------------------------//
103// Rollup window control
104
105#define ROLLUPWINDOWCLASS _T("RollupWindow")
106
107typedef void *RollupState;
108
109// Flags passed to AppendRollup
110#define APPENDROLL_CLOSED       (1<<0)  // Starts the page out rolled up.
111
112class IRollupWindow : public ICustomControl {
113        public:
114                // Shows or hides all
115                virtual void Show()=0;
116                virtual void Hide()=0;
117
118                // Shows or hides by index
119                virtual void Show(int index)=0;
120                virtual void Hide(int index)=0;
121
122                virtual HWND GetPanelDlg(int index)=0;
123                virtual int GetPanelIndex(HWND hWnd)=0;
124                virtual void SetPanelTitle(int index,TCHAR *title)=0;
125
126                // returns index of new panel
127                virtual int AppendRollup( HINSTANCE hInst, TCHAR *dlgTemplate,
128                                DLGPROC dlgProc, TCHAR *title, LPARAM param=0,DWORD flags=0 )=0;
129                virtual int ReplaceRollup( int index, HINSTANCE hInst, TCHAR *dlgTemplate,
130                                DLGPROC dlgProc, TCHAR *title, LPARAM param=0,DWORD flags=0 )=0;
131                virtual void DeleteRollup( int index, int count )=0;
132                virtual void SetPageDlgHeight(int index,int height)=0;
133
134                virtual void SaveState( RollupState *hState )=0;
135                virtual void RestoreState( RollupState *hState )=0;
136
137                // Passing WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP to
138                // this function allows scrolling with unused areas in the dialog.
139                virtual void DlgMouseMessage( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )=0;
140
141                virtual int GetNumPanels()=0;
142                virtual BOOL IsPanelOpen(int index) = 0;
143                virtual void SetPanelOpen(int index, BOOL isOpen) =0;
144                virtual int GetScrollPos()=0;
145                virtual void SetScrollPos(int spos)=0;
146        };
147
148// This function returns TRUE if a particular rollup panel is open given
149// a handle to the dialog window in the panel.
150CoreExport BOOL IsRollupPanelOpen(HWND hDlg);
151
152IRollupWindow CoreExport *GetIRollup( HWND hCtrl );
153void CoreExport ReleaseIRollup( IRollupWindow *irw );
154
155//----------------------------------------------------------------------------//
156// CustEdit control
157
158#define CUSTEDITWINDOWCLASS _T("CustEdit")
159
160// Sent when the user hits the enter key in an edit control.
161// wParam = cust edit ID
162// lParam = HWND of cust edit control.
163#define WM_CUSTEDIT_ENTER       (WM_USER+685)
164
165class ICustEdit : public ICustomControl {
166        public:
167                virtual void GetText( TCHAR *text, int ct )=0;
168                virtual void SetText( TCHAR *text )=0; 
169                virtual void SetText( int i )=0;
170                virtual void SetText( float f, int precision=3 )=0;
171                virtual int GetInt(BOOL *valid=NULL)=0;
172                virtual float GetFloat(BOOL *valid=NULL)=0;
173                virtual void SetLeading(int lead)=0;
174        };
175
176ICustEdit CoreExport *GetICustEdit( HWND hCtrl );
177void CoreExport ReleaseICustEdit( ICustEdit *ice );
178
179
180//----------------------------------------------------------------------------//
181// CustButton control
182
183#define CUSTBUTTONWINDOWCLASS _T("CustButton")
184
185#define CC_COMMAND              WM_USER + 700
186// send these with CC_COMMAND: wParam = CC_???
187#define CC_CMD_SET_TYPE                 23              // lParam = CBT_PUSH, CBT_CHECK
188#define CC_CMD_SET_STATE                24              // lParam = 0/1 for popped/pushed
189#define CC_CMD_HILITE_COLOR             25              // lParam = RGB packed int
190
191#define RED_WASH        RGB(255,192,192)
192#define GREEN_WASH      RGB(192,255,192)
193#define BLUE_WASH       RGB(192,192,255)
194
195enum CustButType { CBT_PUSH, CBT_CHECK };
196
197// If the button is set to notify on button down, it will send a WM_COMMAND
198// with this notify code when the user touches the button.
199#define BN_BUTTONDOWN   8173
200// It will also send this message when the mouse is released regardless
201// if the mouse is released inside the toolbutton rectangle
202#define BN_BUTTONUP             8174
203
204// If a button is set to notify on right clicks,  it will send a WM_COMMAND
205// with this notify code when the user right clicks on the button.
206#define BN_RIGHTCLICK   8183
207
208// When the user chooses a new fly-off item, this notify code will be sent.
209#define BN_FLYOFF               8187
210
211// When the user presses a button a WM_MENUSELECT message is sent so that
212// the client can display a status prompt describing the function of
213// the tool. The fuFlags parameter is set to this value:
214#define CMF_TOOLBUTTON  9274
215
216class FlyOffData {
217        public:
218                int iOutEn;
219                int iInEn;
220                int iOutDis;
221                int iInDis;             
222        };
223
224// Directions the fly off will go.
225#define FLY_VARIABLE    1
226#define FLY_UP                  2
227#define FLY_DOWN                3
228#define FLY_HVARIABLE   4 // horizontal variable
229#define FLY_LEFT                5
230#define FLY_RIGHT               6
231
232class ICustButton : public ICustomControl {
233        public:
234                virtual void GetText( TCHAR *text, int ct )=0;
235                virtual void SetText( TCHAR *text )=0;                 
236                virtual void SetImage( HIMAGELIST hImage,
237                        int iOutEn, int iInEn, int iOutDis, int iInDis, int w, int h )=0;
238                virtual void SetType( CustButType type )=0;
239                virtual void SetFlyOff(int count,FlyOffData *data,int timeOut,int init,int dir=FLY_VARIABLE)=0;
240                virtual void SetCurFlyOff(int f,BOOL notify=FALSE)=0;
241                virtual int GetCurFlyOff()=0;
242                virtual BOOL IsChecked()=0;
243                virtual void SetCheck( BOOL checked )=0;
244                virtual void SetCheckHighlight( BOOL highlight )=0;
245                virtual void SetButtonDownNotify(BOOL notify)=0;
246                virtual void SetRightClickNotify(BOOL notify)=0;
247                virtual void SetHighlightColor(COLORREF clr)=0;
248                virtual void SetTooltip(BOOL onOff, LPSTR text)=0;
249        };
250
251ICustButton CoreExport *GetICustButton( HWND hCtrl );
252void CoreExport ReleaseICustButton( ICustButton *icb );
253
254
255//---------------------------------------------------------------------------//
256// CustStatus
257
258#define CUSTSTATUSWINDOWCLASS _T("CustStatus")
259
260enum StatusTextFormat {
261        STATUSTEXT_LEFT,
262        STATUSTEXT_CENTERED,
263        STATUSTEXT_RIGHT };
264
265
266class ICustStatus : public ICustomControl {
267        public:
268                virtual void SetText(TCHAR *text)=0;
269                virtual void SetTextFormat(StatusTextFormat f)=0;
270        };
271
272ICustStatus CoreExport *GetICustStatus( HWND hCtrl );
273void CoreExport ReleaseICustStatus( ICustStatus *ics );
274
275
276//----------------------------------------------------------------------------//
277// CustToolbar control
278
279#define CUSTTOOLBARWINDOWCLASS _T("CustToolbar")
280
281// Sent in a WM_COMMAND when the user right clicks in open space
282// on a toolbar.
283#define TB_RIGHTCLICK   0x2861
284
285enum ToolItemType {
286        CTB_PUSHBUTTON,
287        CTB_CHECKBUTTON,
288        CTB_SEPARATOR,
289        CTB_STATUS,
290        CTB_OTHER
291         };
292
293
294class ToolItem {
295        public:
296                ToolItemType type;
297                int id;
298                DWORD helpID;
299                int w, h;
300                virtual ~ToolItem() {}
301        };
302
303class ToolButtonItem : public ToolItem {
304        public:         
305                int iOutEn, iInEn;
306                int iOutDis, iInDis;
307                int iw;
308                int ih;         
309                ToolButtonItem(ToolItemType t,
310                        int iOE, int iIE, int iOD, int iID,
311                        int iW, int iH, int wd,int ht, int ID, DWORD hID=0)
312                        {
313                        type = t;
314                        iOutEn = iOE; iInEn = iIE; iOutDis = iOD; iInDis = iID;
315                        iw = iW; ih = iH; w = wd; h = ht; id = ID; helpID = hID;
316                        }               
317        };
318
319class ToolSeparatorItem : public ToolItem {
320        public:
321                ToolSeparatorItem(int w) {
322                        type = CTB_SEPARATOR;
323                        id = 0;
324                        helpID = 0;
325                        this->w = w;
326                        h = 0;
327                        }
328        };
329
330class ToolStatusItem : public ToolItem {
331        public:
332                BOOL fixed;
333                ToolStatusItem(int w, int h,BOOL f,int id, DWORD hID=0) {
334                        type = CTB_STATUS;
335                        this->w = w;
336                        this->h = h;
337                        this->id = id;
338                        this->helpID = hID;
339                        fixed = f;
340                        }
341        };
342
343#define CENTER_TOOL_VERTICALLY  0xffffffff
344
345class ToolOtherItem : public ToolItem {
346        public:
347                int       y;
348                DWORD style;
349                TCHAR *className;
350                TCHAR *windowText;
351                ToolOtherItem(TCHAR *cls,int w,int h,int id,DWORD style=WS_CHILD|WS_VISIBLE,
352                                        int y=CENTER_TOOL_VERTICALLY,TCHAR *wt=NULL,DWORD hID=0) {
353                        type = CTB_OTHER;
354                        this->y = y;
355                        this->w = w;
356                        this->h = h;
357                        this->id = id;
358                        this->helpID = hID;
359                        this->style = style;
360                        className = cls;
361                        windowText = wt;
362                        }               
363        };
364
365
366class ICustToolbar : public ICustomControl {
367        public:
368                virtual void SetImage( HIMAGELIST hImage )=0;
369                virtual void AddTool( const ToolItem& entry, int pos=-1 )=0;
370                virtual void DeleteTools( int start, int num=-1 )=0;  // num = -1 deletes 'start' through count-1 tools
371                virtual void SetBottomBorder(BOOL on)=0;
372                virtual void SetTopBorder(BOOL on)=0;
373                virtual ICustButton *GetICustButton( int id )=0;
374                virtual ICustStatus *GetICustStatus( int id )=0;               
375                virtual HWND GetItemHwnd(int id)=0;
376        };
377
378ICustToolbar CoreExport *GetICustToolbar( HWND hCtrl );
379void CoreExport ReleaseICustToolbar( ICustToolbar *ict );
380
381
382//---------------------------------------------------------------------------//
383// CustImage
384
385
386#define CUSTIMAGEWINDOWCLASS _T("CustImage")
387
388class ICustImage : public ICustomControl {
389        public:
390                virtual void SetImage( HIMAGELIST hImage,int index, int w, int h )=0;           
391        };
392
393ICustImage CoreExport *GetICustImage( HWND hCtrl );
394void CoreExport ReleaseICustImage( ICustImage *ici );
395
396
397//------------------------------------------------------------------------
398// Off Screen Buffer
399
400class IOffScreenBuf {
401        public:
402                virtual HDC GetDC()=0;
403                virtual void Erase(Rect *rct=NULL)=0;
404                virtual void Blit(Rect *rct=NULL)=0;
405                virtual void Resize()=0;
406                virtual void SetBkColor(COLORREF color)=0;
407                virtual COLORREF GetBkColor()=0;
408        };
409
410CoreExport IOffScreenBuf *CreateIOffScreenBuf(HWND hWnd);
411CoreExport void DestroyIOffScreenBuf(IOffScreenBuf *iBuf);
412
413
414//------------------------------------------------------------------------
415// Color swatch control
416// Puts up the ColorPicker when user right clicks on it.
417//
418
419// This message is sent as the color is being adjusted in the
420// ColorPicker.
421// LOWORD(wParam) = ctrlID,
422// HIWORD(wParam) = 1 if button UP
423//                = 0 if mouse drag.
424// lParam = pointer to ColorSwatchControl
425#define CC_COLOR_CHANGE                 WM_USER + 603
426
427// LOWORD(wParam) = ctrlID,
428// lParam = pointer to ColorSwatchControl
429#define CC_COLOR_BUTTONDOWN             WM_USER + 606
430
431// LOWORD(wParam) = ctrlID,
432// HIWORD(wParam) = FALSE if user cancelled - TRUE otherwise
433// lParam = pointer to ColorSwatchControl
434#define CC_COLOR_BUTTONUP               WM_USER + 607
435
436// This message is sent if the color has been clicked on, before
437// bringing up the color picker.
438// LOWORD(wParam) = ctrlID,
439// HIWORD(wParam) = 0
440// lParam = pointer to ColorSwatchControl
441#define CC_COLOR_SEL                    WM_USER + 604
442
443
444// This message is sent if another color swatch has been dragged and dropped
445// on this swatch.
446// LOWORD(wParam) = toCtrlID,
447// HIWORD(wParam) = 0
448// lParam = pointer to ColorSwatchControl
449#define CC_COLOR_DROP                   WM_USER + 605
450
451
452
453#define COLORSWATCHWINDOWCLASS _T("ColorSwatch")
454
455class IColorSwatch: public ICustomControl {
456        public:
457                // sets only the varying color of the color picker if showing
458                virtual COLORREF SetColor(COLORREF c, int notify=FALSE)=0;  // returns old color
459
460                // sets both the varying color and the "reset"color of the color picker
461                virtual COLORREF InitColor(COLORREF c, int notify=FALSE)=0;  // returns old color
462
463                virtual COLORREF GetColor()=0;
464                virtual void ForceDitherMode(BOOL onOff)=0;
465                virtual void SetModal()=0;
466                virtual void Activate(int onOff)=0;
467                virtual void EditThis(BOOL startNew=TRUE)=0;
468        };
469
470IColorSwatch CoreExport *GetIColorSwatch( HWND hCtrl, COLORREF col, TCHAR *name);
471void CoreExport ReleaseIColorSwatch( IColorSwatch *ics );
472
473//------------------------------------------------------------------------
474// Window thumb tack
475
476// This function installs a thumb tack in the title bar of a window
477// which allows the user to make it an always on top window.
478// NOTE: The window class for the window should have 4 extra bytes in
479// the window structure for SetWindowLong().
480CoreExport void InstallThumbTack(HWND hwnd);
481CoreExport void RemoveThumbTack(HWND hwnd);
482
483// Handy routines for setting up Spinners.
484CoreExport ISpinnerControl *SetupIntSpinner(HWND hwnd, int idSpin, int idEdit,  int min, int max, int val);
485CoreExport ISpinnerControl *SetupFloatSpinner(HWND hwnd, int idSpin, int idEdit,  float min, float max, float val, float scale = 0.1f);
486
487//---------------------------------------------------------------------------
488//
489
490CoreExport void DisableAccelerators();
491CoreExport void EnableAccelerators();
492CoreExport BOOL AcceleratorsEnabled();
493
494CoreExport void SetSaveRequired(int b=TRUE);
495CoreExport BOOL GetSaveRequired();
496
497
498#endif // __CUSTCONT__
499
Note: See TracBrowser for help on using the repository browser.