ICS

QicsTable Documentation Set

QicsDimensionManager.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 **
00003 ** Copyright (C) 2002-2006 Integrated Computer Solutions, Inc
00004 ** All rights reserved.
00005 **
00006 ** This file is part of the QicsTable Product.
00007 **
00008 **********************************************************************/
00009 
00010 #ifndef _QICSDIMENSIONMANAGER_H
00011 #define _QICSDIMENSIONMANAGER_H
00012 
00013 #include <QicsNamespace.h>
00014 #include <QicsGridInfo.h>
00015 #include <QicsStyleManager.h>
00016 
00017 #include <qobject.h>
00018 #include <qvaluevector.h>
00019 #include <qvaluelist.h>
00020 
00022 
00044 class QICS_EXPORT QicsDimensionManager : public QObject, public Qics
00045 {
00046     Q_OBJECT
00047 public:
00048 
00053     QicsDimensionManager(QicsGridInfo *grid_info);
00054 
00055     QicsDimensionManager(const QicsDimensionManager &dm, QicsGridInfo *grid_info);
00056 
00060     ~QicsDimensionManager();
00061 
00071     void setControllingRowDimensionManager(QicsDimensionManager *dm);
00081     void setControllingColumnDimensionManager(QicsDimensionManager *dm);
00082 
00089     void setDefaultFont(const QFont &fnt);
00090 
00099     void setRowFont(QicsGridType grid_type, int row, bool visual_coords,
00100             const QFont &fnt);
00108     void unsetRowFont(QicsGridType grid_type, int row, bool visual_coords);
00109 
00115     void setRepeatingRowFont(QicsGridType grid_type,
00116                  int row, unsigned int interval,
00117                  const QFont &fnt);
00118 
00127     void setColumnFont(QicsGridType grid_type, int col, bool visual_coords,
00128                const QFont &fnt);
00137     void unsetColumnFont(QicsGridType grid_type, int col, bool visual_coords);
00138 
00144     void setRepeatingColumnFont(QicsGridType grid_type,
00145                 int col, unsigned int interval,
00146                 const QFont &fnt);
00147 
00156     void setCellFont(QicsGridType grid_type, int row, int col,
00157              bool visual_coords, const QFont &fnt);
00166     void unsetCellFont(QicsGridType grid_type, int row, int col,
00167                bool visual_coords);
00168 
00174     void setRowHeightInPixels(int row, bool visual_coords, int height);
00181     void setRowHeightInChars(int row, bool visual_coords, int height);
00182 
00188     void setRepeatingRowHeightInPixels(int row, unsigned int interval,
00189                        int height);
00195     void setRepeatingRowHeightInChars(int row, unsigned int interval,
00196                        int height);
00197 
00201     void setDefaultRowHeightInPixels(int height);
00206     void setDefaultRowHeightInChars(int height);
00207 
00213     void setColumnWidthInPixels(int col, bool visual_coords, int width);
00219     void setColumnWidthInChars(int col, bool visual_coords, int width);
00220 
00226     void setRepeatingColumnWidthInPixels(int col, unsigned int interval,
00227                      int width);
00233     void setRepeatingColumnWidthInChars(int col, unsigned int interval,
00234                     int width);
00235 
00239     void setDefaultColumnWidthInPixels(int width);
00244     void setDefaultColumnWidthInChars(int width);
00245 
00249     int rowHeight(int row,
00250           bool use_model_settings = true,
00251           bool use_visual_settings = true,
00252           bool force_calc = false) const;
00256     int columnWidth(int col,
00257             bool use_model_settings = true,
00258             bool use_visual_settings = true,
00259             bool force_calc = false) const;
00260 
00266     void setRowMinHeightInPixels(int row, bool visual_coords, int height);
00273     void setRowMinHeightInChars(int row, bool visual_coords, int height);
00274 
00280     void setColumnMinWidthInPixels(int col, bool visual_coords, int width);
00286     void setColumnMinWidthInChars(int col, bool visual_coords, int width);
00287 
00291     int rowMinHeight(int row, bool use_model_settings = true,
00292              bool use_visual_settings = true) const;
00296     int columnMinWidth(int col, bool use_model_settings = true,
00297                bool use_visual_settings = true) const;
00298 
00302     void setDefaultMargin(int margin);
00308     void setRowMargin(QicsGridType grid_type, int row, bool visual_coords,
00309               int margin);
00315     void setColumnMargin(QicsGridType grid_type, int col, bool visual_coords,
00316              int margin);
00322     void setCellMargin(QicsGridType grid_type, int row, int col,
00323                bool visual_coords, int margin);
00324 
00330     void setRepeatingRowMargin(QicsGridType grid_type,
00331                    int row, unsigned int interval,
00332                    int margin);
00338     void setRepeatingColumnMargin(QicsGridType grid_type,
00339                   int col, unsigned int interval,
00340                   int margin);
00341 
00345     void setDefaultBorderWidth(int bw);
00351     void setRowBorderWidth(QicsGridType grid_type, int row,
00352                bool visual_coords, int bw);
00358     void setColumnBorderWidth(QicsGridType grid_type, int col,
00359                   bool visual_coords, int bw);
00365     void setCellBorderWidth(QicsGridType grid_type, int row, int col,
00366                 bool visual_coords, int bw);
00367 
00373     void setRepeatingRowBorderWidth(QicsGridType grid_type,
00374                     int row, unsigned int interval,
00375                     int bw);
00381     void setRepeatingColumnBorderWidth(QicsGridType grid_type,
00382                        int col, unsigned int interval,
00383                        int bw);
00384 
00388     bool isRowStretchable(int row, bool visual_coords) const;
00389 
00393     void setRowStretchable(int row, bool visual_coords, bool set);
00394 
00398     bool isColumnStretchable(int col, bool visual_coords) const;
00399 
00403     void setColumnStretchable(int col, bool visual_coords, bool set);
00404 
00409     void stretchRows(int start_row, int end_row, int space,
00410              bool visual_coords);
00411 
00416     void stretchColumns(int start_col, int end_col, int space,
00417             bool visual_coords);
00418 
00423     int regionHeight(const QicsRegion &region) const;
00428     int regionWidth(const QicsRegion &region) const;
00429 
00434     void overrideRowHeight(int row, int height);
00435 
00440     void overrideColumnWidth(int col, int width);
00441 
00446     void resetRowHeight(int row);
00447 
00452     void resetColumnWidth(int col);
00453 
00458     int overriddenRowHeight(int row) const;
00459 
00464     int overriddenColumnWidth(int col) const;
00465 
00466     void dumpWidths(void) const;
00467     void dumpHeights(void) const ;
00468 
00472     void hideRow(int row);
00473 
00477     void hideColumn(int col);
00478 
00482     void showRow(int row);
00483 
00487     void showColumn(int col);
00488 
00492     bool isRowHidden(int row) const;
00493 
00497     bool isColumnHidden(int col) const;
00498 
00499 public slots:
00503     void insertRows(int num, int start_position);
00507     void insertColumns(int num, int start_position);
00511     void deleteRows(int num, int start_position);
00515     void deleteColumns(int num, int start_position);
00516 
00517 signals:
00522     void dimensionChanged();
00523     
00524     
00529     void rowResized(int row,int old_height,int new_height);
00530     
00535     void columnResized(int column,int old_width,int new_width);
00536 
00537 // Should be protected, but the Sun Workshop compiler complains
00538 public:
00539     enum QicsGridRole { QicsTableGridRole,
00540             QicsRowHeaderGridRole,
00541             QicsColumnHeaderGridRole };
00542 
00543     enum QicsDimensionMode { QicsDimensionUnset,
00544                  QicsDimensionPixel,
00545                  QicsDimensionChar };
00546 
00547 protected:
00551 
00555     class QicsCellSetting
00556     {
00557     public:
00559     QicsCellSetting();
00561     bool isEmpty(void) const;
00562 
00564     QicsGridRole role;
00566     int row;
00568     int col;
00570     int font_height;
00572     int font_width;
00574     int cell_margin;
00576     int border_width;
00577     };
00579     typedef QValueVector<QicsCellSetting> QicsCellSettingV;
00581     typedef QValueVector<QicsCellSetting *> QicsCellSettingPV;
00582 
00586     class QicsRowSetting
00587     {
00588     public:
00590     QicsRowSetting();
00592     bool isEmpty(void) const;
00593 
00595     QicsGridRole role;
00597     int row;
00599     int font_height;
00601     int font_width;
00603     int cell_margin;
00605     int border_width;
00607     bool stretchable;
00608     };
00610     typedef QValueVector<QicsRowSetting> QicsRowSettingV;
00612     typedef QValueVector<QicsRowSetting *> QicsRowSettingPV;
00613 
00617     class QicsColumnSetting
00618     {
00619     public:
00621     QicsColumnSetting();
00623     bool isEmpty(void) const;
00624 
00626     QicsGridRole role;
00628     int col;
00630     int font_height;
00632     int font_width;
00634     int cell_margin;
00636     int border_width;
00638     bool stretchable;
00639     };
00641     typedef QValueVector<QicsColumnSetting> QicsColumnSettingV;
00643     typedef QValueVector<QicsColumnSetting *> QicsColumnSettingPV;
00644 
00645     class QicsRepeatingRowSetting : public QicsRowSetting
00646     {
00647     public:
00648     QicsRepeatingRowSetting();
00649 
00651     unsigned int interval;
00652     };
00654     typedef QValueVector<QicsRepeatingRowSetting> QicsRepeatingRowSettingV;
00656     typedef QValueVector<QicsRepeatingRowSetting *> QicsRepeatingRowSettingPV;
00657 
00658     class QicsRepeatingColumnSetting : public QicsColumnSetting
00659     {
00660     public:
00661     QicsRepeatingColumnSetting();
00662 
00664     unsigned int interval;
00665     };
00667     typedef QValueVector<QicsRepeatingColumnSetting> QicsRepeatingColumnSettingV;
00669     typedef QValueVector<QicsRepeatingColumnSetting *> QicsRepeatingColumnSettingPV;
00670 
00675     class QicsDefaultDimensionSetting {
00676     public:
00680     QicsDefaultDimensionSetting();
00684     QicsDefaultDimensionSetting(const QicsDefaultDimensionSetting &);
00688     void setFont(const QFont &fnt);
00689 
00693     void setHeightInPixels(int height);
00697     void setHeightInChars(int height);
00698 
00702     void setWidthInPixels(int width);
00706     void setWidthInChars(int width);
00707 
00712     void compute(void);
00713 
00715     QicsDimensionMode mode;
00717     int height;
00719     int width;
00721     int height_chars;
00723     int width_chars;
00725     int font_height;
00727     int font_width;
00729     int cell_margin;
00731     int border_width;
00732     };
00733 
00737     class QicsRowHeight {
00738     public:
00742     QicsRowHeight();
00746     QicsRowHeight(const QicsRowHeight &rh);
00747 
00749     QicsDimensionMode mode;
00751     int height;
00753     int chars;
00755     int valid;
00756 
00757     };
00759     typedef QValueVector<QicsRowHeight> QicsRowHeightV;
00761     typedef QValueVector<QicsRowHeight *> QicsRowHeightPV;
00762 
00766     class QicsColumnWidth {
00767     public:
00771     QicsColumnWidth();
00775     QicsColumnWidth(const QicsColumnWidth &cw);
00776 
00778     QicsDimensionMode mode;
00780     int width;
00782     int chars;
00784     int valid;
00785     };
00787     typedef QValueVector<QicsColumnWidth> QicsColumnWidthV;
00789     typedef QValueVector<QicsColumnWidth *> QicsColumnWidthPV;
00790 
00791     class QicsRepeatingRowHeight : public QicsRowHeight
00792     {
00793     public:
00794     QicsRepeatingRowHeight();
00795     
00799     QicsRepeatingRowHeight(const QicsRepeatingRowHeight &rh);
00800 
00802     int row;
00804     unsigned int interval;
00805     };
00807     typedef QValueVector<QicsRepeatingRowHeight> QicsRepeatingRowHeightV;
00809     typedef QValueVector<QicsRepeatingRowHeight *> QicsRepeatingRowHeightPV;
00810 
00811     class QicsRepeatingColumnWidth : public QicsColumnWidth
00812     {
00813     public:
00814     QicsRepeatingColumnWidth();
00815 
00819     QicsRepeatingColumnWidth(const QicsRepeatingColumnWidth &cw);
00820 
00822     int col;
00824     unsigned int interval;
00825     };
00827     typedef QValueVector<QicsRepeatingColumnWidth> QicsRepeatingColumnWidthV;
00829     typedef QValueVector<QicsRepeatingColumnWidth *> QicsRepeatingColumnWidthPV;
00830 
00831     class QicsOverrideSetting {
00832     public:
00833     inline QicsOverrideSetting()
00834         { myIndex = -1; myVal = -1; }
00835     inline QicsOverrideSetting(int idx, int val)
00836         { myIndex = idx; myVal = val; }
00837 
00838     inline QicsOverrideSetting(const QicsOverrideSetting &os)
00839         { myIndex = os.myIndex; myVal = os.myVal; }
00840 
00841     inline int index(void) const
00842         { return myIndex; }
00843 
00844     inline void setIndex(int idx)
00845         { myIndex = idx; }
00846 
00847     inline int value(void) const
00848         { return myVal; }
00849 
00850     inline void setValue(int val)
00851         { myVal = val;; }
00852 
00853     protected:
00854     int myIndex;
00855     int myVal;
00856     };
00857     typedef QValueList<QicsOverrideSetting> QicsOverrideSettingL;
00858 
00860 
00864     QicsGridRole gridRole(QicsGridType grid_type) const;
00865 
00874     int computeRowHeight(int row, QicsRowHeightPV &row_heights,
00875              int visual_row, QicsRowHeightPV &vrow_heights,
00876              QicsDefaultDimensionSetting &default_dims);
00877 
00885     int computeRowHeight(int nlines, int font_height,
00886              int cell_margin, int border_width);
00887 
00896    int computeColumnWidth(int col, QicsColumnWidthPV &col_widths,
00897                int visual_col, QicsColumnWidthPV &vcol_widths,
00898                QicsDefaultDimensionSetting &default_dims);
00899 
00907     int computeColumnWidth(int nchars, int font_width,
00908              int cell_margin, int border_width);
00909 
00910 
00919     bool computeDefaultRowFontHeight(void);
00928     bool computeDefaultColumnFontWidth(void);
00929 
00935     bool computeAllRowHeights(void);
00941     bool computeAllColumnWidths(void);
00942 
00948     void invalidateRowHeight(int row);
00954     void invalidateColumnWidth(int col);
00955 
00959     QicsGridInfo *gridInfo(void) const
00960     { return myGridInfo; }
00961 
00962     QicsStyleManager *styleManager(void) const
00963     { return gridInfo()->styleManager(); }
00964 
00966     QicsDimensionManager *myRowDM;
00968     QicsDimensionManager *myColumnDM;
00969 
00971     QicsCellSettingV mySetCells;
00973     QicsRowSettingV mySetRows;
00975     QicsColumnSettingV mySetColumns;
00976 
00978     QicsRowHeightPV myRowHeights;
00980     QicsColumnWidthPV myColumnWidths;
00981 
00983     QicsRowHeightPV myRowMinHeights;
00985     QicsColumnWidthPV myColumnMinWidths;
00986 
00988     QicsDefaultDimensionSetting myOrigDefaultDimensions;
00990     QicsDefaultDimensionSetting myCurrentDefaultDimensions;
00991 
00993     QicsDefaultDimensionSetting myOrigDefaultMinDimensions;
00995     QicsDefaultDimensionSetting myCurrentDefaultMinDimensions;
00996 
00997     QicsOverrideSettingL myRowOverrides;
00998     QicsOverrideSettingL myColumnOverrides;
00999 
01000     QValueList<int> myHiddenRows;
01001     QValueList<int> myHiddenColumns;
01002 
01004     QicsCellSettingV mySetVisualCells;
01006     QicsRowSettingV mySetVisualRows;
01008     QicsColumnSettingV mySetVisualColumns;
01010     QicsRepeatingRowSettingV mySetRepeatingRows;
01012     QicsRepeatingColumnSettingV mySetRepeatingColumns;
01013 
01015     QicsRowHeightPV myVisualRowHeights;
01017     QicsColumnWidthPV myVisualColumnWidths;
01018 
01020     QicsRowHeightPV myVisualRowMinHeights;
01022     QicsColumnWidthPV myVisualColumnMinWidths;
01023 
01025     QicsRepeatingRowHeightV myRepeatingRowHeights;
01027     QicsRepeatingColumnWidthV myRepeatingColumnWidths;
01028 
01030     QicsGridInfo *myGridInfo;
01031 
01033     int myLastStretchedRow;
01035     int myLastStretchedColumn;
01036 
01038     bool _allow_override_changes;
01039 
01040     friend class QicsDimensionManager::QicsRowHeight;
01041     friend class QicsDimensionManager::QicsColumnWidth;
01042     friend class QicsDimensionManager::QicsDefaultDimensionSetting;
01043 
01044 private:
01045     void dupSetCells(const QicsCellSettingV &from, QicsCellSettingV &to);
01046     void dupSetRows(const QicsRowSettingV &from, QicsRowSettingV &to);
01047     void dupSetColumns(const QicsColumnSettingV &from, QicsColumnSettingV &to);
01048     void dupRowHeights(const QicsRowHeightPV &from, QicsRowHeightPV &to);
01049     void dupColumnWidths(const QicsColumnWidthPV &from, QicsColumnWidthPV &to);
01050 
01051     void delRowHeights(QicsRowHeightPV &vals);
01052     void delColumnWidths(QicsColumnWidthPV &vals);
01053 
01054     void setRowFont(QicsRowSettingV &settings, QicsGridType grid_type,
01055             int row, const QFont &fnt);
01056     void unsetRowFont(QicsRowSettingV &settings, QicsGridType grid_type,
01057               int row);
01058 
01059     void setColumnFont(QicsColumnSettingV &settings, QicsGridType grid_type,
01060                int col, const QFont &fnt);
01061     void unsetColumnFont(QicsColumnSettingV &settings, QicsGridType grid_type,
01062              int col);
01063 
01064     void setCellFont(QicsCellSettingV &settings, QicsGridType grid_type,
01065              int row, int col, const QFont &fnt);
01066     void unsetCellFont(QicsCellSettingV &settings, QicsGridType grid_type,
01067                int row, int col);
01068 };
01069 
01070 #include <QicsMappedDimensionManager.h>
01071 #endif /* _QICSDIMENSIONMANAGER_H */

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.