IViewportButton.h

Go to the documentation of this file.
00001 /*==============================================================================
00002 // Copyright (c) 1998-2008 Autodesk, Inc.
00003 // All rights reserved.
00004 // 
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 // DESCRIPTION: Interface to the Simple Viewport Button System
00012 // AUTHOR: Michael Zyracki created May/June 2008
00013 //***************************************************************************/
00014 #pragma once
00015 
00016 #include "MaxHeap.h"
00017 #include "ifnpub.h"
00018 #include "strclass.h"
00019 #include "IPoint2.h"
00020 #include "color.h"
00021 #include "box2.h"
00022 // forward declarations
00023 class GraphicsWindow;
00024 class ViewExp;
00025 
00027 
00031 class IViewportButton :public MaxHeapOperators
00032 {
00033 
00034 public:
00035     //constructor/deconstructor
00036     IViewportButton(){};
00037     virtual ~IViewportButton(){};
00038 
00039     //properties
00043     virtual bool GetEnabled()const =0;
00044 
00048     virtual void SetEnabled(bool v) =0;
00049 
00053     virtual MSTR GetLabel()const =0;
00054 
00058     virtual void SetLabel(MSTR &label)=0;
00059 
00063     virtual IPoint2 GetLocation() const =0;
00064 
00068     virtual void SetLocation(IPoint2 &loc)=0;
00069 
00073     virtual void SetColor(Color &c) =0;
00074 
00078     virtual Color GetColor()const =0;
00079 
00083     virtual bool ShowInActiveViewportOnly()=0;
00084     //Callbacks
00085     enum Action{
00086         eLeftClick = 0x0,
00087         eRightClick,
00088         eMouseMove,
00089     };
00090 
00098     virtual bool OnAction(HWND hwnd,GraphicsWindow *gw,IPoint2 hitLoc,IViewportButton::Action action)=0;
00099 
00106     virtual bool OnUpdate(HWND hwnd, ViewExp * vpt)=0;
00107     
00114     virtual void Display(TimeValue t, ViewExp *vpt, int flags) = 0;     
00115 
00121     virtual void GetViewportRect( TimeValue t, ViewExp *vpt, Rect *rect )=0;
00122 
00123 
00124 };
00125 
00126 
00127 
00129 
00136 class ViewportTextButton: public IViewportButton
00137 {
00138 public:
00139     CoreExport ViewportTextButton();
00140     CoreExport ~ViewportTextButton();
00141     
00142     //properties
00143     CoreExport bool GetEnabled()const;
00144     CoreExport void SetEnabled(bool v);
00145     CoreExport MSTR GetLabel()const;
00146 
00150     CoreExport void SetLabel(MSTR &label);
00151     CoreExport IPoint2 GetLocation() const;
00152     CoreExport void SetLocation(IPoint2 &loc);
00153 
00157     CoreExport void SetColor(Color &c);
00158     CoreExport Color GetColor()const;
00159     CoreExport bool ShowInActiveViewportOnly();
00160     
00165     CoreExport bool OnAction(HWND hwnd,GraphicsWindow *gw,IPoint2 hitLoc,IViewportButton::Action action);
00166     CoreExport bool OnUpdate(HWND hwnd, ViewExp * vpt); 
00167     //Display
00168     CoreExport void Display(TimeValue t, ViewExp *vpt, int flags);      
00169     CoreExport void GetViewportRect( TimeValue t, ViewExp *vpt, Rect *rect );
00170 
00171 protected:
00172     bool mEnabled;
00173     MSTR mButtonText;
00174     MSTR mLabel;
00175     IPoint2 mLocation; 
00176     Color mColor;
00177     bool mMouseOver;
00178     bool mOldMouseOver;
00179 };
00180 
00181 
00183 #define IVIEWPORTBUTTONMANAGER_INTERFACE Interface_ID(0x47ab2195, 0x22e8126e)
00184 
00186 
00193 class IViewportButtonManager : public FPStaticInterface
00194 {
00195 public:
00196 
00198 
00201     virtual void RegisterButton(IViewportButton *button)=0;
00202 
00204 
00208     virtual void UnRegisterButton(IViewportButton *button)=0;
00209 
00211 
00215     virtual bool IsButtonRegistered(IViewportButton *button)const=0;
00216 
00218 
00221     virtual int GetNumRegisteredButtons()const=0;
00222 
00224 
00228     virtual IViewportButton * GetViewportButton(int index)=0;
00229     
00231 
00235     virtual void EnableButtons(bool val)=0;
00236 
00238 
00242     virtual bool GetButtonsEnabled()const =0;
00243 
00245 
00252     virtual bool OnAction(HWND hwnd,GraphicsWindow *gw,IPoint2 hitLoc,IViewportButton::Action action) =0;
00253 
00255 
00260     virtual bool OnUpdate(HWND hwnd, ViewExp * vpt)=0;
00261 
00263 
00272     virtual bool HitTest(HWND hwnd,GraphicsWindow *gw,IPoint2 stringStartLoc, IPoint2 hitLoc,MSTR &string) = 0;
00273 
00275 
00282     virtual bool HitTest(HWND hwnd,GraphicsWindow *gw, IPoint2 hitLoc) = 0;
00283 
00285 
00289     virtual void DrawButtons(ViewExp * vpt, Rect * rect = NULL) =0; 
00290 
00292     virtual void RefreshButtonDisplay() = 0;
00293 };
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 
00308