glow_growmenu.h 6.68 KB
Newer Older
claes's avatar
claes committed
1
/* 
claes's avatar
claes committed
2
 * Proview   $Id: glow_growmenu.h,v 1.4 2007-01-04 07:57:39 claes Exp $
claes's avatar
claes committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * Copyright (C) 2005 SSAB Oxelsund AB.
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation, either version 2 of 
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with the program, if not, write to the Free Software 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **/

claes's avatar
claes committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#ifndef glow_growmenu_h
#define glow_growmenu_h

#include "glow_growrect.h"

/*! \file glow_growmenu.h
    \brief Contains the GrowMenu class. */
/*! \addtogroup Glow */
/*@{*/


//! Class for drawing a menu object.
/*! A GrowMenu object is a pulldown menu.

  The GrowMenu class contains function for drawing the object, and handle events when the 
  object is clicked on, moved etc.
*/

class GrowMenu : public GrowRect {
 public:
  //! Constuctor
  /*!
    \param glow_ctx 	The glow context.
    \param name		Name (max 31 char).
claes's avatar
claes committed
44
    \param menu_info		Menu info.
claes's avatar
claes committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    \param x		x coordinate for position.
    \param y		y coordinate for position.
    \param min_w	Minimum width.
    \param border_d_type Border color.
    \param line_w	Linewidth of border.
    \param fill_rect	Rectangle is filled.
    \param display_border Border is visible.
    \param fill_d_type	Fill color.
    \param t_size	Text size.
    \param t_drawtype	Drawtype for text.
    \param t_color	Text color.
    \param t_color_disabled Text color for disabled item.
    \param parent	Parent menu.
    \param nodraw	Don't draw the object now.
  */
claes's avatar
claes committed
60
  GrowMenu( GrowCtx *glow_ctx, char *name, glow_sMenuInfo *menu_info, double x = 0, double y = 0, 
claes's avatar
claes committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	    double min_w = 0,
	    glow_eDrawType border_d_type = glow_eDrawType_Line, 
	    int line_w = 1, 
	    int fill_rect = 0, int display_border = 1, 
	    glow_eDrawType fill_d_type = glow_eDrawType_Line, int t_size = 2, 
	    glow_eDrawType t_drawtype = glow_eDrawType_TextHelvetica, 
	    glow_eDrawType t_color = glow_eDrawType_Line, 
	    glow_eDrawType t_color_disabled = glow_eDrawType_Line, 
	    GlowArrayElem *parent = 0, int nodraw = 0);

  //! Destructor
  /*! Remove the object from context, and erase it from the screen.
   */
  ~GrowMenu();

  void save( ofstream& fp, glow_eSaveMode mode) {}
  void open( ifstream& fp) {}

  //! Erase the object
claes's avatar
claes committed
80 81
  void erase( GlowWind *w)
	{ erase( w, (GlowTransform *)NULL, hot, NULL);};
claes's avatar
claes committed
82 83 84 85 86 87 88 89

  //! Draw the objects if any part is inside the drawing area.
  /*!
    \param ll_x		Lower left x coordinate of drawing area.
    \param ll_y		Lower left y coordinate of drawing area.
    \param ur_x		Upper right x coordinate of drawing area.
    \param ur_y		Upper right y coordinate of drawing area.
  */
claes's avatar
claes committed
90
  void draw( GlowWind *w, int ll_x, int ll_y, int ur_x, int ur_y);
claes's avatar
claes committed
91 92 93 94 95 96 97 98 99 100 101

  //! Draw the objects if any part is inside the drawing area, and extends the drawing area.
  /*!
    \param ll_x		Lower left x coordinate of drawing area.
    \param ll_y		Lower left y coordinate of drawing area.
    \param ur_x		Upper right x coordinate of drawing area.
    \param ur_y		Upper right y coordinate of drawing area.

    If some part of object is inside the drawing area, and also outside the drawing area,
    the drawingarea is extended so it contains the whole objects.
  */
claes's avatar
claes committed
102
  void draw( GlowWind *w, int *ll_x, int *ll_y, int *ur_x, int *ur_y);
claes's avatar
claes committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

  //! Drawing in the navigation window. See the corresponding draw function.
  void nav_draw(int ll_x, int ll_y, int ur_x, int ur_y) {}

  glow_eObjectType type() { return glow_eObjectType_GrowMenu;};

  glow_sMenuInfo	info;			//!< Button text and types.
  int			text_size;		//!< Button text size.
  glow_eDrawType	text_drawtype;		//!< Drawtype  for button text.
  glow_eDrawType	text_color;		//!< Color for button text.
  glow_eDrawType	text_color_disabled;	//!< Color for disabled button text.
  int			item_cnt;		//!< Number of menu items.
  double		item_height;		//!< Menu item height in pixel.
  int			current_item;		//!< Hot item.
  int			new_item;		//!< New current item.
  int			old_item;		//!< Current item in previous event.
  GlowArrayElem		*parent_menu;		//!< Parent menu.
  double		min_width;		//!< Minimum width of menu.
  int			input_focus;		//!< This menu has input focus.

  //! Draw the object.
  /*!
    \param t		Transform of parent node. Can be zero.
    \param highlight	Draw with highlight colors.
    \param hot		Draw as hot, with larger line width.
    \param node		Parent node. Can be zero.
    \param colornode	The node that controls the color of the object. Can be zero.

    The object is drawn with border, fill and shadow. If t is not zero, the current tranform is
    multiplied with the parentnodes transform, to give the appropriate coordinates for the drawing.
  */
claes's avatar
claes committed
134
  void draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void *node, void *colornode);
claes's avatar
claes committed
135 136 137 138 139 140 141

  //! Erase the object.
  /*!
    \param t		Transform of parent node.
    \param hot		Draw as hot, with larger line width.
    \param node		Parent node. Can be zero.
  */
claes's avatar
claes committed
142
  void erase( GlowWind *w, GlowTransform *t, int hot, void *node);
claes's avatar
claes committed
143 144 145 146 147 148 149

  //! Redraw the area inside the objects border.
  void draw();

  void export_javabean( GlowTransform *t, void *node,
			 glow_eExportPass pass, int *shape_cnt, int node_cnt, int in_nc,  ofstream &fp) {}

claes's avatar
claes committed
150 151 152
  int event_handler( GlowWind *w, glow_eEvent event, int x, int y, double fx, double fy);
  int event_handler( GlowWind *w, glow_eEvent event, double fx, double fy);
  int local_event_handler( GlowWind *w, glow_eEvent event, double x, double y);
claes's avatar
claes committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

  //! Check this menu object is a child to the specified menu object, and delete it if it is.
  /*! \param parent	The parent menu object. */
  void delete_menu_child( GlowArrayElem *parent);

  //! Get color, textsize and text colors for menu.
  /*!
    \param t_size	Text size.
    \param fill_color	Fill color.
    \param t_drawtype	Drawtype for text.
    \param t_color	Text color.
    \param t_color_disabled Text color for disabled button.
  */
  void get_menu_char( int *t_size, glow_eDrawType *fill_color, glow_eDrawType *t_drawtype,
		      glow_eDrawType *t_color, glow_eDrawType *t_color_disabled);

  void shift_current_item( int shift);
  int get_current_item( int *item);
  void set_input_focus( int focus) { input_focus = focus;}
  int get_input_focus() { return input_focus;}
  void get_submenu_position( int item, double *x, double *y);
  int get_parent( GlowArrayElem **parent);
};


/*@}*/
#endif