# widget_type.h

Go to the documentation of this file.

    00001 /* $Id: widget_type.h 15903 2009-03-30 23:15:05Z rubidium $ */
    00002
    00005 #ifndef WIDGET_TYPE_H
    00006 #define WIDGET_TYPE_H
    00007
    00008 #include "core/bitmath_func.hpp"
    00009 #include "strings_type.h"
    00010 #include "gfx_type.h"
    00011
    00012 /* How the resize system works:
    00013     First, you need to add a WWT_RESIZEBOX to the widgets, and you need
    00014      to add the flag WDF_RESIZABLE to the window. Now the window is ready
    00015      to resize itself.
    00016     As you may have noticed, all widgets have a RESIZE_XXX in their line.
    00017      This lines controls how the widgets behave on resize. RESIZE_NONE means
    00018      it doesn't do anything. Any other option let's one of the borders
    00019      move with the changed width/height. So if a widget has
    00020      RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
    00021      the right of the window will also be made 5 pixels wider.
    00022     Now, what if you want to clamp a widget to the bottom? Give it the flag
    00023      RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
    00024      5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
    00025      widgets moves downwards without resizing, and appears to be clamped
    00026      to the bottom. Nice aint it?
    00027    You should know one more thing about this system. Most windows can't
    00028     handle an increase of 1 pixel. So there is a step function, which
    00029     let the windowsize only be changed by X pixels. You configure this
    00030     after making the window, like this:
    00031       w->resize.step_height = 10;
    00032     Now the window will only change in height in steps of 10.
    00033    You can also give a minimum width and height. The default value is
    00034     the default height/width of the window itself. You can change this
    00035     AFTER window - creation, with:
    00036      w->resize.width or w->resize.height.
    00037    That was all.. good luck, and enjoy :) -- TrueLight */
    00038
    00039 enum DisplayFlags {
    00040   RESIZE_NONE   = 0,
    00041
    00042   RESIZE_LEFT   = 1,
    00043   RESIZE_RIGHT  = 2,
    00044   RESIZE_TOP    = 4,
    00045   RESIZE_BOTTOM = 8,
    00046
    00047   RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,
    00048   RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,
    00049   RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,
    00050   RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM,
    00051   RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,
    00052   RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM,
    00053
    00054   /* The following flags are used by the system to specify what is disabled, hidden, or clicked
    00055    * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
    00056    * These states are used in exceptions. If nothing is specified, they will indicate
    00057    * Enabled, visible or unclicked widgets*/
    00058   WIDG_DISABLED = 4,
    00059   WIDG_HIDDEN   = 5,
    00060   WIDG_LOWERED  = 6,
    00061 };
    00062 DECLARE_ENUM_AS_BIT_SET(DisplayFlags);
    00063
    00064 enum {
    00065   WIDGET_LIST_END = -1,
    00066 };
    00067
    00071 enum WidgetType {
    00072   WWT_EMPTY,
    00073
    00074   WWT_PANEL,
    00075   WWT_INSET,
    00076   WWT_IMGBTN,
    00077   WWT_IMGBTN_2,
    00078
    00079   WWT_TEXTBTN,
    00080   WWT_TEXTBTN_2,
    00081   WWT_LABEL,
    00082   WWT_TEXT,
    00083   WWT_MATRIX,
    00084   WWT_SCROLLBAR,
    00085   WWT_FRAME,
    00086   WWT_CAPTION,
    00087
    00088   WWT_HSCROLLBAR,
    00089   WWT_STICKYBOX,
    00090   WWT_SCROLL2BAR,
    00091   WWT_RESIZEBOX,
    00092   WWT_CLOSEBOX,
    00093   WWT_DROPDOWN,
    00094   WWT_DROPDOWNIN,
    00095   WWT_EDITBOX,
    00096   WWT_LAST,
    00097
    00098   WWT_MASK = 0x1F,
    00099
    00100   WWB_PUSHBUTTON  = 1 << 5,
    00101   WWB_MASK        = 0xE0,
    00102
    00103   WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
    00104   WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
    00105   WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
    00106 };
    00107
    00109 #define WIDGETS_END WWT_LAST, RESIZE_NONE, INVALID_COLOUR, 0, 0, 0, 0, 0, STR_NULL
    00110
    00114 struct Widget {
    00115   WidgetType type;
    00116   DisplayFlags display_flags;
    00117   Colours colour;
    00118   int16 left;
    00119   int16 right;
    00120   int16 top;
    00121   int16 bottom;
    00122   uint16 data;
    00123   StringID tooltips;
    00124 };
    00125
    00126 #endif /* WIDGET_TYPE_H */