home *** CD-ROM | disk | FTP | other *** search
/ Instant Doom Levels / Instant.Doom.Levels.-.Level.Master.II.iso / EDITORS / ZIPPED / WSCDEU52.ZIP / INCLUDE / MAPDC.H < prev    next >
C/C++ Source or Header  |  1995-03-05  |  5KB  |  181 lines

  1. /*----------------------------------------------------------------------------*
  2.  | This file is part of WinDEU, the port of DEU to Windows.                   |
  3.  | WinDEU was created by the DEU team:                                        |
  4.  |  Renaud Paquay, Raphael Quinet, Brendon Wyber and others...                |
  5.  |                                                                            |
  6.  | DEU is an open project: if you think that you can contribute, please join  |
  7.  | the DEU team.  You will be credited for any code (or ideas) included in    |
  8.  | the next version of the program.                                           |
  9.  |                                                                            |
  10.  | If you want to make any modifications and re-distribute them on your own,  |
  11.  | you must follow the conditions of the WinDEU license. Read the file        |
  12.  | LICENSE or README.TXT in the top directory.  If do not  have a copy of     |
  13.  | these files, you can request them from any member of the DEU team, or by   |
  14.  | mail: Raphael Quinet, Rue des Martyrs 9, B-4550 Nandrin (Belgium).         |
  15.  |                                                                            |
  16.  | This program comes with absolutely no warranty.  Use it at your own risks! |
  17.  *----------------------------------------------------------------------------*
  18.  
  19.     Project WinDEU
  20.     DEU team
  21.     Jul-Dec 1994, Jan-Mar 1995
  22.  
  23.     FILE:         mapdc.h
  24.  
  25.     OVERVIEW
  26.     ========
  27.     Class definition for TMapDC (TDC).
  28. */
  29. #ifndef __mapdc_h
  30. #define __mapdc_h
  31.  
  32. #ifndef __common_h
  33.     #include "common.h"
  34. #endif
  35.  
  36. #ifndef __gfx_h
  37.     #include "gfx.h"        // Colors, ScrCenterX, OrigX, ...
  38. #endif
  39.  
  40. #ifndef __objects_h
  41.     #include "objects.h"    // SelPtr
  42. #endif
  43.  
  44. #ifndef __OWL_DC_H
  45.     #include <owl\dc.h>
  46. #endif
  47.  
  48. #ifndef __OWL_GDIOBJEC_H
  49.     #include <owl\gdiobjec.h>
  50. #endif
  51.  
  52. #ifndef __editcli_h
  53.     class TEditorClient;
  54. #endif
  55.  
  56. //
  57. // Class for pen (retains color, width and style in members)
  58. //
  59. class TPenColor16 : public TPen
  60. {
  61. public:    // data members
  62.     int color;
  63.     int width;
  64.     UINT style;
  65.     unsigned long HitCount;
  66.  
  67. public:    // function members
  68.      TPenColor16 (int _color, int _width = 1, UINT _style = PS_SOLID);
  69.     ~TPenColor16 ();
  70. } ;
  71.  
  72.  
  73. //
  74. // Size of cache for 16 color pens
  75. //
  76. #define COLOR16_CACHE_SIZE    12
  77.  
  78.  
  79. //
  80. // DC class for drawing on the level map in editor
  81. //
  82. class TMapDC : public TDC
  83. {
  84. //
  85. // Class members
  86. //
  87. private:
  88.     static TPenColor16 **LastPens;
  89.  
  90. public:
  91.     static void InitCacheData();
  92.     static void _USERENTRY CleanupCacheData();
  93.     static TPenColor16 *GetPenColor16 (int color, int width, UINT style);
  94.     static TColor GetColor16 (int color);
  95.  
  96. //
  97. // Object members
  98. //
  99. private:
  100.     BOOL DoDelete;            // use black pen for every drawing
  101.     int CurPenColor;
  102.     int CurPenWidth;
  103.     UINT CurPenStyle;
  104.     HPEN hOldPen;
  105.     BOOL FromWindow;        // DC created by GetDC(hWnd) ?
  106.     TEditorClient *pEditor;
  107.  
  108. protected:
  109.     void Init(TEditorClient *_pEditor);
  110.  
  111.     // Clipping and Origin selection
  112.     void SetupOrg ();
  113.     void SetupClipping ();
  114.     void ExcludeClipWindow (TWindow *pWnd);
  115.     void SetNewPenColor16 (int color, int width = 1, UINT style = PS_SOLID);
  116.     void DrawLineDefLen (SHORT, SHORT, SHORT, SHORT, int color);
  117.  
  118. public:
  119.     TMapDC (TEditorClient *_pEditor, TDC &dc);    // from other DC
  120.     TMapDC (TEditorClient *_pEditor);            // client DC from window
  121.     ~TMapDC ();
  122.  
  123.     // Primitive of color selection
  124.     void SetPenColor16 (int color, int width = 1, UINT style = PS_SOLID)
  125.     {
  126.         // Doesn't allow color selection if Delete mode
  127.         if (DoDelete)    return;
  128.  
  129.         // Choose new pen only if different than current pen
  130.         if ( CurPenColor != color ||
  131.              CurPenWidth != width ||
  132.              CurPenStyle != style )
  133.         {
  134.             SetNewPenColor16 (color, width, style);
  135.         }
  136.     }
  137.     void SetTextColor16 (int color);
  138.     void SetBkColor16 (int color);
  139.     void SetDelete(BOOL doDelete)
  140.     {
  141.         if ( doDelete )    SetPenColor16 (BLACK, CurPenWidth, CurPenStyle);
  142.         DoDelete = doDelete ;
  143.     }
  144.  
  145.     // Primitive to draw on map
  146.     void DrawMapLine (SHORT, SHORT, SHORT, SHORT);
  147.     void DrawMapRect (SHORT, SHORT, SHORT, SHORT);
  148.     void DrawMapCircle (SHORT, SHORT, SHORT);
  149.     void DrawMapVector (SHORT, SHORT, SHORT, SHORT);
  150.     void DrawMapArrow (SHORT, SHORT, USHORT, USHORT);
  151.  
  152.     // Draw an object, use editmode to select color and shape
  153.     void DrawMapThing   (int editmode, SHORT tnum);
  154.     void DrawMapLineDef (int editmode, SHORT ldnum, BOOL DrawLen = FALSE);
  155.     void DrawMapVertex  (int editmode, SHORT vnum);
  156.     void DrawMapSector  (int editmode, SHORT snum);
  157.  
  158.     int GetLineDefColor (int editmode, SHORT ldnum);
  159.     void DrawMapLineDefLen (int editmode, SHORT ldnum);
  160.  
  161.     // Draw a list of objects of a type
  162.     void DrawMapThingsList   (int editmode, SelPtr list);
  163.     void DrawMapLineDefsList (int editmode, SelPtr list, BOOL DrawLen = FALSE);
  164.     void DrawMapVertexesList (int editmode, SelPtr list);
  165.     void DrawMapSectorsList  (int editmode, SelPtr list);
  166.  
  167.     // Draw all objects of a type
  168.     void DrawMapThings   (int editmode);
  169.     void DrawMapLineDefs (int editmode, BOOL DrawLen = FALSE);
  170.     void DrawMapVertexes (int editmode);
  171.     void DrawMapSectors  (int editmode);
  172.  
  173.     // Draw the grid on the map
  174.     void DrawMapGrid (SHORT grid);
  175.  
  176.     // Draw all map
  177.     void DrawMap (int editmode, SHORT grid, BOOL drawgrid);
  178. } ;
  179.  
  180.  
  181. #endif        // __mapdc_h