00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _uview_hpp_
00026 #define _uview_hpp_
00027
00028 #include <ubit/uctrl.hpp>
00029 #include <ubit/uevent.hpp>
00030
00031
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
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
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
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
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
00153
00154 static UViewStyle style;
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
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
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
00240
00241
00242
00243
00244 void updatePaint(URegion* localRegion = null, bool double_buffering = false);
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 void updateWinPaint(const URegion& window_region, UView* firstPaintedLayer,
00255 bool double_buffering, bool update_all_layers);
00256
00257
00258
00259
00260 int updateWinData(const URegion& region);
00261
00262
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
00273
00274
00275
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;
00304 class UBoxLink *boxlink;
00305 class UWinGraph *wingraph;
00306 class UMargins *border_margins;
00307 class UViewExt *pext;
00308 class UView *nextview;
00309 int vmodes;
00310 public:
00311 int edit_shift;
00312 u_dim chwidth, chheight;
00313 unsigned short hflex_count, vflex_count;
00314 #endif
00315 };
00316
00317
00318
00319
00320 class UFlowView: public UView {
00321 public:
00322 static UViewStyle style;
00323 virtual UViewStyle* getViewStyle() {return &style;}
00324
00325
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
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
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
00355
00356