t.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright 2010, Lowell Boggs Jr.
00004 //
00005 // This file or directory, containing source code for a computer program,
00006 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00007 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00008 // source file without charge or obligation so long as you agree to
00009 // the following:
00010 //
00011 //  1.  You must indemnify Lowell Boggs against any and all financial
00012 //      obligations caused by its use, misuse, function, or malfunction.
00013 //      Further, you acknowledge that there is no warranty of any kind,
00014 //      whatsoever.
00015 //
00016 //  2.  You agree not to attempt to patent any portion of this original
00017 //      work -- though you may attempt to patent your own extensions to
00018 //      it if you so choose.
00019 //
00020 //  3.  You keep this copyright notice with the file and all copies
00021 //      of the file and do not change it anyway except language translation.
00022 //
00023 // You are responsible for enforcing your own compliance with these
00024 // conditions and may not use this source file if you cannot agree to the
00025 // above terms and conditions.
00026 
00027 
00028 //@File
00029 //
00032 
00033 #include <cxxtls/tableviewer.h>
00034 #include <cxxtls/viewermanager.h>
00035 #include <iostream>
00036 
00037 using namespace std;
00038 using namespace cxxtls;
00039 
00040 
00041 
00042 int main()
00043 {
00044   ViewerManager vm;
00045 
00046   vm.open();
00047 
00048   TableViewer *p;
00049 
00050   vm.add( p = (new TableViewer(&vm)), "table" );
00051 
00052   p->setRowsAndColumns(200,200);
00053 
00054   for(int i = 0; i < 200; ++i)
00055   {
00056     char buffer[40];
00057 
00058     sprintf(buffer, "%d", i);
00059 
00060     if(i % 5 == 0 && i)
00061     {
00062         p->setRowInfo(i, buffer, 4, true);
00063     }
00064     else
00065         p->setRowInfo(i, buffer, 4, false);
00066 
00067 
00068     p->setColInfo(i, buffer, 4, false);
00069   }
00070 
00071   for(int row=0; row < 200;  ++row)
00072     for(int col=0; col < 200; ++col)
00073     {
00074        TableViewer::CellInfo *cellInfo = p->cellInfo(row,col);
00075 
00076        if(cellInfo == 0)
00077           abort();  // program bug
00078 
00079        char buffer[80];
00080 
00081        sprintf(buffer, "%03dx,%03dy", row, col);
00082 
00083        if(cellInfo->text_.size() == 0)
00084           cellInfo->text_.push_back(buffer);
00085        else
00086           cellInfo->text_[0] = buffer;
00087 
00088     }
00089 
00090   p->setOrigin(0,0); // virtual world top left corner
00091 
00092 
00093   (*p)(vm.active_viewport(), CursorWindow::viewport::repaint_handler::activate);
00094 
00095   vm.run();
00096 
00097 
00098 
00099 }
00100 
Generated on Wed Feb 29 22:50:03 2012 for CXXUtilities by  doxygen 1.6.3