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

Copyright © 1997-2009 Jeroen van der Zijp