home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * WINDOW.CXX
- * (c) 1992-1994 STAR DIVISION
- *******************************************************************/
-
- #include <sv.hxx>
-
- #define TEXTY 15
- #define WINDOWX 200
- #define WINDOWY 150
-
- // --- class MyApp -------------------------------------------------
-
- class MyApp : public Application
- {
- public:
- virtual void Main( int, char*[] );
- };
-
- // --- class WindowWithParent --------------------------------------
-
- class WindowWithParent : public WorkWindow
- {
- public:
- WindowWithParent( Window* );
-
- virtual void Resize();
- virtual void Paint( const Rectangle& );
- virtual void Move();
- };
-
- // --- class WindowWithoutParent -----------------------------------
-
- class WindowWithoutParent : public WorkWindow
- {
- public:
- WindowWithoutParent();
-
- virtual void Resize();
- virtual void Paint( const Rectangle& );
- virtual void Move();
- };
-
- // --- class ChildWindow -------------------------------------------
-
- class ChildWindow : public Window
- {
- public:
- ChildWindow( Window* );
-
- virtual void Resize();
- virtual void Paint( const Rectangle& );
- virtual void Move();
- };
-
- // --- class MyWindow ----------------------------------------------
-
- class MyWindow : public WorkWindow
- {
- protected:
- WindowWithParent aWindowWithParent;
- WindowWithoutParent aWindowWithoutParent;
- ChildWindow aChildWindow;
-
- public:
- MyWindow();
-
- virtual void Resize();
- virtual void Move();
- };
-
- // --- WindowWithParent::WindowWithParent --------------------------
-
- WindowWithParent::WindowWithParent( Window* pParent ) :
- WorkWindow( pParent, WB_STDWORK )
- {
- Font aFont;
- aFont.ChangePitch( PITCH_FIXED );
- ChangeFont( aFont );
- }
-
- // --- WindowWithParent::Resize() ----------------------------------
-
- void WindowWithParent::Resize()
- {
- Invalidate();
- }
-
- // --- WindowWithParent::Move() ------------------------------------
-
- void WindowWithParent::Move()
- {
- Invalidate();
- }
-
- // --- WindowWithParent::Paint() -----------------------------------
-
- void WindowWithParent::Paint( const Rectangle& )
- {
- Point aPosition( GetPosPixel() );
- Point aScreenPosition( OutputToScreenPixel( Point( 0, 0 ) ) );
- Size aSize( GetSizePixel() );
- Size aOutputSize( GetOutputSizePixel() );
- String aOutStr;
-
- aOutStr = "Pos: ";
- aOutStr += aPosition.X();
- aOutStr += " , ";
- aOutStr += aPosition.Y();
- DrawText( Point( 0, 0 ), aOutStr );
-
- aOutStr = "Scr-Pos: ";
- aOutStr += aScreenPosition.X();
- aOutStr += " , ";
- aOutStr += aScreenPosition.Y();
- DrawText( Point( 0, TEXTY ), aOutStr );
-
- aOutStr = "Size: ";
- aOutStr += aSize.Width();
- aOutStr += " : ";
- aOutStr += aSize.Height();
- DrawText( Point( 0, 2*TEXTY ), aOutStr );
-
- aOutStr = "Out-Size: ";
- aOutStr += aOutputSize.Width();
- aOutStr += " : ";
- aOutStr += aOutputSize.Height();
- DrawText( Point( 0, 3*TEXTY ), aOutStr );
- }
-
- // --- WindowWithoutParent::WindowWithoutParent --------------------
-
- WindowWithoutParent::WindowWithoutParent() :
- WorkWindow( NULL, WB_STDWORK )
- {
- Font aFont;
- aFont.ChangePitch( PITCH_FIXED );
- ChangeFont( aFont );
- }
-
- // --- WindowWithoutParent::Resize() -------------------------------
-
- void WindowWithoutParent::Resize()
- {
- Invalidate();
- }
-
- // --- WindowWithoutParent::Move() ---------------------------------
-
- void WindowWithoutParent::Move()
- {
- Invalidate();
- }
-
- // --- WindowWithoutParent::Paint() --------------------------------
-
- void WindowWithoutParent::Paint( const Rectangle& )
- {
- Point aPosition( GetPosPixel() );
- Point aScreenPosition( OutputToScreenPixel( Point( 0, 0 ) ) );
- Size aSize( GetSizePixel() );
- Size aOutputSize( GetOutputSizePixel() );
- String aOutStr;
-
- aOutStr = "Pos: ";
- aOutStr += aPosition.X();
- aOutStr += " , ";
- aOutStr += aPosition.Y();
- DrawText( Point( 0, 0 ), aOutStr );
-
- aOutStr = "Scr-Pos: ";
- aOutStr += aScreenPosition.X();
- aOutStr += " , ";
- aOutStr += aScreenPosition.Y();
- DrawText( Point( 0, TEXTY ), aOutStr );
-
- aOutStr = "Size: ";
- aOutStr += aSize.Width();
- aOutStr += " : ";
- aOutStr += aSize.Height();
- DrawText( Point( 0, 2*TEXTY ), aOutStr );
-
- aOutStr = "Out-Size: ";
- aOutStr += aOutputSize.Width();
- aOutStr += " : ";
- aOutStr += aOutputSize.Height();
- DrawText( Point( 0, 3*TEXTY ), aOutStr );
- }
-
- // --- ChildWindow::ChildWindow ------------------------------------
-
- ChildWindow::ChildWindow( Window* pParent ) :
- Window( pParent, WB_BORDER )
- {
- Font aFont;
- aFont.ChangePitch( PITCH_FIXED );
- ChangeFont( aFont );
- }
-
- // --- ChildWindow::Resize() ---------------------------------------
-
- void ChildWindow::Resize()
- {
- Invalidate();
- }
-
- // --- ChildWindow::Move() -----------------------------------------
-
- void ChildWindow::Move()
- {
- Invalidate();
- }
-
- // --- ChildWindow::Paint() ----------------------------------------
-
- void ChildWindow::Paint( const Rectangle& )
- {
- Point aPosition( GetPosPixel() );
- Point aScreenPosition( OutputToScreenPixel( Point( 0, 0 ) ) );
- Size aSize( GetSizePixel() );
- Size aOutputSize( GetOutputSizePixel() );
- String aOutStr;
-
- aOutStr = "Pos: ";
- aOutStr += aPosition.X();
- aOutStr += " , ";
- aOutStr += aPosition.Y();
- DrawText( Point( 0, 0 ), aOutStr );
-
- aOutStr = "Scr-Pos: ";
- aOutStr += aScreenPosition.X();
- aOutStr += " , ";
- aOutStr += aScreenPosition.Y();
- DrawText( Point( 0, TEXTY ), aOutStr );
-
- aOutStr = "Size: ";
- aOutStr += aSize.Width();
- aOutStr += " : ";
- aOutStr += aSize.Height();
- DrawText( Point( 0, 2*TEXTY ), aOutStr );
-
- aOutStr = "Out-Size: ";
- aOutStr += aOutputSize.Width();
- aOutStr += " : ";
- aOutStr += aOutputSize.Height();
- DrawText( Point( 0, 3*TEXTY ), aOutStr );
- }
-
- // --- MyWindow::MyWindow ------------------------------------------
-
- MyWindow::MyWindow() :
- WorkWindow( NULL, WB_APP | WB_STDWORK ),
- aWindowWithParent( this ),
- aWindowWithoutParent(),
- aChildWindow( this )
- {
- aChildWindow.ChangeSizePixel( Size( WINDOWX,WINDOWY ) );
- aChildWindow.ChangePosPixel( Point( 160,210 ) );
- aChildWindow.Show();
-
- aWindowWithParent.ChangeSizePixel( Size( WINDOWX,WINDOWY ) );
- aWindowWithParent.ChangePosPixel( Point( 305,30 ) );
- aWindowWithParent.SetText( "With Parent" );
- aWindowWithParent.Show();
-
- aWindowWithoutParent.ChangeSizePixel( Size( WINDOWX,WINDOWY ) );
- aWindowWithoutParent.ChangePosPixel( Point( 25,30 ) );
- aWindowWithoutParent.SetText( "Without Parent" );
- aWindowWithoutParent.Show();
-
- ChangeSizePixel( Size( 540, 400 ) );
- ChangePosPixel( Point( 0, 0 ) );
- SetText( "Application Window" );
- Show();
-
- aWindowWithoutParent.ToTop();
- }
-
- // --- MyWindow::Move() --------------------------------------------
-
- void MyWindow::Move()
- {
- aChildWindow.Invalidate();
- aWindowWithParent.Invalidate();
- aWindowWithoutParent.Invalidate();
- }
-
- // --- MyWindow::Resize() ------------------------------------------
-
- void MyWindow::Resize()
- {
- aChildWindow.Invalidate();
- aWindowWithParent.Invalidate();
- aWindowWithoutParent.Invalidate();
- }
-
- // --- MyApp::Main() -----------------------------------------------
-
- void MyApp::Main( int, char*[] )
- {
- MyWindow aWindow;
- Execute();
- }
-
- // --- aMyApp ------------------------------------------------------
-
- MyApp aMyApp;
-