home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * EXAMPLE2.CXX
- * (c) 1992 STAR DIVISION
- *******************************************************************/
-
- #include <sv.hxx>
- #include <dir.h>
- #include <stdlib.h>
- #include <string.h>
- #include <io.h>
- #include <fcntl.h>
-
- #define MID_DLGBOXEN 10
- #define MID_DLGMES 11
- #define MID_DLGINFO 12
- #define MID_DLGWARN 13
- #define MID_DLGERR 14
- #define MID_DLGQUERY 15
- #define MID_ANFANG 20
- #define MID_VOR 30
- #define MID_RUECK 40
- #define MID_ENDE 50
-
-
- #define TAXEDATEN "TAXEABDA.NAM"
-
- // --- class MyApp -------------------------------------------------
-
- class MyApp : public Application
- {
- public:
- virtual void Main( int, char*[] );
- };
-
- // --- class MyWin -------------------------------------------------
-
- class MyWin : public WorkWindow
- {
- private:
- char szTaxePfad [ MAXPATH ]; // Pfad auf Taxedatei
- int iOpened; // Flag : Datei ge÷ffnet
- int iTaxeFd; // Fieldescriptor
-
-
- public:
- MyWin();
-
- virtual BOOL Close();
-
- void Message( const String& rMessage );
- /*
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void MouseButtonUp( const MouseEvent& rMEvt );
- virtual void MouseMove( const MouseEvent& rMEvt );
- */
-
- long DialogSelect( Menu* pMenu );
- long OperationSelect( Menu* pMenu );
- };
-
- // --- MyWin::MyWin() ----------------------------------------------
-
- MyWin::MyWin() : WorkWindow( NULL, WB_STDWORK | WB_APP )
- {
- char *cp = getenv( "TAXEPATH" );
- if ( cp )
- {
- strcpy( szTaxePfad, cp );
- }
- else
- {
- Message( "Environmentvariable TAXEPATH nicht gesetzt" );
- Close(); // Window erst gar nicht anzeigen
- return;
- }
- iOpened = 0; // Default : Datei nicht ge÷ffnet
-
- strcat( szTaxePfad, TAXEDATEN ); // Dateiname jetzt vollstΣndig
- iTaxeFd = open( taxename, O_RDONLY | O_BINARY,
- S_IREAD | S_IWRITE );
-
- if ( iTaxeFd == -1 )
- {
- Message( "Fehler beim ╓ffnen der Taxedatei" );
- Close(); // Window erst gar nicht anzeigen
- return;
- }
- }
-
- // --- MyWin::Close() ----------------------------------------------
-
- BOOL MyWin::Close()
- {
- /*
- QueryBox aBox( this, WB_OK_CANCEL | WB_DEF_OK, "Exit Testprogramm" );
-
- if ( aBox.Execute() == RET_OK )
- return WorkWindow::Close();
- else
- return FALSE;
- */
- if ( iTaxeFd > 0 )
- close( iTaxeFd );
-
- return WorkWindow::Close();
-
- }
-
- // --- MyWin::Message() ----------------------------------------------
-
- void MyWin::Message( const String& rMessage )
- {
- InfoBox aInfoBox( this,
- rMessage );
- aInfoBox.Execute();
- }
-
-
- // --- MyWin::MouseButtonDown() ------------------------------------
-
- /*
- void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
- {
- CaptureMouse();
- aLastPoint = rMEvt.GetPosPixel();
- }
-
- // --- MyWin::MouseButtonUp() --------------------------------------
-
- void MyWin::MouseButtonUp( const MouseEvent& )
- {
- ReleaseMouse();
- }
-
- // --- MyWin::MouseMove() ------------------------------------------
-
- void MyWin::MouseMove( const MouseEvent& rMEvt )
- {
- if ( rMEvt.GetMode() == MOUSE_SIMPLEDRAG )
- {
- DrawLine( aLastPoint, rMEvt.GetPosPixel() );
- aLastPoint = rMEvt.GetPosPixel();
- }
- }
- */
-
- // --- MyWin::DialogSelect() ----------------------------------------
-
- long MyWin::DialogSelect( Menu* pMenu )
- {
- USHORT nItem;
- nItem = pMenu->GetCurItemId();
-
- switch ( nItem )
- {
- case MID_DLGMES:
- MessBox aMessBox( this,
- WinBits( WB_YES_NO_CANCEL ),
- "Message-Box",
- "Dies ist die Default-Message-Box\n"
- "aus der StarView-Klassenbibliothek" );
- switch( aMessBox.Execute() )
- {
- case RET_OK :
- ;
- break;
- }
- break;
-
- case MID_DLGINFO:
- InfoBox aInfoBox( this,
- "Dies ist die Default-Info-Box\n"
- "aus der StarView-Klassenbibliothek" );
- aInfoBox.Execute();
- break;
-
- case MID_DLGWARN:
- WarningBox aWarnBox( this,
- WinBits( WB_YES_NO_CANCEL ),
- "Dies ist die Default-Warning-Box\n"
- "aus der StarView-Klassenbibliothek" );
- switch( aWarnBox.Execute() )
- {
- case RET_OK :
- ;
- break;
- }
- break;
-
- case MID_DLGERR:
- ErrorBox aErrorBox( this,
- WinBits( WB_YES_NO_CANCEL ),
- "Dies ist die Default-Error-Box\n"
- "aus der StarView-Klassenbibliothek" );
- switch( aErrorBox.Execute() )
- {
- case RET_OK :
- ;
- break;
- }
- break;
-
- case MID_DLGQUERY:
- QueryBox aQueryBox( this,
- WB_OK_CANCEL | WB_DEF_OK,
- "Dies ist die Default-Query-Box\n"
- "aus der StarView-Klassenbibliothek" );
- aQueryBox.Execute();
- break;
- }
-
- return TRUE;
- }
-
- // --- MyWin::OperationSelect() ----------------------------------------
-
- long MyWin::OperationSelect( Menu* pMenu )
- {
- USHORT nItem;
- nItem = pMenu->GetCurItemId();
-
- Message( pMenu->GetItemText( nItem ) );
-
- switch ( nItem )
- {
- case MID_ANFANG:
- break;
- case MID_VOR:
- break;
- case MID_RUECK:
- break;
- case MID_ENDE:
- break;
- }
- return TRUE;
- }
-
- // --- MyApp::Main() -----------------------------------------------
-
- void MyApp::Main( int, char*[] )
- {
- MyWin aMainWin;
-
- PopupMenu aDialogMenu;
- MenuBar aMenuBar;
-
- aMenuBar.InsertItem( MID_DLGBOXEN, "~Dialogboxen" );
- aMenuBar.InsertItem( MID_ANFANG, "~Anfang" );
- aMenuBar.InsertItem( MID_VOR, "~Vor" );
- aMenuBar.InsertItem( MID_RUECK, "~Rⁿck" );
- aMenuBar.InsertItem( MID_ENDE, "~Ende" );
-
- aMenuBar.ChangePopupMenu( MID_DLGBOXEN, &aDialogMenu );
-
- aDialogMenu.InsertItem( MID_DLGMES, "~Message" );
- aDialogMenu.InsertItem( MID_DLGINFO, "~Info" );
- aDialogMenu.InsertItem( MID_DLGWARN, "~Warning" );
- aDialogMenu.InsertItem( MID_DLGERR, "~Error" );
- aDialogMenu.InsertItem( MID_DLGQUERY, "~Query" );
-
-
- aDialogMenu.PushSelectHdl( LINK( &aMainWin,
- MyWin::DialogSelect ) );
-
- aMenuBar.PushSelectHdl( LINK( &aMainWin,
- MyWin::OperationSelect ) );
-
- ChangeAppMenu( &aMenuBar );
-
- aMainWin.SetText( "2.Beipiel mit StarView ( EXAMPLE2 )" );
- aMainWin.Show();
-
- // aMainWin.Minimize(); // minimieren
-
- Execute();
- }
-
- // --- aMyApp ------------------------------------------------------
-
- MyApp aMyApp;
-
- #ifdef MAC
- Application* pApp = &aMyApp;
- #endif
-