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

FXPacker.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                P a c k e r   C o n t a i n e r   W i d g e t                  *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXPacker.h,v 1.21 2006/01/22 17:58:07 fox Exp $                          *
00023 ********************************************************************************/
00024 #ifndef FXPACKER_H
00025 #define FXPACKER_H
00026 
00027 #ifndef FXCOMPOSITE_H
00028 #include "FXComposite.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Default spacing
00035 enum { DEFAULT_SPACING = 4 };
00036 
00037 
00038 /**
00039 * Packer is a layout manager which automatically places child windows
00040 * inside its area against the left, right, top, or bottom side.
00041 * Each time a child is placed, the remaining space is decreased by the
00042 * amount of space taken by the child window.
00043 * The side against which a child is placed is determined by the LAYOUT_SIDE_TOP,
00044 * LAYOUT_SIDE_BOTTOM, LAYOUT_SIDE_LEFT, and LAYOUT_SIDE_RIGHT hints given by
00045 * the child window.  Other layout hints from the child are observed as far as
00046 * sensible.  So for example, a child placed against the right edge can still
00047 * have LAYOUT_FILL_Y or LAYOUT_TOP, and so on.
00048 * The last child may have both LAYOUT_FILL_X and LAYOUT_FILL_Y, in which
00049 * case it will be placed to take all remaining space.
00050 */
00051 class FXAPI FXPacker : public FXComposite {
00052   FXDECLARE(FXPacker)
00053 protected:
00054   FXColor baseColor;        // Base color
00055   FXColor hiliteColor;      // Highlight color
00056   FXColor shadowColor;      // Shadow color
00057   FXColor borderColor;      // Border color
00058   FXint   padtop;           // Top margin
00059   FXint   padbottom;        // Bottom margin
00060   FXint   padleft;          // Left margin
00061   FXint   padright;         // Right margin
00062   FXint   hspacing;         // Horizontal child spacing
00063   FXint   vspacing;         // Vertical child spacing
00064   FXint   border;           // Border width
00065 protected:
00066   FXPacker();
00067   void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00068   void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00069   void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00070   void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00071   void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00072   void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00073   void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00074   void drawFocusRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00075   void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00076 private:
00077   FXPacker(const FXPacker&);
00078   FXPacker &operator=(const FXPacker&);
00079 public:
00080   long onPaint(FXObject*,FXSelector,void*);
00081   long onFocusUp(FXObject*,FXSelector,void*);
00082   long onFocusDown(FXObject*,FXSelector,void*);
00083   long onFocusLeft(FXObject*,FXSelector,void*);
00084   long onFocusRight(FXObject*,FXSelector,void*);
00085 public:
00086 
00087   /// Construct packer layout manager
00088   FXPacker(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING);
00089 
00090   /// Return default width
00091   virtual FXint getDefaultWidth();
00092 
00093   /// Return default height
00094   virtual FXint getDefaultHeight();
00095 
00096   /// Perform layout
00097   virtual void layout();
00098 
00099   /// Change frame style
00100   void setFrameStyle(FXuint style);
00101 
00102   /// Get current frame style
00103   FXuint getFrameStyle() const;
00104 
00105   /// Change packing hints
00106   void setPackingHints(FXuint ph);
00107 
00108   /// Return packing hints
00109   FXuint getPackingHints() const;
00110 
00111   /// Get border width
00112   FXint getBorderWidth() const { return border; }
00113 
00114   /// Change top padding
00115   void setPadTop(FXint pt);
00116 
00117   /// Get top interior padding
00118   FXint getPadTop() const { return padtop; }
00119 
00120   /// Change bottom padding
00121   void setPadBottom(FXint pb);
00122 
00123   /// Get bottom interior padding
00124   FXint getPadBottom() const { return padbottom; }
00125 
00126   /// Change left padding
00127   void setPadLeft(FXint pl);
00128 
00129   /// Get left interior padding
00130   FXint getPadLeft() const { return padleft; }
00131 
00132   /// Change right padding
00133   void setPadRight(FXint pr);
00134 
00135   /// Get right interior padding
00136   FXint getPadRight() const { return padright; }
00137 
00138   /// Change highlight color
00139   void setHiliteColor(FXColor clr);
00140 
00141   /// Get highlight color
00142   FXColor getHiliteColor() const { return hiliteColor; }
00143 
00144   /// Change shadow color
00145   void setShadowColor(FXColor clr);
00146 
00147   /// Get shadow color
00148   FXColor getShadowColor() const { return shadowColor; }
00149 
00150   /// Change border color
00151   void setBorderColor(FXColor clr);
00152 
00153   /// Get border color
00154   FXColor getBorderColor() const { return borderColor; }
00155 
00156   /// Change base gui color
00157   void setBaseColor(FXColor clr);
00158 
00159   /// Get base gui color
00160   FXColor getBaseColor() const { return baseColor; }
00161 
00162   /// Change horizontal inter-child spacing
00163   void setHSpacing(FXint hs);
00164 
00165   /// Return current horizontal inter-child spacing
00166   FXint getHSpacing() const { return hspacing; }
00167 
00168   /// Change vertical inter-child spacing
00169   void setVSpacing(FXint vs);
00170 
00171   /// Return current vertical inter-child spacing
00172   FXint getVSpacing() const { return vspacing; }
00173 
00174   /// Save to stream
00175   virtual void save(FXStream& store) const;
00176 
00177   /// Load from stream
00178   virtual void load(FXStream& store);
00179   };
00180 
00181 }
00182 
00183 #endif

Copyright © 1997-2005 Jeroen van der Zijp