home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectInput / DIConfig / cdeviceview.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  3.8 KB  |  144 lines

  1. //-----------------------------------------------------------------------------
  2. // File: cdeviceview.h
  3. //
  4. // Desc: CDeviceView is a window class derived from CFlexWnd.  It represents
  5. //       the device view window in which the device and callouts are drawn.
  6. //       Each CDeviceView only represents one view.  A device that has more
  7. //       than one view should have a corresponding number of CDeviceView for it.
  8. //
  9. // Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  10. //-----------------------------------------------------------------------------
  11.  
  12. #ifdef FORWARD_DECLS
  13.  
  14.  
  15.     enum DVIMAGE;
  16.  
  17.     class CDeviceView;
  18.  
  19. #define DEFAULTVIEWSBWIDTH 11
  20.  
  21.  
  22. #else // FORWARD_DECLS
  23.  
  24. #ifndef __CDEVICEVIEW_H__
  25. #define __CDEVICEVIEW_H__
  26.  
  27.  
  28. enum DVIMAGE {
  29.     DVI_IMAGE,
  30.     DVI_THUMB,
  31.     DVI_SELTHUMB
  32. };
  33.  
  34.  
  35. class CDeviceView : public CFlexWnd
  36. {
  37. private:
  38. friend class CDeviceUI;    // CDeviceUI has exclusive right to create/destroy views
  39. friend class CDIDeviceActionConfigPage;
  40.     CDeviceView(CDeviceUI &ui);
  41.     ~CDeviceView();
  42.     CDeviceUI &m_ui;
  43.  
  44. public:
  45.     // control information
  46.     int GetNumControls();
  47.     CDeviceControl *GetControl(int nControl);
  48.     CDeviceControl *GetControlFromOfs(DWORD dwOfs)
  49.         { return GetControl(GetIndexFromOfs(dwOfs)); }
  50.  
  51.     // text information
  52.     int GetNumTexts();
  53.     CDeviceViewText *GetText(int nText);
  54.  
  55.     // text addition
  56.     CDeviceViewText *NewText();
  57.     CDeviceViewText *AddText(
  58.         HFONT, COLORREF, COLORREF, const RECT &, LPCTSTR text);
  59.     CDeviceViewText *AddText(
  60.         HFONT, COLORREF, COLORREF, const POINT &, LPCTSTR text);
  61.     CDeviceViewText *AddWrappedLineOfText(
  62.         HFONT, COLORREF, COLORREF, LPCTSTR text);
  63.  
  64.     void SetImage(CBitmap *&refpbm);
  65.     void SetImagePath(LPCTSTR tszPath);
  66.  
  67.     // imaging
  68.     CBitmap *GetImage(DVIMAGE dvi);
  69.     
  70.     // editing
  71.     void Remove(CDeviceControl *pControl);
  72.     void RemoveAll(BOOL bUser = TRUE);
  73.     BOOL DoesCalloutOtherThanSpecifiedExistForOffset(CDeviceControl *, DWORD);
  74.     BOOL DoesCalloutExistForOffset(DWORD);
  75.     BOOL IsUnassignedOffsetAvailable();
  76.  
  77.     int GetViewIndex();
  78.  
  79.     int GetIndexFromOfs(DWORD dwOfs);  // For writing to INI
  80.  
  81.  
  82.     void MakeMissingImages();
  83.  
  84.     CDeviceControl *NewControl();
  85.  
  86. protected:
  87.     virtual void OnPaint(HDC hDC);
  88.     virtual void OnMouseOver(POINT point, WPARAM fwKeys);
  89.     virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  90.     virtual void OnDoubleClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  91.     virtual void OnWheel(POINT point, WPARAM wParam);
  92.     virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  93.  
  94. private:
  95.     // helpers
  96.     void Unpopulate(BOOL bInternalOnly = FALSE);
  97.     
  98.     // images/visualization
  99.     CBitmap *m_pbmImage, *m_pbmThumb, *m_pbmSelThumb;
  100.     LPTSTR m_ptszImagePath;
  101.     CBitmap *GrabViewImage();
  102.  
  103.     LPCTSTR GetImagePath() { return m_ptszImagePath; }
  104.  
  105.     // controls
  106.     CArray<CDeviceControl *, CDeviceControl *&> m_arpControl;
  107.  
  108.     // text
  109.     CArray<CDeviceViewText *, CDeviceViewText *&> m_arpText;
  110.     POINT m_ptNextWLOText;
  111.  
  112.     // Special painting
  113.     virtual void DoOnPaint(HDC hDC);
  114.     BOOL m_bForcePaint;  // This indicates that we need painting even if GetUpdateRect returns FALSE.
  115.  
  116.     // Sort assigned for keyboard devices
  117.     void SwapControls(int i, int j);
  118.     void SortAssigned(BOOL bSort);
  119.     void SortCallouts(int iStart, int iEnd);
  120.  
  121.     // editting state machine
  122.     int m_SuperState, m_State, m_SubState;
  123.     int m_OldSuperState, m_OldState, m_OldSubState;
  124.     CDeviceControl *m_pControlContext;
  125.  
  126.     // scrolling (vertical only)
  127.     BOOL m_bScrollEnable;
  128.     int m_nScrollOffset;
  129.     int m_nViewHeight;
  130. public:
  131.     void EnableScrolling() {m_bScrollEnable = TRUE;}    
  132.     void ScrollToMakeControlVisible(const RECT &rc);
  133.     void CalcDimensions();
  134. private:
  135.     void DisableScrollBar();
  136.     void EnableScrollBar();
  137.     CFlexScrollBar m_sb;
  138. };
  139.  
  140.  
  141. #endif //__CDEVICEVIEW_H__
  142.  
  143. #endif // FORWARD_DECLS
  144.