home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / COMMAND / menuhandler.h < prev   
C/C++ Source or Header  |  1998-04-29  |  6KB  |  169 lines

  1. // menuhandler.h
  2.  
  3. // Copyright (C) 1997  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18.  
  19.  
  20. #ifndef MENUHANDLER_H
  21. #define MENUHANDLER_H
  22.  
  23. #include <selection.h>
  24. #include <pick.h>
  25. #include <pair.h>
  26. #include <vector.h>
  27. #include <drawablegeom.h>
  28.  
  29. #include <vdcmdwin.h>
  30.  
  31. #include <menuhandler_enum.h>
  32.  
  33. class ComException;
  34. class DrawableException;
  35. class ColorDialog;
  36. class LineStyleDialog;
  37. class Attributes;
  38.  
  39. class MenuHandler
  40. {
  41.  
  42. protected:
  43.  
  44.     vdCmdWindow* commandWindow;
  45.  
  46.     typedef pair<Pick,int> PickAndButton;
  47.     vector<PickAndButton> picks;
  48.     int parm;
  49.     vector<int> parmStack;
  50.     vector<int> commandStack;
  51.     vector<SelectionFilter> filterStack;
  52.     vector<double>dataStack;
  53.     vector<Handle>deleteStack;
  54.     int rounding;             // rounding constant - PLEASE SEE POINT.H !!!!!
  55.     Selection currentSelection;
  56.     InputString inputString;
  57.  
  58. public:
  59.     // The selection handler needs to know the geombank, canvas, and rounding constant.
  60.  
  61.     MenuHandler(vdCmdWindow* cmdwin,int r);
  62.  
  63.     virtual ~MenuHandler() {}
  64.  
  65.     virtual void DoPick(const Selection& s);    // provide to deal
  66.                             // with derived windows
  67.                             // selections
  68.     virtual void CommandActions(); // process pending modifiers and commands
  69.  
  70.     virtual void MenuCommand(int);                 // provide to handle 
  71.                             // input and processing
  72.                             // of commands
  73. //    void ExecModifier();
  74.  
  75.     void LoadPick(const Selection& sx);        // load a pick from a selection
  76.  
  77.     void LoadModifier(int code);    // not changable behavior
  78.  
  79.     void Initialize(); // set all stacks to zero. 
  80.  
  81.     void Rounding(int r) {rounding = r; }        // managment of the rounding constant
  82.     int Rounding() const { return rounding; }
  83.  
  84.     // simple is for midpoint, endpoint, and center... those with 1 pick.
  85.     // parameter should be FD_MIDPOINT, FD_CENTER, or FD_ENDPOINT.
  86.     void SimpleModifier(int);
  87.  
  88.     // intersection uses 2 functions to process 2 picks
  89.     void InitializeIntersectionModifier();
  90.     void IntersectionModifier1();
  91.     void IntersectionModifier2();
  92.     void KeyboardPointModifier();
  93.  
  94.     void Delete(/* const Selection& */ );
  95.  
  96. // bank functions
  97.     Handle BankCreate(Geom*) const;     // create a new entity in the bank
  98.     void BankDestroy(const Handle& ) const;   // destroy an existing entity from the bank
  99.     Handle BankGetHandleFromPointer(const Geom*) const throw (BankException);
  100.  
  101. // drawregister and vdcmdwindow manipulation functions
  102.     void Register(const Handle&, const Attributes&, const DrawableGeom* ,bool v = true)const;
  103.     void UnRegister(const Handle&) const;
  104.     Attributes GetAttributesFromHandle(const Handle&) const throw (CoreException);
  105.     void Redraw() const;
  106.     void SetHighlight(const Pick&,bool hl) const;
  107.     void SetAllHighlights(bool hl) const;
  108.     void SetVisible(const Pick&, bool v) const;
  109.     void SetAllVisible(bool v) const;
  110.     void SwapVisible() const;
  111.     
  112.  
  113.     void ClearTypeMask();
  114.     void ClearModifier();
  115.         void ClearFunctionMap();
  116.         void CancelCanvasAction();
  117.     void SetTypeMask(const SelectionFilter&);
  118.     SelectionFilter GetTypeMask() const;
  119.     void RestoreTypeMask();
  120.  
  121. // external informatives 
  122.     bool IsActive() const { return (commandStack.size()>0); }
  123.  
  124.     int Get1Pick(Pick&) throw (ComException); // returns the mouse button, loads the pick into the supplied reference
  125.     void PushPick(const Pick&,int); // push a pick and button back onto the stack
  126.  
  127.     void ToastDeleteStack();
  128.     void EmptyDeleteStack();
  129.  
  130.     void Say(const int&);
  131.     void Say(const char*);
  132.     void Query();
  133.  
  134. public: // calls for the dialogs
  135.     void LoadColor(int value);
  136.     void LoadLineStyle(unsigned short style);
  137.     void LoadThick(unsigned int   thick);
  138.     void LoadPointSize(unsigned int   size);
  139.     
  140.  
  141. protected: // calls for the children - access to data members of the command window
  142.     int CurrentColor() const ;
  143.     unsigned short CurrentLineStyle() const;
  144.     unsigned int CurrentThick() const;
  145.     unsigned int CurrentPointSize() const;
  146.     unsigned int CurrentLayer() const;
  147.     string CurrentFileName() const;
  148.     const DrawableGeom* Drawable(const int&) const throw(DrawableException);
  149.     void CanvasRegisterInit() const;
  150.     bool CanvasRegisterNextItem(RegisteredEntity&) const;
  151.  
  152. private:
  153. // initialize the color change function
  154.     void InitializeColor();
  155.     void InitializeLineStyle();
  156.     
  157. // process a Pick and change the color of the geometry
  158.     void ChangeAttribute();
  159.  
  160.     ColorDialog* colorDialog;
  161.     LineStyleDialog* lineStyleDialog;
  162.     
  163. protected:
  164.     Point KeyboardPoint() const throw(ComException); // get a keyboard entered point 
  165.     double KeyboardValue(const char* message) const throw(ComException); // get a keyboard entered real number
  166. };
  167.  
  168. #endif
  169.