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

uview.hpp

00001 /* ==================================================== ======== ======= * 00002 * 00003 * uview.hpp 00004 * Ubit Project [Elc][2003] 00005 * Author: Eric Lecolinet 00006 * 00007 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00008 * 00009 * (C) 1999-2003 Eric Lecolinet @ ENST Paris 00010 * WWW: http://www.enst.fr/~elc/ubit Email: elc@enst.fr (subject: ubit) 00011 * 00012 * *********************************************************************** 00013 * COPYRIGHT NOTICE : 00014 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00015 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00016 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00017 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00018 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00019 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00020 * *********************************************************************** 00021 * 00022 * ==================================================== [Elc:03] ======= * 00023 * ==================================================== ======== ======= */ 00024 00025 #ifndef _uview_hpp_ 00026 #define _uview_hpp_ 00027 //pragma ident "@(#)uview.hpp ubit:03.05.05" 00028 #include <ubit/uctrl.hpp> 00029 #include <ubit/uevent.hpp> 00030 00031 /* ==================================================== [Elc:03] ======= */ 00032 /* ==================================================== ======== ======= */ 00035 class UViewStyle : public UMode { 00036 public: 00037 UViewStyle(UView* (*)(class UBoxLink*, UView*, UWinGraph*), u_modes = 0); 00038 virtual ~UViewStyle() {destructs();} 00039 virtual void update(); 00040 00041 class UView* (*makeView)(class UBoxLink*, UView* parview, UWinGraph*); 00043 00044 virtual void addingTo(class ULink *selflink, UGroup *parent); 00045 virtual void removingFrom(class ULink *selflink, UGroup *parent); 00047 }; 00048 00049 /* ==================================================== [Elc:03] ======= */ 00050 /* ==================================================== ======== ======= */ 00058 class UView : public URegion { 00059 public: 00060 00061 UView(class UBoxLink*, UView* parview, UWinGraph*); 00062 virtual ~UView(); 00063 00064 static UView* makeView(class UBoxLink*, UView* parview, UWinGraph*); 00066 00067 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00068 00069 class UView* getParentView() const {return parview;} 00071 00072 class UDisp* getDisp() const; 00073 class UAppli* getAppli() const; 00075 00076 class UBox *getBox() const; 00078 00079 class UBox* getBoxParent() const; 00085 bool isRealized() const; 00090 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00091 // size 00092 00093 u_dim getWidth() const {return width;} 00094 u_dim getHeight() const {return height;} 00095 void getSize(u_dim& w, u_dim& h) const {w = width; h = height;} 00097 00098 void setWidth(u_dim width); 00099 void setHeight(u_dim height); 00100 void resize(u_dim width, u_dim height); 00106 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00107 // position 00108 00109 u_pos getX() const; 00110 u_pos getY() const; 00111 bool where(u_pos &x, u_pos &y) const; 00116 u_pos getXwin() const {return x;} 00117 u_pos getYwin() const {return y;} 00118 bool whereInWin(u_pos &x, u_pos &y) const; 00126 u_pos getXscreen() const; 00127 u_pos getYscreen() const; 00128 bool whereOnScreen(u_pos& x, u_pos& y) const; 00130 00131 u_pos getXappli() const; 00132 u_pos getYappli() const; 00133 bool whereOnAppli(u_pos& x, u_pos& y) const; 00135 00136 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00137 // conversions 00138 00139 static bool convertPos(UView* to_view, u_pos& to_x, u_pos& to_y, 00140 UView* from_view, u_pos from_x, u_pos from_y); 00142 00143 u_pos XToXwin(u_pos x_in_view) const {return x_in_view + x;} 00144 u_pos YToYwin(u_pos y_in_view) const {return y_in_view + y;} 00146 00147 u_pos XwinToX(u_pos x_in_win) const {return x_in_win - x;} 00148 u_pos YwinToY(u_pos y_in_win) const {return y_in_win - y;} 00150 00151 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00152 // implementation 00153 00154 static UViewStyle style; // renderer 00155 virtual UViewStyle* getViewStyle() {return &style;} 00157 00158 class UNatWin* getNatWin() const; 00159 class UWin* getHardwin() const; 00160 class UView* getHardwinView() const; 00162 00163 class UWinGraph* getWinGraph() const {return wingraph;} 00164 class UWinGraph& wg() const {return *wingraph;} 00171 #ifndef NO_DOC 00172 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00173 // implementation 00174 00175 friend class UViewLayoutImpl; 00176 friend class UViewUpdateImpl; 00177 friend class UBox; 00178 friend class UBoxLink; 00179 00180 enum VMODES { 00183 INITIALIZING = 1<<0, 00184 INITIALIZED = 1<<1, 00185 00187 DAMAGED = 1<<2, 00188 00190 FIXED_WIDTH = 1<<4, 00191 FIXED_HEIGHT = 1<<5, 00192 00194 REALIZED_CHILDREN = 1<<6, 00195 00198 OBS_COORDS = 1<<7 00199 00200 // !BEWARE: no comma after last item! 00201 }; 00202 00203 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00204 00205 bool isVmode(int _vmodes) const {return ((vmodes & _vmodes) != 0);} 00207 00208 bool allVmodes(int _vmodes) const {return ((vmodes & _vmodes) == _vmodes);} 00210 00211 int getVmodes() const {return vmodes;} 00213 00214 void setVmodes(int _vmodes, bool state); 00216 00217 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00218 00219 class UMargins* getBorderMargins() {return border_margins;} 00220 void setBorderMargins(class UMargins* f) {border_margins = f;} 00222 00223 class UView* getNext() {return nextview;} 00224 void setNext(UView* v) {nextview = v;} 00226 00227 class UViewExt* getExt() {return pext;} 00229 00230 class UBoxLink *getBoxLink() {return boxlink;} 00232 00233 void setXwin(u_pos x_in_win); 00234 void setYwin(u_pos y_in_win); 00235 void setParentView(UView* _parview) {parview = _parview;} 00236 00237 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00238 00239 // update view paint in VIEW coordinates: 00240 // - 'localRegion' is relative to View coordinates 00241 // a null value means: "repaint the whole view" 00242 // - 'doubleBuffering' : paints in double buffering 00243 00244 void updatePaint(URegion* localRegion = null, bool double_buffering = false); 00245 00246 // update view paint in WINDOW coordinates: 00247 // - 'windowRegion' is relative to Window coordinates 00248 // - 'doubleBuffering' : paints in double buffering 00249 // - 'updateAllLayers' : paints all layers located beneath the view 00250 // (this in necessary in case of transparent views) 00251 // - otherwise, if updateAllLayers is false : paints from 'firstPaintedLayer' 00252 // (if it is not null) then (always) paints 'this' view 00253 00254 void updateWinPaint(const URegion& window_region, UView* firstPaintedLayer, 00255 bool double_buffering, bool update_all_layers); 00256 00257 // update internal data but don't repaint (must be called after scrolling 00258 // and in various cases for initializing the views' content) 00259 00260 int updateWinData(const URegion& region); 00261 00262 //Note: contains() modifies the mofifies clip 00263 virtual UView* contains(u_pos xmouse, u_pos y_mouse, URegion& clip); 00264 virtual UView* contains(UView* searchv, URegion& clip); 00265 00266 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00267 00268 virtual bool doLayout(class UContext&, class UViewLayout&); 00269 virtual void doUpdate(class UContext&, URegion r, URegion clip, 00270 class UViewUpdate&); 00271 00272 // locateSource either searches: 00273 // - 'searchedView' 00274 // - the visible view where (e->xmouse, e->ymouse) is located 00275 // this function sets: e->{source, sourceView, sourceProps, redrawnClip} 00276 00277 virtual UView* locateSource(const UContext& parp, URegion clip, 00278 class UEvent&, const UView* searchedView, 00279 class USourceProps); 00280 00281 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00282 00283 virtual void doLayout2(class UViewLayoutImpl&, UGroup*, UContext&, 00284 class UViewLayout&); 00285 00286 virtual void doUpdate2(class UViewUpdateImpl&, UGroup*, UContext&, 00287 URegion& r, URegion& clip, class UViewUpdate&); 00288 00289 virtual UView* locateSource2(UGroup*, const class UContext& parp, URegion clip, 00290 class UEvent&, const UView* searchedView, 00291 class USourceProps&); 00292 00293 virtual bool locateElemV(UContext&, class ULink*, class UWinGraph&, 00294 const URegion&, class UViewUpdate&); 00295 virtual bool locateElemH(UContext&, class ULink*, class UWinGraph&, 00296 const URegion&, class UViewUpdate&); 00297 virtual bool locateElemRef(UContext&, class ULink*, class UWinGraph&, 00298 const URegion&, class UViewUpdate&); 00299 00300 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00301 00302 protected: 00303 class UView *parview; // parent view 00304 class UBoxLink *boxlink; // corresponding Box Link 00305 class UWinGraph *wingraph; // corresponding Window Graphics 00306 class UMargins *border_margins; // border margins of this view (if any) 00307 class UViewExt *pext; // view extensions (if any) 00308 class UView *nextview; // next view in the list 00309 int vmodes; // modes of this view 00310 public: 00311 int edit_shift; 00312 u_dim chwidth, chheight; // size occupied by children 00313 unsigned short hflex_count, vflex_count; // number of horiz and vert flexible children 00314 #endif 00315 }; 00316 00317 // ==================================================== [Elc:03] ======= // 00318 // ==================================================== ======== ======= // 00319 00320 class UFlowView: public UView { 00321 public: 00322 static UViewStyle style; // renderer 00323 virtual UViewStyle* getViewStyle() {return &style;} 00324 00325 // "static" constructor used by UViewStyle to make a new view 00326 static UView* makeView(UBoxLink*, UView* parview, UWinGraph*); 00327 UFlowView(UBoxLink*, UView* parview, UWinGraph*); 00328 00329 virtual ~UFlowView(); 00330 00331 #ifndef NO_DOC 00332 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00333 // implementation 00334 00335 class UFlowLine *lines; 00336 class UFlowCell *cells; 00337 int line_count, cell_count, lastline_strcell; 00338 int alloc_line_count, alloc_cell_count; 00339 00340 virtual void getHints(UContext &parctx, class UViewLayout &vl); 00341 virtual bool doLayout(UContext&, class UViewLayout &vl); 00342 virtual void doUpdate(UContext&, URegion r, URegion clip, class UViewUpdate&); 00343 //NB: NOT virtual: 00344 bool locateElemPos(UContext&, ULink*, class UFlowCell*, 00345 class UWinGraph&, const URegion&, 00346 class UViewUpdate &uc); 00347 bool locateElemPtr(UContext&, ULink*, class UFlowCell*, 00348 class UWinGraph&, const URegion&, 00349 class UViewUpdate &uc); 00350 #endif 00351 }; 00352 00353 #endif 00354 /* ==================================================== [TheEnd] ======= */ 00355 /* ==================================================== [Elc:03] ======= */ 00356

Generated on Tue Jul 27 18:01:55 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.7