tableeditor.h

Go to the documentation of this file.
00001 #ifndef TABLE_EDITOR_HEADER_INCLUDED_p
00002 #define TABLE_EDITOR_HEADER_INCLUDED_p
00003 //
00004 // Copyright 2010, Lowell Boggs Jr.
00005 //
00006 // This file or directory, containing source code for a computer program,
00007 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00008 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00009 // source file without charge or obligation so long as you agree to
00010 // the following:
00011 //
00012 //  1.  You must indemnify Lowell Boggs against any and all financial
00013 //      obligations caused by its use, misuse, function, or malfunction.
00014 //      Further, you acknowledge that there is no warranty of any kind,
00015 //      whatsoever.
00016 //
00017 //  2.  You agree not to attempt to patent any portion of this original
00018 //      work -- though you may attempt to patent your own extensions to
00019 //      it if you so choose.
00020 //
00021 //  3.  You keep this copyright notice with the file and all copies
00022 //      of the file and do not change it anyway except language translation.
00023 //
00024 // You are responsible for enforcing your own compliance with these
00025 // conditions and may not use this source file if you cannot agree to the
00026 // above terms and conditions.
00027 
00028 #include <cxxtls/tableviewer.h>
00029 #include <cxxtls/file.h>
00030 
00031 namespace cxxtls
00032 {
00033 
00034 class TableEditor
00035 : public TableViewer
00045 {
00046 
00047     size_t fieldEditColumn_;
00048 
00049 
00050 public:
00051 
00052     TableEditor(ViewerManager *vm,
00053               int delimChar=','
00054              );
00070     
00071     virtual ~TableEditor();
00072 
00073 
00074 protected:
00075 
00076     int    delimiter_;
00077     bool   keyKludge_;  // previous input key was ^X
00078 
00079     virtual bool handle_event( CursorWindow::input_event const * e,
00080                              CursorWindow::viewport          * vp
00081                            );
00084 
00085 
00086    virtual void setCursorInfo(CursorWindow::viewport *vp,
00087                               size_t worldRow, 
00088                               size_t worldCol, 
00089                               bool displayed
00090                              );
00094 
00095    void terminateInput();
00097 
00098    CellInfo *editCell(); 
00104 
00105    virtual void paintField(CursorWindow::viewport *vp,
00106                            size_t          vpRow, 
00107                            size_t          vpCol, 
00108                            CellInfo const *cell, 
00109                            size_t          cellRow, 
00110                            size_t          vpColumns,
00111                            bool            editCursor
00112                           );
00136 
00137     static bool isTableEditKey(CursorWindow::input_event const * e);
00142 
00143     bool fieldEditable(size_t tableRow, size_t tableCol) const
00154 
00155     {
00156        if(    tableRow >= rows_.size()
00157           ||  tableCol >= cols_.size()
00158          )
00159             return false; // invalid table location
00160 
00161        return rows_[tableRow].editable_ && cols_[tableCol].editable_;
00162     }
00163 
00164     bool fieldEditable(CursorInfo const &cur) const
00174     {
00175       return fieldEditable(cur.row_, cur.col_);
00176     }
00177 
00178 
00179     void snatchEdit(CursorWindow::viewport *vp, FileName const &directory);
00191 
00192 };
00193 
00194 } // namespace cxxtls
00195 #endif
Generated on Wed Feb 29 22:50:04 2012 for CXXUtilities by  doxygen 1.6.3