iimageviewer.h

Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------------
00002 // -----------------------------------------------------------------------------
00003 
00004    FILE: iImageViewer.h
00005 
00006      DESCRIPTION: abstract class for image viewers
00007 
00008      CREATED BY: michael malone (mjm)
00009 
00010      HISTORY: created April 13, 2000
00011 
00012      Copyright (c) 2000, All Rights Reserved
00013 
00014 // -----------------------------------------------------------------------------
00015 // -------------------------------------------------------------------------- */
00016 #pragma once
00017 
00018 #include "maxheap.h"
00019 #include "maxtypes.h"
00020 #include "bitmap.h"
00021 
00022 // forward declarations
00023 class DADMgr;
00024 class CropCallback;
00025 
00026 #ifdef IMAGE_VIEW_EXPORTS
00027 #define IMAGE_VIEW_API __declspec(dllexport)
00028 #else
00029 #define IMAGE_VIEW_API __declspec(dllimport)
00030 #endif
00031 
00032 // sent by a docked bitmap viewer window to its parent when the user right clicks on dead area of the toolbar
00033 // mouse points are relative to the client area of the schematic view window
00034 //
00035 // LOWORD(wParam) = mouse x
00036 // HIWORD(wParam) = mouse y
00037 // lparam         = bitmap viewer window handle
00038 #define WM_BV_TOOLBAR_RIGHTCLICK    WM_USER + 0x8ac4
00039 
00040 #define MAX_BITMAP_VIEWER_CLASS _M("MaxBitmapViewerClass") // windows class name
00041 
00042 
00043 // aszabo | Nov.16.2000
00044 // For the exported abstract classes in this header I am just adding
00045 // a GetInterface method to them instead of deriving them from InterfaceServer
00046 // in order to make it ready for extending it later with additional interfaces
00047 class BaseInterface;
00048 
00049 // -----------------------------------------------------------------------------
00055 class IMAGE_VIEW_API IImageViewer: public MaxHeapOperators
00056 {
00057 public:
00058     enum DisplayStyle { IV_FLOATING = 0, IV_DOCKED };
00059 
00060     enum WindowPosition
00061     {
00062         WPos_NULL = 0,
00063         WPos_UpperLeft,
00064         WPos_LowerLeft,
00065         WPos_UpperRight,
00066         WPos_LowerRight,
00067         WPos_Center,
00068 
00069         // the following are used for automatic save and restore
00070         WPos_Renderer = 10,
00071         WPos_VideoPostPrimary,
00072         WPos_VideoPostSecondary,
00073     };
00074     
00075     // -----------------------------------------------------------------------------
00076     //    Abstract class (Interface) for a callback that allows post-display access
00077     //    to an image viewer
00078     #pragma warning(push)
00079     #pragma warning(disable:4100)
00080     class PostDisplayCallback : public MaxHeapOperators
00081     {
00082     public:
00089         virtual void PostDisplayCB(HWND hWnd) = 0;
00090 
00091         // provides a way for extending it with interfaces
00100         virtual     BaseInterface* GetInterface (Interface_ID id) { return NULL; }
00101     };
00102 
00103 
00104     // -----------------------------------------------------------------------------
00105     //    Abstract class (Interface) for a callback that allows pre-event handler
00106     //    access to an image viewer
00107     class PreEventHandlerCallback : public MaxHeapOperators
00108     {
00109     public:
00123         virtual LRESULT EventHandlerCB(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool &propagate) = 0;
00124 
00125         // provides a way for extending it with interfaces
00132         virtual     BaseInterface* GetInterface (Interface_ID id) { return NULL; }
00133     };
00134     #pragma warning(pop)
00135     // shows/hides the viewer window
00140     virtual void Show() = 0;
00145     virtual void Hide() = 0;
00146 
00147     // gets the handle to display window
00150     virtual HWND GetHDisplayWindow() = 0;
00151 
00152     // sets the screen
00160     virtual void SetPos(int x, int y, int w, int h) = 0;
00161 
00162     // gets the display style
00165     virtual DisplayStyle GetDisplayStyle() const = 0;
00166 
00167     // sets/gets the context help id
00173     virtual void SetContextHelpId(DWORD helpID) = 0;
00175     virtual DWORD GetContextHelpId() const = 0;
00176 
00177     // sets/gets the DADMgr (allows override of DADMgr methods)
00183     virtual void SetDADMgr(DADMgr *pDADMgr) = 0;
00184     virtual DADMgr *GetDADMgr() const = 0;
00185 
00186     // sets/gets the pre-event handler callback
00192     virtual void SetPreEventHandlerCallback(PreEventHandlerCallback* pPreEventHandlerCB) = 0;
00195     virtual PreEventHandlerCallback* GetPreEventHandlerCallback() const = 0;
00196 
00197     // sets/gets the post-display callback
00203     virtual void SetPostDisplayCallback(PostDisplayCallback* pPostDisplayCB) = 0;
00206     virtual PostDisplayCallback* GetPostDisplayCallback() const = 0;
00207 
00208     // provides a way for extending it with interfaces
00216     virtual     BaseInterface* GetInterface (Interface_ID id) { UNUSED_PARAM(id); return NULL; }
00217 };
00218 
00219 
00220 // -----------------------------------------------------------------------------
00221 // -----------------------------------------------------------------------------
00222 
00231 class IMAGE_VIEW_API IMaxBitmapViewer : public IImageViewer
00232 
00233 //  PURPOSE:
00234 //    Abstract class (Interface) for an default max bitmap viewer
00235 //
00236 //  NOTES:
00237 //    created:  04.13.00 - mjm
00238 //
00239 // -----------------------------------------------------------------------------
00240 // -----------------------------------------------------------------------------
00241 
00242 {
00243 public:
00244     // sets/gets the bitmap
00251     virtual void SetBitmap(Bitmap* pBitmap) = 0;
00254     virtual Bitmap* GetBitmap() const = 0;
00255 
00256     // sets/gets the crop callback
00265     virtual void SetCropCB(CropCallback* pCropCallback) = 0;
00268     virtual CropCallback* GetCropCB() const = 0;
00269 
00270     // sets/gets the autonomous state
00280     virtual void SetAutonomous(bool isAutonomous) = 0;
00285     virtual bool GetAutonomous() const = 0;
00286 
00287     // sets/gets the current position
00291     virtual void SetCurrentPosition(WindowPosition currentPosition) = 0;
00294     virtual WindowPosition GetCurrentPosition() const = 0;
00295 
00296     // sets/gets whether to show the save button
00303     virtual void SetShowSaveButton(bool showSaveButton) = 0;
00306     virtual bool GetShowSaveButton() const = 0;
00307 
00308     // (un)displays the viewer
00328     virtual bool Display(MCHAR *title, WindowPosition position = WPos_Center) = 0;
00329     // parameters x, y, w, & h will be ignored unless 'Current Position' is WPos_NULL
00350     virtual bool Display(MCHAR *title, HWND hParent, int x, int y, int w, int h) = 0;
00354     virtual bool UnDisplay() = 0;
00359     virtual void ClearScreen() = 0;
00360 
00361     // transforms point/rect between window's client coords and bitmap's coords
00368     virtual POINT XFormScreenToBitmap(const POINT &pt) const = 0;
00375     virtual POINT XFormBitmapToScreen(const POINT &pt) const = 0;
00382     virtual Rect XFormScreenToBitmap(const Rect &rect) const = 0;
00389     virtual Rect XFormBitmapToScreen(const Rect &rect) const = 0;
00390 
00391     // shows/hides/toggles the toolbar
00397     virtual void ShowToolbar(bool show) = 0;
00400     virtual void ToggleToolbar() = 0;
00401 
00402     // gets the portion of the window's client area that is safe to draw in (in client coordinates)
00410     virtual void GetDrawableRect(Rect& drawableRect) = 0;
00411 
00412     // refreshes the region of the window, or the entire window if region is NULL
00418     virtual void RefreshWindow(Rect* pRefreshRegion = NULL) = 0;
00419 
00420     // provides a way for extending it with interfaces
00428     virtual     BaseInterface* GetInterface (Interface_ID id) { UNUSED_PARAM(id); return NULL; }
00429 };
00430 
00431 
00442 IMAGE_VIEW_API IMaxBitmapViewer* CreateIMaxBitmapViewer(Bitmap* pBitmap, IImageViewer::DisplayStyle displayStyle);
00449 IMAGE_VIEW_API void ReleaseIMaxBitmapViewer(IMaxBitmapViewer *);
00450