convert line ends
[canaan.git] / prj / cam / src / ui / buttpanl.h
blob201a749af2bbfa9a60df208bffea9499cc8ae250
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/ui/buttpanl.h,v 1.5 1998/10/30 02:03:02 mahk Exp $
7 #pragma once
8 #ifndef __BUTTPANL_H
9 #define __BUTTPANL_H
10 #include <comtools.h>
11 #include <loopapi.h>
12 #include <panlmode.h>
13 #include <gadblist.h>
14 #include <dynarray.h>
15 #include <cursors.h>
16 #include <imgsrc.h>
18 ////////////////////////////////////////////////////////////
19 // SIMPLE BUTTON PANEL MODE CLASS
21 // This simple class uses panelmode to implement
22 // a modal, full-screen button panel.
24 // It's not terribly abstract, but it gets the job done.
27 typedef cCTUnaggregated<ILoopClient, &IID_ILoopClient, kCTU_Default> cBaseLoopClient;
29 typedef cDynArray<Rect> cRectArray;
30 typedef cDynArray<DrawElement> cElemArray;
32 class cModalButtonPanel
34 protected:
36 //------------------------------------------------------------
37 // VIRTUAL FUNCTIONS FOR DESCRIBING YOUR BUTTON PANEL
40 // Init/Term UI (optional, but way recommended)
41 virtual void InitUI() { };
42 virtual void TermUI() { };
44 // These will only get called inside init/term ui, we promise
46 // How many buttons do I have?
47 virtual int NumButtons() = 0;
48 // my button rectangles
49 virtual cRectArray& Rects() = 0;
50 // my draw elements
51 virtual cElemArray& Elems() = 0;
53 // My cursor
54 virtual IImageSource* CursorImage() = 0;
55 // Its palette
56 virtual IDataSource* CursorPalette() { return NULL; };
58 // Handle UI events
59 virtual void OnButtonList(ushort action, int button) = 0;
61 // Handle loop events (optional)
62 // Can get called outside init/term ui
63 virtual void OnLoopMsg(eLoopMessage, tLoopMessageData ) {} ;
67 public:
69 //------------------------------------------------------------
70 // CLIENT API
74 // Constructor. The descriptors specify *default* values.
75 // The button panel will override them when necessary
77 cModalButtonPanel(sPanelModeDesc* pmdesc, sLoopClientDesc* lcdesc);
78 ~cModalButtonPanel();
81 // Spit out a panel mode, so that the client can call switch or whatever
84 IPanelMode* GetPanelMode() { mpPanelMode->AddRef(); return mpPanelMode; };
87 // Get the button list
90 LGadButtonList& GetButtons() { return mpClient->mButtonList; };
92 //------------------------------------------------------------
93 // THE GRITTY DETAILS
96 protected:
97 IPanelMode* mpPanelMode;
98 ulong mFactoryHandle;
101 // LOOP CLIENT, ACTUALLY OWNS THE BUTTON LIST
104 class cClient : public cBaseLoopClient
106 public:
107 cClient(const sLoopClientDesc* desc, cModalButtonPanel* panel);
108 ~cClient();
110 STDMETHOD_(short,GetVersion)() { return kVerLoopClient; };
111 STDMETHOD_(const sLoopClientDesc*, GetDescription)() { return mpDesc; };
112 STDMETHOD_(eLoopMessageResult, ReceiveMessage)(eLoopMessage, tLoopMessageData hData);
114 static bool BListCB(ushort action, int button, void* data, LGadBox* blist);
115 void SetupUI();
116 void CleanupUI();
117 static ILoopClient* LGAPI FactoryFunc(const sLoopClientDesc*, tLoopClientData);
119 const sLoopClientDesc* mpDesc;
120 cModalButtonPanel* mpPanel;
121 LGadButtonList mButtonList;
122 IImageSource* mpCursorImg;
123 Cursor mCursor;
124 int mPaletteIdx;
126 BOOL mActive;
129 friend class cClient;
131 cClient* mpClient;
136 #endif // __BUTTPANL_H