home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
csnb.zip
/
NB.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-12
|
5KB
|
155 lines
//---------------------------------------------------------------------------
// Module name : nb.cpp - notebook example program
//---------------------------------------------------------------------------
// Author : Robert Ferguson
//---------------------------------------------------------------------------
// Date : 1 April, 1994
//---------------------------------------------------------------------------
// Description : This example program is a C++ - CS/ARCHITECT version of
// Rick Fishmans' nbbase.c
//---------------------------------------------------------------------------
// $HEADER$
// $Log$
//---------------------------------------------------------------------------
#define INCL_CSAWINSTDBOOK // notebook controls
#include <csa.h> // include CS/ARCHITECT
#include "nbdefs.h" // application defines
#include "nb.h" // application declarations
// frame window constructor
// window has a tasklist and an icon
MyFrameWindow::MyFrameWindow( PXWINDOW AParent, const CHAR* ATitle,
PXWINDOW AClient )
: xFrameWindow( AParent, ATitle, AClient )
{
FRAMECDATA fcdata ;
QueryControlData( fcdata ) ;
fcdata.flCreateFlags|= FCF_TASKLIST | FCF_ICON ;
SetControlData( fcdata ) ;
}
// client window constructor
// constuct notebook control as child of client window
MyClientWindow::MyClientWindow() : xClientWindow()
{
Notebook= new xNotebook( this ) ;
}
// client setup window processing
// insert notebook pages - default is load on page select
// set major and minor tab dimensions
// set tab and status line text
// etc...
VOID MyClientWindow::SetupWindow()
{
PXNOTEBOOKPAGE ANotebookPage= 0 ;
PXSEPARATORPAGE ASeparatorPage= 0 ;
xPoint point ;
xRect rect ;
xClientWindow::SetupWindow() ;
Notebook->SetTabDimensions( NBPage[ 0 ].TabText, BKA_MAJORTAB ) ;
Notebook->SetTabDimensions( NBPage[ 2 ].TabText, BKA_MINORTAB ) ;
for( INT i= 0 ; i < NUM_PAGES ; i++ )
{
if ( i == 1 )
{
ASeparatorPage= new xSeparatorPage( Notebook ) ;
Notebook->InsertPage( ASeparatorPage ) ;
ASeparatorPage->SetTabText( NBPage[ 1 ].TabText ) ;
continue ;
}
ANotebookPage= new xNotebookPage( Notebook,
NBPage[ i ].Id,
NBPage[ i ].PageStyle ) ;
Notebook->InsertPage( ANotebookPage ) ;
ANotebookPage->SetTabText( NBPage[ i ].TabText ) ;
ANotebookPage->SetStatusLineText( NBPage[ i ].StatusLineText ) ;
// calculate the size of the largest notebook page
rect= ANotebookPage->QueryWindowRect() ;
if ( rect.xRight > point.x )
point.x= rect.xRight ;
if ( rect.yTop > point.y )
point.y= rect.yTop ;
}
rect.xRight= point.x ;
rect.yTop= point.y ;
// map dialog units to window coordinates
WinMapDlgPoints( HWND_DESKTOP, (PPOINTL) &rect, 2, TRUE ) ;
// the notebook is sized to fill the client area
Notebook->CalcPageRect( rect, FALSE ) ;
// calculate the size of the frame from the size of the client
Frame->CalcFrameRect( rect, FALSE ) ;
rect.xRight = rect.xRight - rect.xLeft ;
rect.yTop = rect.yTop - rect.yBottom ;
rect.xLeft = 10 ;
rect.yBottom= 20 ;
// map dialog units to window coordinates
WinMapDlgPoints( HWND_DESKTOP, (PPOINTL) &rect, 1, TRUE ) ;
rect.xRight+= ( rect.xLeft - 1 ) ;
rect.yTop += ( rect.yBottom - 1 ) ;
rect.xRight= ( rect.xRight - rect.xLeft ) + 1 ;
rect.yTop= ( rect.yTop - rect.yBottom ) + 1 ;
// size and activate frame window
Frame->SetWindowPos( HWND_TOP, rect,
SWP_SIZE | SWP_MOVE |
SWP_SHOW | SWP_ACTIVATE ) ;
}
// size of client == size of notebook
VOID MyClientWindow::WMSize( RXMESSAGE msg )
{
xRect rect ;
xClientWindow::WMSize( msg ) ;
QueryWindowRect( rect ) ;
if ( Notebook )
Notebook->SetWindowPos( HWND_TOP, rect,
SWP_SIZE | SWP_MOVE |
SWP_SHOW | SWP_ACTIVATE ) ;
}
// construct main frame and client windows
VOID MyApp::InitMainWindow()
{
MainWindow= new MyFrameWindow( 0,
Name,
new MyClientWindow() ) ;
}
main()
{
MyApp App( "Notebook Sample Program", FALSE ) ;
return App.Run() ;
}
// eof nb.cpp