OOFILE  1.9
oofrepeditx.h
Go to the documentation of this file.
1 // COPYRIGHT 1999 A.D. Software, All rights reserved
2 // oofrepeditx.h
3 // report-writer layer of OOFILE database - private editing classes
4 
5 
6 
7 #ifndef H_OOFREPEDITX
8 #define H_OOFREPEDITX
9 
10 #ifndef H_OOFREPEDIT
11  #include "oofrepedit.h"
12 #endif
13 
14 #ifdef _Macintosh
15  #ifndef REPMACGUIPREVPP
16  #include "oofRepPreviewPP.h"
17  #endif
18 #elif defined(_Windows)
19  #ifndef H_OOFPRNWN
20  #include "oofPrnWn.h" // yeah I know these headers are badly named, low prio!
21  #endif
22 #endif
23 
24 class LPane;
25 
34 public:
35  virtual oofRepRender* clone(const oofRepDrawable* newOwner) const=0;
36  oofRepRedirectingRender(oofRepRender* adoptedRender=0);
37  virtual ~oofRepRedirectingRender();
38 
39  virtual void draw()=0;
40  oofRepEditor* editor() const;
41  oofRepEditingEnv* editingEnv() const;
42  bool editRedirectionActive() const;
43 
44 protected:
46 };
47 
48 
56 public:
57  virtual oofRepRender* clone(const oofRepDrawable* newOwner) const;
60 
61  virtual void draw();
62 
63  void addAreaForCurrentBlock() const;
64 
65  static oofRepLayoutRedirectingRender* currentLayoutRedirectingRender();
66 
67 private:
68  oofRepLayoutBand_Render* LayoutRender() const;
69  void SetupEditLink();
70 
71  // data storage
72  oofRepLayoutEditLink* mEditLink; // dec refs - partially owned
73  static oofRepLayoutRedirectingRender* sCurrentLayoutRedirectingRender;
74 };
75 
76 
82 public:
83  virtual oofRepRender* clone(const oofRepDrawable* newOwner) const;
85  virtual void draw();
86 };
87 
88 
94 public:
95  virtual oofRepRender* clone(const oofRepDrawable* newOwner) const;
97  virtual void draw();
98 };
99 
100 
101 
109 public:
110  virtual oofRepRender* clone(const oofRepDrawable* newOwner) const;
112  virtual ~oofRepViewRedirectingRender();
113 
114 
115  virtual OOF_mixViewExtraRender* finishClone(oofRepRender* newClone) const;
116 
117 // overrides
118  virtual void drawColumnHeaders();
119  virtual void startTableBody(bool headersHaveChanged);
120  virtual void endTableBody();
121  virtual void draw();
122 
123 protected:
124  void AddRowInteractionAreas();
125  oofRepViewBand* ViewBand() const;
127 };
128 
129 
135 public:
136  short mCellIndex;
138 };
139 
140 
146 public:
148  virtual ~OOF_RepBlockCellRow();
149 
150  OOF_RepBlockCellMap& map(unsigned long) const;
151  void addBlockCells(oofRepBlock*);
152  bool findBlock(oofRepBlock* inBlock, short& outCol) const;
153 
154 protected:
155  virtual void* AllocBits(unsigned long) const;
156  virtual void DeleteBits(bool becauseExpanding);
157  void AddMap(short inIndex, oofRepBlock*);
158 
160 };
161 
162 
168 public:
170  virtual ~OOF_RepBlockCellRows();
171 
172  OOF_RepBlockCellRow& row(unsigned long) const;
174 
175 protected:
176  virtual void* AllocBits(unsigned long) const;
177  virtual void DeleteBits(bool becauseExpanding);
178 
179  OOF_RepBlockCellRow* mRows; // typed reference to mBits
180 };
181 
182 
188 public:
190  void initMapping();
191 
192 // cell content access methods
193  virtual oofString getCellText(bool* outIsEditable=0, oofString* outLocationName=0, long row=-1, short col=-1);
194  virtual void setCellText(const oofString&, long row=-1, short col=-1);
195 
196 // reflective methods to query link
197  virtual bool allowsCellTextStyles() const;
198 
199  void getFirstCoordsForBlock(oofRepBlock*, short& col, short& row) const;
200 
201 // movement testing
202  virtual bool getRightOfCurrent(short& outCol, long& outRow) const;
203  virtual bool getUpFromCurrent(short& outCol, long& outRow) const;
204  virtual bool getDownFromCurrent(short& outCol, long& outRow) const;
205 
206 protected:
207  oofRepLayoutBand* Drawable() const;
208  oofRepBlock* MapCoordsToBlock(long row, short col, short& outCellInBlock) const;
209 
211 };
212 
213 
219 private:
220  oofRepViewEditLink(const oofRepViewEditLink& rhs) : oofRepEditLink(rhs.mDrawable) {}; // can't copy
221 
222 public:
223  oofRepViewEditLink(oofRepViewBand*, bool editingSubSelection);
224  virtual ~oofRepViewEditLink();
225 
226 // cell content access methods
227  virtual oofString getCellText(bool* outIsEditable=0, oofString* outLocationName=0, long row=-1, short col=-1);
228  virtual void setCellText(const oofString&, long row=-1, short col=-1);
229 
230 // init and cleanup code when edit dialog launches and if it changes links
231  virtual void enterLink(dbGUIAdapter*);
232 
233 // reflective methods to query link
234  virtual bool allowsCellTextStyles() const;
235 
236  virtual bool hasCustomViewDrawers() const;
237  virtual oofRepCustomViewDrawer* customViewDrawer(long col) const; // returns NULL if has none
238 
239 // movement testing
240  virtual bool getRightOfCurrent(short& outCol, long& outRow) const;
241  virtual bool getUpFromCurrent(short& outCol, long& outRow) const;
242  virtual bool getDownFromCurrent(short& outCol, long& outRow) const;
243 
244 protected:
245  oofRepViewBand* Drawable() const;
246  dbView* View() const;
247 
248 // data storage
249  dbSelection* mSelection; // owned but maybe NULL as may not need to reset selection
250  unsigned long mRecordNumber;
251 };
252 
253 
261 public:
263 
264 // cell content access methods
265  virtual oofString getCellText(bool* outIsEditable=0, oofString* outLocationName=0, long row=-1, short col=-1);
266  virtual void setCellText(const oofString&, long row=-1, short col=-1);
267 
268 // movement testing
269  virtual bool getRightOfCurrent(short& outCol, long& outRow) const;
270 
271 protected:
272  dbView* View() const;
273  oofRepViewBand* Drawable() const;
274 };
275 
276 
277 
283 public:
284  virtual void singleClick(short inX, short inY, OOF_InteractionArea*, oofRepEditingEnv*);
285 };
286 
287 
294 public:
296 
297  bool matchesPageLocation(short inX, short inY) const;
298  void singleClick(short inX, short inY, oofRepEditingEnv*);
299 
300  short X, Y, mWidth, mHeight;
301  long mRow;
302  short mCol;
305 };
306 
307 
315 public:
317  virtual ~OOF_InteractionPageAreas();
318 
319 // data adders
321  void addInteractionArea(short inX, short inY, short inCol, long inRow, oofRepEditLink*, oofRepInteractorStrategy* inInteractor=0, short inWidth=0, short inHeight=0);
323  void changeAreasToNewLink(long matchingRow, oofRepEditLink* matchingLink, oofRepEditLink* newLink);
324  void startNonEditableArea(unsigned long newY);
325 
326 
327 // queries
328  OOF_InteractionArea* findAreaBelowAndRightOf(short inX, short inY);
330 
331 protected:
332  virtual void* AllocBits(unsigned long) const;
333  virtual void DeleteBits(bool becauseExpanding);
334 
337 };
338 
339 
345 public:
347  virtual ~OOF_InteractionPages();
348 
349  void addPage();
351  OOF_InteractionPageAreas& page(unsigned long index);
352 
353 protected:
354  virtual void* AllocBits(unsigned long) const;
355  virtual void DeleteBits(bool becauseExpanding);
356 
358 };
359 
360 
361 // capable base class but user can replace by subclassing oofRepEditor
362 
363 #ifdef _Macintosh
364 
369  public:
371 #elif defined(_Windows)
372 
377  public:
378  typedef oofRepWinGUIPreviewMFC parentGUIenvT;
379 #endif
381  virtual ~oofRepEditingEnv();
382 
383  virtual void startEnvironment();
384  virtual void endEnvironment();
385 
386  parentGUIenvT* parentGUIenv() const;
387  oofRepEditor* editor() const;
388 
389  virtual void makeRenderDispatch(oofRepDrawable*) const;
390  virtual void makeRenderDispatch(oofAdorner*) const;
391 
392  virtual void drawPageBreak();
393  virtual void splitBandOverPage();
394  virtual void resumeBandOverPage();
395 
397 
398  virtual void addInteractionArea(short inX, short inY, short inCol, long inRow, oofRepEditLink* inEditor, oofRepInteractorStrategy* inInteractor=0, short width=0, short height=0);
399  virtual void addInteractionArea(const OOF_InteractionArea&);
400  void pageAdoptsEditLink(oofRepEditLink*);
401  void changeAreasToNewLink(long matchingRow, oofRepEditLink* matchingLink, oofRepEditLink* newLink);
402  void startNonEditableArea();
404 
405 #ifdef _Macintosh
406  virtual void startMonitoringWindowInteractions(LPane*);
407 #elif defined(_Windows)
408 #endif
409 
410 
412  virtual void singleClick(short x, short y);
413 
414 protected:
418 };
419 
420 
421 // -------------------------------------------------------
422 // o o f R e p E d i t i n g E n v i r o n m e n t
423 // -------------------------------------------------------
426 {
427  return (parentGUIenvT*) this;
428 }
429 
430 
431 inline oofRepEditor*
433 {
434  return mEditor;
435 }
436 
437 
438 inline void
440 {
441  mInteractionPages->latestPage().pageAdoptsEditLink(inLink);
442 }
443 
444 
445 // -------------------------------------------------------
446 // o o f R e p R e d i r e c t i n g R e n d e r
447 // -------------------------------------------------------
448 inline oofRepEditingEnv*
450 {
451  const oofRep* curRep = oofRep::currentReport();
452  oofRepEditingEnv* ret = (oofRepEditingEnv*)curRep->environment(); // slightly unsafe downcast, lacks local protection
453  return ret;
454 }
455 
456 
457 inline oofRepEditor*
459 {
460  oofRepEditor* ret = editingEnv()->editor();
461  return ret;
462 }
463 
464 
465 // -------------------------------------------------------
466 // o o f R e p L a y o u t E d i t L i n k
467 // -------------------------------------------------------
468 
469 inline oofRepLayoutBand*
471 {
472  return (oofRepLayoutBand*) mDrawable; // safe downcast
473 }
474 
475 
476 // -------------------------------------------------------
477 // o o f R e p V i e w E d i t L i n k
478 // -------------------------------------------------------
479 
480 inline oofRepViewBand*
482 {
483  return (oofRepViewBand*) mDrawable; // safe downcast
484 }
485 
486 
487 inline dbView*
489 {
490  return Drawable()->view(0);
491 }
492 
493 
494 
495 // -------------------------------------------------------
496 // o o f R e p C o l H e a d e r E d i t L i n k
497 // -------------------------------------------------------
498 
499 inline dbView*
501 {
502  return ((oofRepViewBand*) mDrawable)->view(0);
503 }
504 
505 
506 inline oofRepViewBand*
508 {
509  return (oofRepViewBand*) mDrawable; // safe downcast
510 }
511 
512 
513 // -------------------------------------------------------
514 // o o f R e p V i e w R e d i r e c t i n g R e n d e r
515 // -------------------------------------------------------
516 
517 inline oofRepViewBand*
519 {
520  assert(mWrappedRender);
521  return ((oofRepViewBand_Render*)mWrappedRender)->viewBand(); // safe downcast
522 }
523 
524 
525 // -------------------------------------------------------
526 // o o f R e p L a y o u t R e d i r e c t i n g R e n d e r
527 // -------------------------------------------------------
530 {
531  return sCurrentLayoutRedirectingRender;
532 }
533 
534 
536 oofRepLayoutRedirectingRender::LayoutRender() const
537 {
538  assert(mWrappedRender);
539  return (oofRepLayoutBand_Render*)mWrappedRender; // safe downcast
540 }
541 
542 
543 
544 // -------------------------------------------------------
545 // O O F _ I n t e r a c t i o n A r e a
546 // -------------------------------------------------------
547 inline
549  #if _MSC_VER>=1010
550  // suppress farcical Visual C++ warning - the standard constant for Shorts is
551  // not a short!
552  // warning C4309: 'initializing' : truncation of constant value
553  // warning C4305: 'initializing' : truncation from 'const int' to 'short'
554  #pragma warning( disable : 4309; disable : 4305 )
555  #endif
556  X(USHRT_MAX),
557  Y(USHRT_MAX),
558  mEditLink(0),
559  mWidth(0),
560  mHeight(0),
561  mInteractionStrategy(0),
562  mRow(-1),
563  mCol(-1)
564 {}
565 
566 
570 inline void
572 {
573  mInteractionStrategy->singleClick(inX, inY, this, inEnv); // Flyweight pattern, Strategy requires us to supply context
574 }
575 
576 
580 inline bool
581 OOF_InteractionArea::matchesPageLocation(short inX, short inY) const
582 {
583  return (
584  (X<=inX && Y<=inY) &&
585  (mHeight==0 || mHeight>=(inY-Y)) &&
586  (mWidth==0 || mWidth >=(inX-X))
587  );
588 }
589 
590 
591 
592 // -------------------------------------------------------
593 // O O F _ I n t e r a c t i o n P a g e s
594 // -------------------------------------------------------
595 inline void
597 {
598  const unsigned long allocSlot = AllocSlot();
599 }
600 
601 
604 {
605  const unsigned long numItems = count();
606  assert(numItems>0); // always have a page active!
607  return mPages[numItems-1];
608 }
609 
610 
612 OOF_InteractionPages::page(unsigned long index)
613 {
614  assert(index<count());
615  return mPages[index];
616 }
617 
618 
619 // -------------------------------------------------------
620 // O O F _ R e p B l o c k C e l l R o w s
621 // -------------------------------------------------------
622 inline OOF_RepBlockCellRow&
623 OOF_RepBlockCellRows::row(unsigned long index) const
624 {
625  assert(index<count());
626  return mRows[index];
627 }
628 
629 
630 inline OOF_RepBlockCellRow* // return pointer so can reassign
632 {
633  unsigned long index = AllocSlot();
634  return &mRows[index];
635 }
636 
637 
638 
639 
640 // -------------------------------------------------------
641 // O O F _ R e p B l o c k C e l l R o w
642 // -------------------------------------------------------
643 inline OOF_RepBlockCellMap&
644 OOF_RepBlockCellRow::map(unsigned long index) const
645 {
646  assert(index<count());
647  return mMaps[index];
648 }
649 #endif // H_OOFREPEDITX
650 
651 
OOF_RepBlockCellRow & row(unsigned long) const
Definition: oofrepeditx.h:623
OOF_InteractionPages * mInteractionPages
owned
Definition: oofrepeditx.h:417
oofRepEditor * editor() const
Definition: oofrepeditx.h:432
virtual void DeleteBits(bool becauseExpanding)
Definition: oofrepedit.cpp:589
virtual void draw()
Definition: oofrep1.cpp:1473
Abstract parent defining how report preview reacts to interaction.
Definition: oofrepedit.h:34
Abstract base for anything drawn on report.
Definition: oofrep.h:860
oofRepEditor * editor() const
Definition: oofrepeditx.h:458
oofRepBlock * mBlock
Definition: oofrepeditx.h:137
bool matchesPageLocation(short inX, short inY) const
Simple rectangular inclusion test.
Definition: oofrepeditx.h:581
OOF_RepBlockCellRow * mRows
Definition: oofrepeditx.h:179
OOF_InteractionArea * mAreas
typed reference to mBits
Definition: oofrepeditx.h:335
OOF_RepBlockCellMap & map(unsigned long) const
Definition: oofrepeditx.h:644
Terminate previous areas so we know we have a dead area.
Definition: oofrepeditx.h:81
Decorator pattern - forwards most calls directly to owned renderer.
Definition: oofrep.h:834
oofRepEnvironment * environment() const
Definition: oofrep.h:1900
virtual void endTableBody()
Definition: oofreprn.h:114
Envelope class to contain an abstract selection apart from its dbTable.
Definition: oof1.h:316
virtual void draw()=0
void addBlockCells(oofRepBlock *)
Definition: oofrepedit.cpp:529
virtual void startEnvironment()
Definition: oofrpWin.cpp:119
virtual ~OOF_InteractionPageAreas()
Definition: oofrepedit.cpp:285
virtual ~OOF_RepBlockCellRows()
Definition: oofrepedit.cpp:572
virtual void DeleteBits(bool becauseExpanding)
Definition: oofrepedit.cpp:309
Record a block within an active oofRepLayoutRedirectingRender.
Definition: oofrepeditx.h:93
void AddMap(short inIndex, oofRepBlock *)
Definition: oofrepedit.cpp:554
Default redirector producing page map when render report to preview.
Definition: oofrepeditx.h:33
virtual oofRepRender * clone(const oofRepDrawable *newOwner) const =0
Most commonly used top band in a report.
Definition: oofrep.h:1283
oofRepEditLink * mColHeaderLink
owned, shared with OOF_InteractionPageAreas
Definition: oofrepeditx.h:126
Base rendering class.
Definition: oofrep.h:816
virtual void makeRenderDispatch(oofRepDrawable *drawable) const
Definition: oofrpWin.cpp:27
virtual oofRepRender * clone(const oofRepDrawable *newOwner) const =0
Subclass platform preview environment to intercept for editing hooks.
Definition: oofrepeditx.h:368
virtual void * AllocBits(unsigned long) const
Definition: oofrepedit.cpp:581
OOF_RepBlockCellMap * mMaps
typed reference to mBits
Definition: oofrepeditx.h:159
Links a dbField to a known control type or I/O mechanism.
Definition: oofgui.h:74
oofRepInteractorStrategy * mInteractionStrategy
Definition: oofrepeditx.h:304
void pageAdoptsEditLink(oofRepEditLink *)
add edit link entry to page, which implies adoption of link if 1st time added to a page ...
Definition: oofrepeditx.h:439
Specify Macintosh GUI drawing environment previewed in PowerPlant window.
Abstract base for rendering an oofRepLayoutBand.
Definition: oofreprn.h:57
virtual void DeleteBits(bool becauseExpanding)
Definition: oofrepedit.cpp:483
Provide an iterable set of fields.
Definition: oofview.h:26
Redirector for layout objects, recording block positions.
Definition: oofrepeditx.h:55
virtual void DeleteBits(bool becauseExpanding)
Definition: oofrepedit.cpp:520
virtual void singleClick(short inX, short inY, OOF_InteractionArea *, oofRepEditingEnv *)
Definition: oofrepedit.cpp:779
Typed array of OOF_RepBlockCellRow with searches.
Definition: oofrepeditx.h:167
PowerPlant base class for drawable item.
virtual void startTableBody(bool)
Definition: oofreprn.h:113
Add extra virtual methods used by oofRep::DrawViewBand beyond normal band drawing.
Definition: oofreprn.h:111
Top level class for a report.
Definition: oofrep.h:571
OOF_InteractionPageAreas & page(unsigned long index)
Definition: oofrepeditx.h:612
OOF_RepBlockCellRow * addRow()
Definition: oofrepeditx.h:631
Areas in just one page.
Definition: oofrepeditx.h:314
oofRepEditor * mEditor
Definition: oofrepeditx.h:415
Describe single rectangular area within preview.
Definition: oofrepeditx.h:293
static oofRepLayoutRedirectingRender * currentLayoutRedirectingRender()
Definition: oofrepeditx.h:529
Abstract base for user column drawer.
Definition: oofrep.h:1239
Map blocks within layout band back to an index for editing.
Definition: oofrepeditx.h:134
Abstract base for rendering an oofRepViewBand.
Definition: oofreprn.h:129
void addInteractionArea(short inX, short inY, short inCol, long inRow, oofRepEditLink *, oofRepInteractorStrategy *inInteractor=0, short inWidth=0, short inHeight=0)
Definition: oofrepedit.cpp:347
Array of longs which expands automatically as you write to cells.
Definition: oofarray.h:21
OOF_InteractionPageAreas * mPages
typed reference to mBits
Definition: oofrepeditx.h:357
virtual void drawPageBreak()
Definition: oofPrnWn.cpp:165
oofRepEditLink * mEditLink
just a ref - may be many maps to same editor!
Definition: oofrepeditx.h:303
virtual void * AllocBits(unsigned long) const
Definition: oofrepedit.cpp:475
virtual OOF_mixViewExtraRender * finishClone(oofRepRender *newClone) const =0
Portable highly capable string class.
Definition: oofstr.h:101
OOF_InteractionArea * mLastAreaOnPrevPage
Definition: oofrepeditx.h:416
virtual void drawColumnHeaders()
Definition: oofreprn.h:119
virtual void * AllocBits(unsigned long) const
Definition: oofrepedit.cpp:512
oofRepEditor encapsulates the factories for all the roles in editing reports and provides a single po...
Definition: oofrepeditor.h:38
Specify a fixed-height band that contains a series of oofRepBlock's.
Definition: oofrep.h:1182
Abstract base for a fixed-size block drawn by an oofRepLayoutBand.
Definition: oofrep.h:1408
Specify MS Windows GUI drawing environment previewed in MFC window.
Definition: oofPrnWn.h:34
virtual ~OOF_RepBlockCellRow()
Definition: oofrepedit.cpp:503
Redirector for view band so maps whilst we page break.
Definition: oofrepeditx.h:108
OOF_InteractionArea * lastAreaAdded() const
may return NULL if none on page yet
Definition: oofrepedit.cpp:377
base class for user arrays.
Definition: oofarray.h:76
oofRepViewBand * ViewBand() const
Definition: oofrepeditx.h:518
Usual interactor triggering editing for a single click on the preview window.
Definition: oofrepeditx.h:282
bool findBlock(oofRepBlock *inBlock, short &outCol) const
Definition: oofrepedit.cpp:540
void startNonEditableArea(unsigned long newY)
Sensible algorithm is only set those in the last row however earlier rows will then match due to thei...
Definition: oofrepedit.cpp:428
void singleClick(short inX, short inY, oofRepEditingEnv *)
Forward a click to our strategy.
Definition: oofrepeditx.h:571
Base object to derive adorners from.
Definition: oofadorn.h:32
OOF_ExpandableLongArray mOwnedLinks
secondary array of owned objects
Definition: oofrepeditx.h:336
oofRepMacGUIPreviewPP parentGUIenvT
Definition: oofrepeditx.h:370
virtual void splitBandOverPage()
Definition: oofrep.h:426
parentGUIenvT * parentGUIenv() const
Definition: oofrepeditx.h:425
Contain all the page maps for a preview window.
Definition: oofrepeditx.h:344
static oofRep * currentReport()
Definition: oofrep.h:2003
oofRepEditingEnv * editingEnv() const
Definition: oofrepeditx.h:449
oofRepEditLink * mEditLink
Definition: oofrepeditx.h:45
virtual ~OOF_InteractionPages()
Definition: oofrepedit.cpp:466
OOF_InteractionArea * findAreaBelowAndRightOf(short inX, short inY)
Definition: oofrepedit.cpp:318
virtual void * AllocBits(unsigned long) const
Definition: oofrepedit.cpp:301
OOF_InteractionPageAreas & latestPage()
return ref so less likely to hang onto expiring pointer
Definition: oofrepeditx.h:603
void pageAdoptsEditLink(oofRepEditLink *)
add edit link entry to page, which implies adoption of link if 1st time added to a page ...
Definition: oofrepedit.cpp:395
#define OOFREP_EXPORT
Prefix for report writer classes to enable optional DLL linking.
Definition: oof0.h:189
virtual void resumeBandOverPage()
Definition: oofrep.h:427
Typed array of OOF_RepBlockCellMap with searches.
Definition: oofrepeditx.h:145
virtual void endEnvironment()
Definition: oofrep2.cpp:1260
void changeAreasToNewLink(long matchingRow, oofRepEditLink *matchingLink, oofRepEditLink *newLink)
Definition: oofrepedit.cpp:406