home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / wfc007.000 / test / grid / grid.cpp next >
Encoding:
C/C++ Source or Header  |  1996-04-08  |  2.4 KB  |  116 lines

  1. #include "wfc.h"
  2. #pragma hdrstop
  3.  
  4. class CMainWindow : public CFrameWnd
  5. {
  6.    public:
  7.  
  8.       CMainWindow();
  9.  
  10.       CLabeledGrid Grid;
  11.  
  12.    protected:
  13.  
  14.       afx_msg void OnPaint();
  15.       DECLARE_MESSAGE_MAP()
  16. };
  17.  
  18. CMainWindow::CMainWindow()
  19. {
  20.    int number_of_rows    = 10;
  21.    int number_of_columns = 10;
  22.  
  23.    Grid.SetSize( number_of_rows, number_of_columns );
  24.  
  25.    int row_index    = 0;
  26.    int column_index = 0;
  27.  
  28.    for ( row_index = 0; row_index < number_of_rows; row_index++ )
  29.    {
  30.       for( column_index = 0; column_index < number_of_columns; column_index++ )
  31.       {
  32.          CSquare *square_p = new CSquare;
  33.  
  34.          square_p->SetSize( 30 );
  35.          square_p->SetLineColor( BLACK );
  36.          square_p->SetFillColor( WHITE );
  37.  
  38.          Grid.SetAt( row_index, column_index, square_p );
  39.       }
  40.    }
  41.  
  42.    TCHAR name[ 10 ];
  43.  
  44.    name[ 0 ] = 'A';
  45.    name[ 1 ] = ' ';
  46.    name[ 2 ] = 'R';
  47.    name[ 3 ] = 'o';
  48.    name[ 4 ] = 'w';
  49.    name[ 5 ] = 0x00;
  50.  
  51.    for ( row_index = 0; row_index < number_of_rows; row_index++ )
  52.    {
  53.       name[ 0 ] = 'A' + row_index;
  54.       Grid.SetRowName( row_index, name );
  55.    }
  56.  
  57.    Grid.SetRowsTitle( "Rows Title" );
  58.  
  59.    for( column_index = 0; column_index < number_of_columns; column_index++ )
  60.    {
  61.       ::sprintf( name, "%02d", column_index );
  62.       Grid.SetColumnName( column_index, name );
  63.    }
  64.  
  65.    Grid.SetColumnsTitle( "Columns Title" );
  66.    Grid.SetName( "Battleship!" );
  67.    //Grid.SetLabelOptions( LABELED_GRID_ALL_TITLES );
  68.    Grid.SetLabelOptions( LABELED_GRID_COLUMNS_TITLE | LABELED_GRID_ROWS_TITLE );
  69.    Grid.SetVerticalSpacing( 2 );
  70.    Grid.SetHorizontalSpacing( 2 );
  71.    
  72.    CRect rectangle( 90, 60, 0, 0 );
  73.  
  74.    Grid.SetRectangle( rectangle );
  75. }
  76.  
  77. BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
  78.    ON_WM_PAINT()
  79. END_MESSAGE_MAP()
  80.  
  81. void CMainWindow::OnPaint()
  82. {
  83.    CPaintDC device_context( this );
  84.  
  85.    Grid.Draw( device_context );
  86. }
  87.  
  88. class CSimpleApplication : public CWinApp
  89. {
  90.    public:
  91.  
  92.       BOOL InitInstance();
  93. };
  94.  
  95. BOOL CSimpleApplication::InitInstance()
  96. {
  97.    CMainWindow *main_window_p = new CMainWindow;
  98.  
  99.    m_pMainWnd = main_window_p;
  100.  
  101.    main_window_p->Create( NULL, "Simple" );
  102.  
  103.    {
  104.       CClientDC device_context( main_window_p );
  105.  
  106.       main_window_p->Grid.PrepareForPainting( device_context );
  107.    }
  108.  
  109.    main_window_p->ShowWindow( m_nCmdShow );
  110.    main_window_p->UpdateWindow();
  111.  
  112.    return( TRUE );
  113. }
  114.  
  115. CSimpleApplication dodah;
  116.