Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Flags.h

00001 /*
00002  * $Id: Fl_Flags.h,v 1.8 2003/07/03 20:36:35 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 #ifndef _FL_FLAGS_H_
00023 #define _FL_FLAGS_H_
00024 
00025 #include "Fl_Export.h"
00026 
00027 // This same value is used to:
00028 
00029 // 1. store state and other information in a widget or menu item
00030 // 2. provide hints to boxes, labeltypes, and images for how to draw
00031 // 3. provide structural information to an array of menu items
00032 
00033 // These are shared because various parts of the code, especially
00034 // drawing, want all of this information at once, and providing it
00035 // as a single word is the easiest way.
00036 
00038 enum Fl_AlignEnum {
00039     FL_ALIGN_CENTER       = 0,
00040     FL_ALIGN_TOP          = 0x00000001,
00041     FL_ALIGN_BOTTOM       = 0x00000002,
00042     FL_ALIGN_LEFT         = 0x00000004,
00043     FL_ALIGN_RIGHT        = 0x00000008,
00044     FL_ALIGN_INSIDE       = 0x00000010,
00045     FL_ALIGN_CLIENT       = 0x00000010,
00046     FL_ALIGN_CLIP         = 0x00000040,
00047     FL_ALIGN_WRAP         = 0x00000080,
00048     FL_ALIGN_TILED        = 0x00000100,
00049     FL_ALIGN_SCALE        = 0x00000200,
00050     FL_ALIGN_MASK         = 0x00000FFF,
00051 
00052     // Short-cuts:
00053     FL_ALIGN_TOP_LEFT     = FL_ALIGN_TOP | FL_ALIGN_LEFT,
00054     FL_ALIGN_TOP_RIGHT    = FL_ALIGN_TOP | FL_ALIGN_RIGHT,
00055     FL_ALIGN_BOTTOM_LEFT  = FL_ALIGN_BOTTOM | FL_ALIGN_LEFT,
00056     FL_ALIGN_BOTTOM_RIGHT = FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT,
00057     FL_ALIGN_LEFT_TOP     = FL_ALIGN_TOP_LEFT,
00058     FL_ALIGN_RIGHT_TOP    = FL_ALIGN_TOP_RIGHT,
00059     FL_ALIGN_LEFT_BOTTOM  = FL_ALIGN_BOTTOM_LEFT,
00060     FL_ALIGN_RIGHT_BOTTOM = FL_ALIGN_BOTTOM_RIGHT,
00061 };
00062 
00064 enum Fl_FlagsEnum {
00065     FL_INACTIVE           = 0x00001000, // does not get events, gray it out
00066     FL_OUTPUT             = 0x00002000, // does not get events
00067     FL_VALUE              = 0x00004000, // indicates true/down/on state
00068     FL_SELECTED           = 0x00008000, // draw using selection colors
00069     FL_INVISIBLE          = 0x00010000, // does not get events, does not draw
00070     FL_HIGHLIGHT          = 0x00020000, // draw highlighted
00071     FL_CHANGED            = 0x00040000, // value changed since last callback
00072     FL_FOCUS_ON_CLICK     = 0x00080000, // Set true if clicking this widget causes it to take focus
00073     FL_FOCUS_ON_KEYBOARD  = 0x00100000, // Set true if clicking this widget causes it to take focus
00074 
00075     FL_RAW_LABEL          = 0x00200000, // don't interpret & or @ in label
00076     FL_PACK_VERTICAL      = 0x00400000  // Fl_Pack puts this widget vertical
00077 };
00078 
00080 typedef Fl_AlignEnum Fl_Align;
00081 
00083 class FL_API Fl_Flags
00084 {
00085     int m_flags;
00086 public:
00087     Fl_Flags(const Fl_Flags &f) { m_flags = f.m_flags; }
00088     Fl_Flags(Fl_Align align) : m_flags(align) { }
00089     Fl_Flags(long flags) : m_flags(flags) { }
00090     Fl_Flags(unsigned flags) : m_flags(flags) { }
00091     Fl_Flags(int flags) : m_flags(flags) { }
00092     Fl_Flags(void* flags) : m_flags((int)flags) { }
00093     Fl_Flags() : m_flags(0) { }
00094 
00095     bool is_set(int flags) const { return (m_flags&flags)!=0; }
00096 
00097     Fl_Flags &flags(Fl_Flags f)  { m_flags = f.m_flags; return *this; }
00098     Fl_Flags &set(int flags)    { m_flags |= flags;  return *this; }
00099     Fl_Flags &clear(int flags)  { m_flags &= ~flags; return *this; }
00100     Fl_Flags &invert(int flags) { m_flags ^= flags;  return *this; }
00101 
00102     Fl_Flags& operator = (Fl_Flags f) { m_flags = f.m_flags; return *this; }
00103     Fl_Flags& operator = (int f) { m_flags = f; return *this; }
00104 
00105     Fl_Align align() const { return Fl_Align(m_flags&FL_ALIGN_MASK); }
00106     void align(int a) { m_flags = (m_flags & (~FL_ALIGN_MASK)) | a; }
00107 
00108     int flags() { return m_flags; }
00109     int flags() const { return m_flags; }
00110 
00111     operator int& () { return m_flags; }
00112 };
00113 
00114 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15