diff --git a/GDE_3_2008/Console/Console.cpp b/GDE_3_2008/Console/Console.cpp new file mode 100644 index 0000000..e853960 --- /dev/null +++ b/GDE_3_2008/Console/Console.cpp @@ -0,0 +1,479 @@ +/* file:Console.cpp +Creator : Girish Bharadwaj. +Desc:This class will contain all the stuff we need from the +Console.Following is the list I can think of 1. Create a new console and +use it to Write and read console. This will be using AllocConsole +(),WriteConsole() and ReadConsole (). This will be via the win32 APIs. + +2. Use the scanf ,printf,cout ,cin and cerr ( this will be using the CRT +functionality.) Using the WDJ technique given there by Andrew Tucker & +using the KB "How to Spawn a Console App and Redirect Standard Handles" +Article ID: Q126628. + +3. Redirect the output from a console app to a windows GUI app. ( +"Redirection Issues on Windows 95 MS-DOS Apps and Batch Files" Article +ID: Q150956).This will be the fun part. What I would like to see is to +provide an API which takes the console process name as the argument. +That will redirect the stuff to a CString.. which can be read by the +creator. + +4. I am also planning to do a somesort of poor man's debugger.i.e. You +will have an API similar to scanf which takes the input from the user at +run time with a default value to fall back to after sometime specified +by u. if you want to change a particular variable and see the effect, +You can use this. +*/ + +#include "stdafx.h" +#include +#include +#include +#include +#include +#include "console.h" + +#include +#include + +#include "..\graphics\shape.h" +#include "..\graphics\pointerarray.h" +#include "..\gde_3.h" +#ifndef _USE_OLD_IOSTREAMS +using namespace std; +#endif + + +#pragma warning( disable : 4311 )//Warning handle to long conversion disabled +#pragma warning( disable : 4312 )//Warning handle to long conversion disabled + + +extern CGDE_3App theApp; + +void printwindata(); + +BOOL CConsole::sm_bConsole = FALSE; +////////////////////////////////////////////////////////////////////////////// +CConsole::CConsole() + { + //default constructor. + m_bRedirected = FALSE; // this is the right place to set this before this + m_sNumColumns = 0; + m_sNumLines = 0; + m_sMaxLines = 0; + m_sMaxColumns = 0; + m_wAttrib = 0; + } +////////////////////////////////////////////////////////////////////////////// + +CConsole::CConsole(BOOL bCreateConsole) + { + m_bRedirected = FALSE; // this is the right place to set this before this + m_sNumColumns = 0; + m_sNumLines = 0; + m_sMaxLines = 0; + m_sMaxColumns = 0; + m_wAttrib = 0; + if (bCreateConsole) + CreateConsole (); + //I dont see any reason for not having bCreateConsole false But eh + } + +////////////////////////////////////////////////////////////////////////////// + +CConsole::~CConsole() + { + DestroyConsole (); //We need to remove the Console + } +////////////////////////////////////////////////////////////////////////////// + +BOOL CConsole::CreateConsole () + { + if (sm_bConsole == TRUE) // we have already created a console + { + return FALSE; + } + // I am not allocating the console if there is already one. + + if (!AllocConsole ()) //Just call the Console allocation API + { + sm_bConsole = FALSE; + m_dwError = GetLastError (); //Lets get the error and store it away. + return FALSE; + } + else + { + sm_bConsole = TRUE; //To make sure we wont allocate again + //Lets keep all the stuff around + m_sNumLines = (short)GetSettings (SC_LINES); + m_sNumColumns = (short)GetSettings (SC_COLUMNS); + m_sMaxLines = 70;//(short) GetSettings (SC_MAXLINES); + m_sMaxColumns = (short) GetSettings (SC_MAXCOLUMNS); + m_wAttrib = GetSettings (SC_ATTRIB); + m_dwError = 0; // Lets keep this zero for the time being. + return TRUE; + } + + } +////////////////////////////////////////////////////////////////////////////// + +BOOL CConsole::DestroyConsole () + { + if (sm_bConsole == FALSE) //There is no console to destroy + return TRUE; //as Well return asif we deleted + if (!FreeConsole ()) + { + sm_bConsole = TRUE; + m_dwError = GetLastError ();//Lets keep the error here if someone wants + return FALSE; + } + else + { + sm_bConsole = FALSE; + return TRUE; + } + } +////////////////////////////////////////////////////////////////////////////// +short CConsole::GetNumberOfLines() + { + return (short) GetSettings (SC_LINES); + } +////////////////////////////////////////////////////////////////////////////// + +short CConsole::SetNumberOfLines (short sLines) + { + if(CONSOLE_DEBUG)printf("SetNumberOfLines to %d\n",sLines); + short sRes = m_sNumLines; + m_sNumLines = sLines; + SetupConsole (SC_LINES); + Sleep(100); + return sRes; + } +////////////////////////////////////////////////////////////////////////////// + +short CConsole::SetNumberOfColumns (short sColumns) + { + if(CONSOLE_DEBUG)printf("SetNumberOfColumns to %d\n",sColumns); + short sOld = m_sNumColumns; + m_sNumColumns = sColumns; + SetupConsole (SC_COLUMNS); + return sOld; + } +////////////////////////////////////////////////////////////////////////////// + +short CConsole::GetNumberOfColumns () + { + return (short)GetSettings (SC_COLUMNS); + } +////////////////////////////////////////////////////////////////////////////// + +WORD CConsole::GetAttributes () + { + return (short) GetSettings (SC_ATTRIB); + } +////////////////////////////////////////////////////////////////////////////// +WORD CConsole::SetAttributes (WORD wAttrib, short NumChars) + { + WORD wOld = m_wAttrib; + m_wAttrib = wAttrib; + SetupConsole (SC_ATTRIB); + ApplyAttrib(NumChars); + return wOld; + } +////////////////////////////////////////////////////////////////////////////// +short CConsole::SetMaxLinesInWindow (short maxLines) + { + if(CONSOLE_DEBUG)printf("SetMaxLinesInWindow to %d\n",maxLines); + + short sOld = m_sMaxLines; + m_sMaxLines = maxLines; + SetupConsole (SC_MAXLINES); + return sOld; + } +////////////////////////////////////////////////////////////////////////////// +short CConsole::GetMaxLinesInWindow () + { + return (short) GetSettings (SC_MAXLINES); + } +////////////////////////////////////////////////////////////////////////////// +short CConsole::SetMaxColumnsInWindow (short maxColumns) + { + if(CONSOLE_DEBUG)printf("SetMaxColumnsInWindow to %d\n",maxColumns); + + short sOld = m_sMaxColumns; + m_sMaxColumns = maxColumns; + SetupConsole (SC_MAXCOLUMNS); + return sOld; + } +////////////////////////////////////////////////////////////////////////////// +short CConsole::GetMaxColumnsInWindow () + { + return (short) GetSettings (SC_MAXCOLUMNS); + } +////////////////////////////////////////////////////////////////////////////// + +//Now here we have the basic beginning traits of a CConsole. +//But it has to do more than Allocing and Freeing consoles. +//So here it is.. + + +void CConsole::RedirectToConsole (WORD wFlags) + { + int hConHandle; + long lStdHandle; + HANDLE nStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + FILE *fp; + + // Create the Console + CreateConsole(); + nStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); + lStdHandle = (long)nStdHandle; + + // set the screen buffer to be big enough to let us scroll text + GetConsoleScreenBufferInfo(nStdHandle,&coninfo); + SetupConsole (SC_COLUMNS|SC_LINES|SC_ATTRIB|SC_MAXLINES|SC_MAXCOLUMNS); + + // redirect unbuffered STDOUT to the console + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + + // redirect unbuffered STDIN to the console + nStdHandle = GetStdHandle(STD_INPUT_HANDLE); + lStdHandle = (long)nStdHandle; + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "r" ); + *stdin = *fp; + setvbuf( stdin, NULL, _IONBF, 0 ); + + // redirect unbuffered STDERR to the console + lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stderr = *fp; + setvbuf( stderr, NULL, _IONBF, 0 ); + // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog + // point to console as well + ios::sync_with_stdio(); + m_bRedirected = TRUE; //Whether the Console is redirected +} + +////////////////////////////////////////////////////////////////////////////// +/* +This will be function which will actually set up the console to the user +settings. +*/ +BOOL CConsole::SetupConsole(WORD wFlags) + { + HANDLE nStdHandle; + long lStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + + if (!sm_bConsole) + return FALSE; // There aint no console to set up, Duh + nStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); + lStdHandle = (long)nStdHandle; + // set the screen buffer to be big enough to let us scroll text + if(!GetConsoleScreenBufferInfo(nStdHandle,&coninfo)){ + if(CONSOLE_DEBUG)printf("***Error*** GetConsoleScreenBufferInfo failed\n"); + if(CONSOLE_DEBUG)printwindata(); + } + if(CONSOLE_DEBUG) printf("BBB: \n"); + if(CONSOLE_DEBUG) printwindata(); + if (wFlags & SC_COLUMNS || wFlags & SC_LINES) //Set up only the columns + { + if(CONSOLE_DEBUG)printf("Either SC_COLUMNS or SC_LINES set m_sNumColumns to %d and m_sNumLines to %d\n", + m_sNumColumns,m_sNumLines); + //Number of Columns to be set + if (m_sNumColumns) + coninfo.dwSize.X = m_sNumColumns; + // number of lines to be set + if (m_sNumLines){ + coninfo.dwSize.Y = m_sNumLines; + } + + //Set the screen buffer size + if(!SetConsoleScreenBufferSize(nStdHandle,coninfo.dwSize)){ + + printf("***Error*** SetConsoleScreenBufferSize failed\n"); + printwindata(); + }; + + } + if (wFlags & SC_ATTRIB) + { + //Attributes as specified + if(CONSOLE_DEBUG)printf("SC_ATTRIB\n"); + if (m_wAttrib) + coninfo.wAttributes = m_wAttrib; + //Set the Text attributes + if(!SetConsoleTextAttribute (nStdHandle,coninfo.wAttributes)){ + printf("***Error*** SetConsoleTextAttribute failed\n"); + printwindata(); + } + } + + if (wFlags & SC_MAXLINES || wFlags & SC_MAXCOLUMNS) + { + if(CONSOLE_DEBUG) printf("SC_MAXLINES: %d;SC_MAXCOLUMNS: %d\n",m_sMaxLines,m_sMaxColumns); + SMALL_RECT rect; + + //Maximum Size of the window + if (m_sMaxLines) + rect.Bottom= m_sMaxLines; + else + rect.Bottom = coninfo.dwMaximumWindowSize.Y; + + if (m_sMaxColumns) + rect.Right = m_sMaxColumns; + else + rect.Right = coninfo.dwMaximumWindowSize.X; + // if (m_sNumColumns) + // rect.Right = m_sNumColumns; + // else + // rect.Right = coninfo.dwMaximumWindowSize.X; + rect.Top = rect.Left = 0; + + //Set the console window maximum size + if(!SetConsoleWindowInfo (nStdHandle,TRUE,&rect)){ + DWORD lasterr = GetLastError(); + printf("lasterr: %d\n",lasterr); + + printf("***Error*** SetConsoleWindowInfo failed\n"); + printwindata(); + } + } + if(CONSOLE_DEBUG) printf("AAA: \n"); + if(CONSOLE_DEBUG) printwindata(); + return TRUE; + + } +////////////////////////////////////////////////////////////////////////////// + +HANDLE CConsole::GetHandle (DWORD dwFlag) + { + if (!sm_bConsole) + return (HANDLE) NULL; + return GetStdHandle (dwFlag); + } +////////////////////////////////////////////////////////////////////////////// + +BOOL CConsole::Clear () + { + COORD coordScreen = { 0, 0 }; /* here's where we'll home the + cursor */ + BOOL bSuccess; + DWORD cCharsWritten; + CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ + DWORD dwConSize; /* number of character cells in + the current buffer */ + + if (!sm_bConsole) + return FALSE; + HANDLE hConsole = GetHandle (STD_OUTPUT_HANDLE); + + /* get the number of character cells in the current buffer */ + + + bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); + dwConSize = csbi.dwSize.X * csbi.dwSize.Y; + if (!bSuccess) return bSuccess; + + /* fill the entire screen with blanks */ + + bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', + dwConSize, coordScreen, &cCharsWritten ); + if (!bSuccess) return bSuccess; + + /* get the current text attribute */ + + bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); + if (!bSuccess) return bSuccess; + + /* now set the buffer's attributes accordingly */ + + bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, + dwConSize, coordScreen, &cCharsWritten ); + if (!bSuccess) return bSuccess; + + /* put the cursor at (0, 0) */ + + bSuccess = SetConsoleCursorPosition( hConsole, coordScreen ); + if (!bSuccess) return bSuccess; + return TRUE; + } +////////////////////////////////////////////////////////////////////////////// + +BOOL CConsole::ApplyAttrib (short NumChars) + { + COORD coordScreen = { 0, 0 }; /* here's where we'll home the + cursor */ + BOOL bSuccess; + DWORD cCharsWritten; + CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ + DWORD dwConSize; /* number of character cells in + the current buffer */ + if (!sm_bConsole) + return FALSE; + HANDLE hConsole = GetHandle (STD_OUTPUT_HANDLE); + bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); + if(!bSuccess) + printf("***Error*** GetConsoleScreenBufferInfo failed\n"); + if (!bSuccess) return bSuccess; + + dwConSize = csbi.dwSize.X * csbi.dwSize.Y; + bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, + NumChars?NumChars:dwConSize, csbi.dwCursorPosition, &cCharsWritten ); + + return bSuccess; + } +////////////////////////////////////////////////////////////////////////////// + +WORD CConsole::GetSettings (WORD wFlags) + { + long lStdHandle; + HANDLE nStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + + if (!sm_bConsole) + return FALSE; // There aint no console to set up, Duh + nStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); + lStdHandle = (long)nStdHandle; + // set the screen buffer to be big enough to let us scroll text + GetConsoleScreenBufferInfo(nStdHandle,&coninfo); + if(!GetConsoleScreenBufferInfo(nStdHandle,&coninfo)) + printf("***Error*** GetConsoleScreenBufferInfo failed\n"); + + switch (wFlags) + { + case SC_ATTRIB: + return coninfo.wAttributes; + break; + case SC_LINES: + return coninfo.dwSize.Y; + break; + case SC_COLUMNS: + return coninfo.dwSize.X; + break; + case SC_MAXLINES: + return coninfo.dwMaximumWindowSize.Y; + break; + case SC_MAXCOLUMNS: + return coninfo.dwMaximumWindowSize.X; + break; + default: + printf("***Error*** Wrong case label in GetSettings\n"); + printwindata(); + } + return 0; + } +////////////////////////////////////////////////////////////////////////////// + +void CConsole::printwindata() +{ + printf ("NumLines:%d,Columns:%d,Attributes:%d,MaxLines:%d,MaxColumns:%d\n", + GetNumberOfLines(),GetNumberOfColumns (), GetAttributes(), + GetMaxLinesInWindow(),GetMaxColumnsInWindow()); + +} diff --git a/GDE_3_2008/Console/Console.h b/GDE_3_2008/Console/Console.h new file mode 100644 index 0000000..6fd3635 --- /dev/null +++ b/GDE_3_2008/Console/Console.h @@ -0,0 +1,61 @@ +#ifndef __CONSOLE_H__ +#define __CONSOLE_H__ + + + +//Some defines we will be requiring +#define SC_LINES 0x0001 +#define SC_COLUMNS 0x0002 +#define SC_ATTRIB 0x0004 +#define SC_MAXLINES 0x0008 +#define SC_MAXCOLUMNS 0x0010 + + +#define CONSOLE_DEBUG 0 + +class CConsole +{ + public: + //Constructor & Destructor + CConsole (); + CConsole (BOOL); + ~CConsole (); + + //Properties + short GetNumberOfLines(); + short SetNumberOfLines (short sLines); + short SetNumberOfColumns (short sColumns); + short GetNumberOfColumns (); + WORD GetAttributes (); + WORD SetAttributes (WORD wAttrib,short NumChars = 0); + short SetMaxLinesInWindow (short maxLines); + short GetMaxLinesInWindow (); + short SetMaxColumnsInWindow (short maxLines); + short GetMaxColumnsInWindow (); + + //Methods + void RedirectToConsole (WORD wFlags); + BOOL SetupConsole(WORD wFlags); + HANDLE GetHandle (DWORD dwFlag); + BOOL Clear (); + BOOL ApplyAttrib (short NumChars); + WORD GetSettings (WORD wFlags); + void printwindata(); + + protected: + + //Helpers + BOOL CreateConsole (); + BOOL DestroyConsole (); + + BOOL m_bRedirected; + short m_sNumColumns; + short m_sNumLines; + WORD m_wAttrib; + short m_sMaxLines; + short m_sMaxColumns; + DWORD m_dwError; + static BOOL sm_bConsole; + +}; +#endif //__CONSOLE_H__ diff --git a/GDE_3_2008/Cparser.cpp b/GDE_3_2008/Cparser.cpp new file mode 100644 index 0000000..9e4d6a6 --- /dev/null +++ b/GDE_3_2008/Cparser.cpp @@ -0,0 +1,77 @@ +#include +#include +#include +#include "stdafx.h" + +#include "Cparser.h" + +using namespace std; + +#define Getc(s) getc(s) +#define Ungetc(c) ungetc(c,IP_Input) + +/* Lexical analyser states. */ + +enum lexstate{L_START,L_INT,L_IDENT}; + + +int Cparser::yylex(){ + int c; + lexstate s; + + for(s=L_START, yytext="";1;){ + c= Getc(IP_Input); + yytext=yytext+(char)c; + switch (s){ + + case L_START: + if(isdigit(c)){ + if((char)c!='x'){ + s=L_INT; + }else{ + Ungetc(c); + yytext=yytext.substr(0,yytext.size()-1); + yytext1+='1'; + yytext+='0';// ab hier gut überlegen falls x auftritte + + + break; + } + }else if (isspace(c)||isalpha(c)){ + s=L_IDENT; + }else if(c==EOF){ + return 0; + }else if (c=='\n'){ LineNumber+=1; + }else { return 0; + } + break; + + case L_INT: + if(isdigit(c)){ break; + }else { + Ungetc(c); + yylval.s=yytext.substr(0,yytext.size()-1); + } + + break; + case L_IDENT: + if(isalpha(c)){ + yylval.s=yytext.substr(0,yytext.size()-1); + yylval.i=atoi(yylval.s.c_str()); + yytext=""; + } + break; + + default: + printf("*** Fatal Error!!!!!*** Wrong case label in yylex\n"); + + + + } + + } +} + + + + diff --git a/GDE_3_2008/Cparser.h b/GDE_3_2008/Cparser.h new file mode 100644 index 0000000..fbefa86 --- /dev/null +++ b/GDE_3_2008/Cparser.h @@ -0,0 +1,49 @@ +#ifndef CPARSER +#define CPARSER + +#include +#include "PrimImplikanten.h" + +using namespace std; + + +class Cparser{ +private: + + PrimImplikant implikant; + +public: + string yytext; + string yytext1; + int LineNumber; + + struct tyylval{ + string s; + int i; + }yylval; + + FILE* IP_Input; + void pr_tokentable(); + void load_tokenentry(string s ,int x); + int yylex(); + + +}; + + + + + + + + + + + + + + + + + +#endif diff --git a/GDE_3_2008/GDE_3.cpp b/GDE_3_2008/GDE_3.cpp new file mode 100644 index 0000000..fd08009 --- /dev/null +++ b/GDE_3_2008/GDE_3.cpp @@ -0,0 +1,172 @@ +// GDE_3.cpp : Definiert das Klassenverhalten für die Anwendung. +// + +#include "stdafx.h" +#include "console\console.h" +#include "GDE_3.h" +#include "MainFrm.h" + +#include "GDE_3Doc.h" +#include "GDE_3View.h" +#include ".\gde_3.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CGDE_3App + +BEGIN_MESSAGE_MAP(CGDE_3App, CWinApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // Dateibasierte Standarddokumentbefehle + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standarddruckbefehl "Seite einrichten" + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) + ON_COMMAND(ID_APP_EXIT, OnAppExit) + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) +END_MESSAGE_MAP() + + +// CGDE_3App-Erstellung + +CGDE_3App::CGDE_3App() +{ + // TODO: Hier Code zur Konstruktion einfügen + // Alle wichtigen Initialisierungen in InitInstance positionieren + m_stopflag=FALSE; +} + + +// Das einzige CGDE_3App-Objekt + +CGDE_3App theApp; +///////////////////////////////////////////////////////////////////////////// +/*Console object*/ +CConsole con(TRUE); +// Dieser thread startet die Funktion main(), in der Benutzer seinen Code hat. +UINT StartGDE(LPVOID lpv) +{ + extern void user_main(); + user_main(); + theApp.vw->uthread=NULL; + return TRUE; +} + +// CGDE_3App Initialisierung + +BOOL CGDE_3App::InitInstance() +{ + // InitCommonControls() ist für Windows XP erforderlich, wenn ein Anwendungsmanifest + // die Verwendung von ComCtl32.dll Version 6 oder höher zum Aktivieren + // von visuellen Stilen angibt. Ansonsten treten beim Erstellen von Fenstern Fehler auf. + InitCommonControls(); + + CWinApp::InitInstance(); + + // OLE-Bibliotheken initialisieren + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + // Standardinitialisierung + // Wenn Sie diese Features nicht verwenden und die Größe + // der ausführbaren Datei verringern möchten, entfernen Sie + // die nicht erforderlichen Initialisierungsroutinen. + // Ändern Sie den Registrierungsschlüssel unter dem Ihre Einstellungen gespeichert sind. + // TODO: Ändern Sie diese Zeichenfolge entsprechend, + // z.B. zum Namen Ihrer Firma oder Organisation. + SetRegistryKey(_T("GDE3")); + LoadStdProfileSettings(16); // Standard INI-Dateioptionen laden (einschließlich MRU) + // Dokumentvorlagen der Anwendung registrieren. Dokumentvorlagen + // dienen als Verbindung zwischen Dokumenten, Rahmenfenstern und Ansichten. + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CGDE_3Doc), + RUNTIME_CLASS(CMainFrame), // Haupt-SDI-Rahmenfenster + RUNTIME_CLASS(CGDE_3View)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + // Befehlszeile parsen, um zu prüfen auf Standardumgebungsbefehle DDE, Datei offen + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + // Verteilung der in der Befehlszeile angegebenen Befehle. Es wird FALSE zurückgegeben, wenn + // die Anwendung mit /RegServer, /Register, /Unregserver oder /Unregister gestartet wurde. + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + // Das einzige Fenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden. + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + // Rufen Sie DragAcceptFiles nur auf, wenn eine Suffix vorhanden ist. + // In einer SDI-Anwendung ist dies nach ProcessShellCommand erforderlich + + /*Console start*/ + con.RedirectToConsole(0); + con.SetNumberOfColumns (120); + Sleep(10); + con.SetNumberOfLines (2500); + Sleep(10); + /*Console end*/ + + return TRUE; +} + + + +// CAboutDlg-Dialogfeld für Anwendungsbefehl 'Info' + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialogfelddaten + enum { IDD = IDD_ABOUTBOX }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterstützung + +// Implementierung +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) +END_MESSAGE_MAP() + +// Anwendungsbefehl zum Ausführen des Dialogfelds +void CGDE_3App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + + +// CGDE_3App Meldungshandler + + +void CGDE_3App::OnAppExit() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. + + +} + +void CGDE_3App::OnFileOpen() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. +} diff --git a/GDE_3_2008/GDE_3.h b/GDE_3_2008/GDE_3.h new file mode 100644 index 0000000..822ac76 --- /dev/null +++ b/GDE_3_2008/GDE_3.h @@ -0,0 +1,39 @@ +// GDE_3.h : Hauptheaderdatei für die GDE_3-Anwendung +// +#ifndef _GDE_3_H +#define _GDE_3_H +#pragma once + +#ifndef __AFXWIN_H__ + #error 'stdafx.h' muss vor dieser Datei in PCH eingeschlossen werden. +#endif + +#include "resource.h" // Hauptsymbole + + +// CGDE_3App: +// Siehe GDE_3.cpp für die Implementierung dieser Klasse +// +class CGDE_3View; + +class CGDE_3App : public CWinApp +{ +public: + CGDE_3App(); + CGDE_3View *vw; //actual view + BOOL m_stopflag; + + +// Überschreibungen +public: + virtual BOOL InitInstance(); + +// Implementierung + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() + afx_msg void OnAppExit(); + afx_msg void OnFileOpen(); +}; + +extern CGDE_3App theApp; +#endif \ No newline at end of file diff --git a/GDE_3_2008/GDE_3.rc b/GDE_3_2008/GDE_3.rc new file mode 100644 index 0000000..6cf8630 --- /dev/null +++ b/GDE_3_2008/GDE_3.rc @@ -0,0 +1,396 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)\r\n" + "LANGUAGE 7, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\GDE_3.rc2"" // Nicht mit Microsoft Visual C++ bearbeitete Ressourcen\r\n" + "#include ""afxres.rc"" // Standardkomponenten\r\n" + "#include ""afxprint.rc"" // Ressourcen für Drucken/Seitenansicht\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\GDE_3.ico" +IDR_GDE_3TYPE ICON "res\\GDE_3Doc.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_FILE_PRINT + BUTTON ID_APP_ABOUT + SEPARATOR + BUTTON ID_BUTTONZOOMOUT + BUTTON ID_BUTTONZOOMIN + BUTTON ID_BUTTONZOOMFIT + BUTTON ID_STARTBUTTON + BUTTON ID_STOPBUTTON +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&Datei" + BEGIN + MENUITEM "&Neu\tStrg+N", ID_FILE_NEW + MENUITEM "Ö&ffnen...\tStrg+O", ID_FILE_OPEN + MENUITEM "&Speichern\tStrg+S", ID_FILE_SAVE + MENUITEM "Speichern &unter...", ID_FILE_SAVE_AS + MENUITEM SEPARATOR + MENUITEM "&Drucken...\tStrg+P", ID_FILE_PRINT + MENUITEM "&Seitenansicht", ID_FILE_PRINT_PREVIEW + MENUITEM "Dru&ckeinrichtung...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Letzte Datei", ID_FILE_MRU_FILE1, GRAYED + MENUITEM SEPARATOR + MENUITEM "&Beenden", ID_APP_EXIT + END + POPUP "&Bearbeiten" + BEGIN + MENUITEM "&Rückgängig\tStrg+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "&Ausschneiden\tStrg+X", ID_EDIT_CUT + MENUITEM "&Kopieren\tStrg+C", ID_EDIT_COPY + MENUITEM "&Einfügen\tStrg+V", ID_EDIT_PASTE + END + POPUP "&Ansicht" + BEGIN + MENUITEM "&Symbolleiste", ID_VIEW_TOOLBAR + MENUITEM "Status&leiste", ID_VIEW_STATUS_BAR + END + POPUP "&Hilfe" + BEGIN + MENUITEM "&Info über GDE_3...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "N", ID_FILE_NEW, VIRTKEY, CONTROL + "O", ID_FILE_OPEN, VIRTKEY, CONTROL + "S", ID_FILE_SAVE, VIRTKEY, CONTROL + "P", ID_FILE_PRINT, VIRTKEY, CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL + "X", ID_EDIT_CUT, VIRTKEY, CONTROL + "C", ID_EDIT_COPY, VIRTKEY, CONTROL + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | + WS_SYSMENU +CAPTION "Info über GDE_3" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "GDE_3 Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2007",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040704e4" + BEGIN + VALUE "CompanyName", "TODO: " + VALUE "FileDescription", "TODO: " + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "GDE_3.exe" + VALUE "Copyright (C) 2007", "TODO: (c) . Alle Rechte vorbehalten." + VALUE "OriginalFilename", "GDE_3.exe" + VALUE "ProductName", "TODO: " + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x407, 1252 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDR_MAINFRAME "GDE_3\n\nGDE_3\n\n\nGDE3.Document\nGDE_3.Document" +END + +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "GDE_3" + AFX_IDS_IDLEMESSAGE "Bereit" +END + +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "ER" + ID_INDICATOR_CURPOS "x,y " + ID_INDICATOR_CAPS "UF" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "RF" + ID_INDICATOR_OVR "ÜB" + ID_INDICATOR_REC "MA" +END + +STRINGTABLE +BEGIN + ID_FILE_NEW "Erstellt ein neues Dokument.\nNeu" + ID_FILE_OPEN "Öffnet ein vorhandenes Dokument.\nÖffnen" + ID_FILE_CLOSE "Schließt das aktive Dokument.\nSchließen" + ID_FILE_SAVE "Speichert das aktive Dokument.\nSpeichern" + ID_FILE_SAVE_AS "Speichert das aktive Dokument unter einem neuem Namen.\nSpeichern unter" + ID_FILE_PAGE_SETUP "Ändert die Druckoptionen.\nSeite einrichten" + ID_FILE_PRINT_SETUP "Ändert den Drucker und die Druckoptionen.\nDruckereinrichtung" + ID_FILE_PRINT "Druckt das aktive Dokument.\nDrucken" + ID_FILE_PRINT_PREVIEW "Zeigt ganze Seiten an.\nSeitenansicht" +END + +STRINGTABLE +BEGIN + ID_APP_ABOUT "Zeigt Programm-, Versions- und Copyrightinformationen an.\nInfo" + ID_APP_EXIT "Beendet die Anwendung und fordert zum Speichern der Dokumente auf.\nBeenden" +END + +STRINGTABLE +BEGIN + ID_FILE_MRU_FILE1 "Öffnet das Dokument." + ID_FILE_MRU_FILE2 "Öffnet das Dokument." + ID_FILE_MRU_FILE3 "Öffnet das Dokument." + ID_FILE_MRU_FILE4 "Öffnet das Dokument." + ID_FILE_MRU_FILE5 "Öffnet das Dokument." + ID_FILE_MRU_FILE6 "Öffnet das Dokument." + ID_FILE_MRU_FILE7 "Öffnet das Dokument." + ID_FILE_MRU_FILE8 "Öffnet das Dokument." + ID_FILE_MRU_FILE9 "Öffnet das Dokument." + ID_FILE_MRU_FILE10 "Öffnet das Dokument." + ID_FILE_MRU_FILE11 "Öffnet das Dokument." + ID_FILE_MRU_FILE12 "Öffnet das Dokument." + ID_FILE_MRU_FILE13 "Öffnet das Dokument." + ID_FILE_MRU_FILE14 "Öffnet das Dokument." + ID_FILE_MRU_FILE15 "Öffnet das Dokument." + ID_FILE_MRU_FILE16 "Öffnet das Dokument." +END + +STRINGTABLE +BEGIN + ID_NEXT_PANE "Wechselt zum nächsten Fensterbereich.\nNächster Bereich" + ID_PREV_PANE "Wechselt zum vorherigen Fensterbereich.\nVorheriger Bereich" +END + +STRINGTABLE +BEGIN + ID_WINDOW_SPLIT "Teilt das aktive Fenster in Bereiche.\nTeilen" +END + +STRINGTABLE +BEGIN + ID_EDIT_CLEAR "Löscht die Auswahl.\nLöschen" + ID_EDIT_CLEAR_ALL "Löscht alles.\nAlles löschen" + ID_EDIT_COPY "Kopiert die Auswahl in die Zwischenablage.\nKopieren" + ID_EDIT_CUT "Überträgt die Auswahl in die Zwischenablage.\nAusschneiden" + ID_EDIT_FIND "Sucht den angegebenen Text.\nSuchen" + ID_EDIT_PASTE "Fügt den Inhalt der Zwischenablage ein.\nEinfügen" + ID_EDIT_REPEAT "Wiederholt den letzten Vorgang.\nWiederholen" + ID_EDIT_REPLACE "Ersetzt den angegebenen Text.\nErsetzen" + ID_EDIT_SELECT_ALL "Markiert das gesamte Dokument.\nAlles auswählen" + ID_EDIT_UNDO "Macht den letzten Vorgang rückgängig.\nRückgängig" + ID_EDIT_REDO "Wiederholt den zuletzt rückgängig gemachten Vorgang.\nWiederherstellen" +END + +STRINGTABLE +BEGIN + ID_VIEW_TOOLBAR "Blendet die Symbolleiste ein oder aus.\nSymbolleiste" + ID_VIEW_STATUS_BAR "Blendet die Statusleiste ein oder aus.\nStatusleiste" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Ändert die Fenstergröße." + AFX_IDS_SCMOVE "Ändert die Position des Fensters." + AFX_IDS_SCMINIMIZE "Minimiert das Fenster." + AFX_IDS_SCMAXIMIZE "Maximiert das Fenster." + AFX_IDS_SCNEXTWINDOW "Wechselt zum nächsten Dokumentfenster." + AFX_IDS_SCPREVWINDOW "Wechselt zum vorherigen Dokumentfenster." + AFX_IDS_SCCLOSE "Schließt das aktive Fenster und fordert zum Speichern des Dokuments auf." +END + +STRINGTABLE +BEGIN + AFX_IDS_SCRESTORE "Stellt die ursprüngliche Fenstergröße wieder her." + AFX_IDS_SCTASKLIST "Aktiviert die Taskliste." +END + +STRINGTABLE +BEGIN + AFX_IDS_PREVIEW_CLOSE "Beendet die Seitenansicht.\nSeitenansicht beenden" +END + +STRINGTABLE +BEGIN + ID_BUTTONZOOMOUT "Zoom Out" + ID_BUTTONZOOMIN "Zoom In" + ID_BUTTONZOOMFIT "Originale Size" + ID_STARTBUTTON "Start the Application" + ID_STOPBUTTON "Stop the Application" +END + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +LANGUAGE 7, 1 +#pragma code_page(1252) +#include "res\GDE_3.rc2" // Nicht mit Microsoft Visual C++ bearbeitete Ressourcen +#include "afxres.rc" // Standardkomponenten +#include "afxprint.rc" // Ressourcen für Drucken/Seitenansicht +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/GDE_3_2008/GDE_3.sln b/GDE_3_2008/GDE_3.sln new file mode 100644 index 0000000..16c53eb --- /dev/null +++ b/GDE_3_2008/GDE_3.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GDE_3", "GDE_3.vcxproj", "{B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Debug|Win32.ActiveCfg = Debug|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Debug|Win32.Build.0 = Debug|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Release|Win32.ActiveCfg = Release|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GDE_3_2008/GDE_3.sln.old b/GDE_3_2008/GDE_3.sln.old new file mode 100644 index 0000000..b4747e7 --- /dev/null +++ b/GDE_3_2008/GDE_3.sln.old @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GDE_3", "GDE_3.vcproj", "{B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Debug|Win32.ActiveCfg = Debug|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Debug|Win32.Build.0 = Debug|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Release|Win32.ActiveCfg = Release|Win32 + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GDE_3_2008/GDE_3.suo.old b/GDE_3_2008/GDE_3.suo.old new file mode 100644 index 0000000..f98116a Binary files /dev/null and b/GDE_3_2008/GDE_3.suo.old differ diff --git a/GDE_3_2008/GDE_3.vcproj b/GDE_3_2008/GDE_3.vcproj new file mode 100644 index 0000000..2d675d7 --- /dev/null +++ b/GDE_3_2008/GDE_3.vcproj @@ -0,0 +1,375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GDE_3_2008/GDE_3.vcproj.8.00.old b/GDE_3_2008/GDE_3.vcproj.8.00.old new file mode 100644 index 0000000..16941a3 --- /dev/null +++ b/GDE_3_2008/GDE_3.vcproj.8.00.old @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GDE_3_2008/GDE_3.vcxproj b/GDE_3_2008/GDE_3.vcxproj new file mode 100644 index 0000000..2d36a10 --- /dev/null +++ b/GDE_3_2008/GDE_3.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Template + Win32 + + + + {B0DC7B0A-75D1-4BF6-9861-3C4056C4AA6B} + MFCProj + + + + Application + Static + MultiByte + + + Application + Static + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + Debug\ + Debug\ + true + Release\ + Release\ + false + + + + _DEBUG;%(PreprocessorDefinitions) + false + + + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + true + Use + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0407 + $(IntDir);%(AdditionalIncludeDirectories) + + + true + Windows + false + + + MachineX86 + + + + + NDEBUG;%(PreprocessorDefinitions) + false + + + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + false + MultiThreaded + true + Use + Level3 + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0407 + $(IntDir);%(AdditionalIncludeDirectories) + + + true + Windows + true + true + false + + + MachineX86 + + + + + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/GDE_3_2008/GDE_3.vcxproj.filters b/GDE_3_2008/GDE_3.vcxproj.filters new file mode 100644 index 0000000..608a703 --- /dev/null +++ b/GDE_3_2008/GDE_3.vcxproj.filters @@ -0,0 +1,137 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {1fd09ea8-21ab-4cb5-9115-9b0c2d0ff524} + + + {9be85dd5-64a4-4050-89fa-728d697c9169} + + + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Graphics + + + Graphics + + + Graphics + + + Console + + + Quelldateien + + + Quelldateien + + + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Graphics + + + Graphics + + + Graphics + + + Graphics + + + Graphics + + + Graphics + + + Console + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + + + Ressourcendateien + + + Ressourcendateien + + + Ressourcendateien + + + Ressourcendateien + + + + + + Ressourcendateien + + + + + + \ No newline at end of file diff --git a/GDE_3_2008/GDE_3Doc.cpp b/GDE_3_2008/GDE_3Doc.cpp new file mode 100644 index 0000000..1962acc --- /dev/null +++ b/GDE_3_2008/GDE_3Doc.cpp @@ -0,0 +1,83 @@ +// GDE_3Doc.cpp : Implementierung der Klasse CGDE_3Doc +// + +#include "stdafx.h" +#include "GDE_3.h" + +#include "GDE_3Doc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +extern WORD MAX_X; +extern WORD MAX_Y; + + +// CGDE_3Doc + +IMPLEMENT_DYNCREATE(CGDE_3Doc, CDocument) + +BEGIN_MESSAGE_MAP(CGDE_3Doc, CDocument) +END_MESSAGE_MAP() + + +// CGDE_3Doc Erstellung/Zerstörung + +CGDE_3Doc::CGDE_3Doc() +{ + // TODO: Hier Code für One-Time-Konstruktion einfügen + +} + +CGDE_3Doc::~CGDE_3Doc() +{ + aShape.RemoveAll(); // Das Array vollstaendig leeren. + +} + +BOOL CGDE_3Doc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: Hier Code zur Reinitialisierung einfügen + // (SDI-Dokumente verwenden dieses Dokument) + + return TRUE; +} + + + + +// CGDE_3Doc Serialisierung + +void CGDE_3Doc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: Hier Code zum Speichern einfügen + } + else + { + // TODO: Hier Code zum Laden einfügen + } +} + + +// CGDE_3Doc Diagnose + +#ifdef _DEBUG +void CGDE_3Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CGDE_3Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// CGDE_3Doc-Befehle diff --git a/GDE_3_2008/GDE_3Doc.h b/GDE_3_2008/GDE_3Doc.h new file mode 100644 index 0000000..44e027f --- /dev/null +++ b/GDE_3_2008/GDE_3Doc.h @@ -0,0 +1,50 @@ +// GDE_3Doc.h : Schnittstelle der Klasse CGDE_3Doc +// +#ifndef _GDE_3DOC_H +#define _GDE_3DOC_H + +#include "graphics\shape.h" +#include "graphics\pointerarray.h" +#include "graphics\dib.h" + +#pragma once + +class CGDE_3Doc : public CDocument +{ +protected: // Nur aus Serialisierung erstellen + CGDE_3Doc(); + DECLARE_DYNCREATE(CGDE_3Doc) + +// Attribute +public: + //gg CDib m_dib; + // Double buffering + CBitmap memoryBmp; // Bitmap im Speicher. + CDC buffer; // Geraetekontext-Objekt + int nShapePos; // Position des Grafikobjekts ab dem neu gezeichnet wird. + CPointerArray aShape; + +// Operationen +public: + +// Überschreibungen + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + +// Implementierung +public: + virtual ~CGDE_3Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generierte Funktionen für die Meldungstabellen +protected: + DECLARE_MESSAGE_MAP() +}; +#endif + diff --git a/GDE_3_2008/GDE_3View.cpp b/GDE_3_2008/GDE_3View.cpp new file mode 100644 index 0000000..f1e6ff2 --- /dev/null +++ b/GDE_3_2008/GDE_3View.cpp @@ -0,0 +1,433 @@ +// GDE_3View.cpp : Implementierung der Klasse CGDE_3View +// + +#include "stdafx.h" +#include "GDE_3.h" +#include "mainfrm.h" +#include "GDE_3Doc.h" +#include "GDE_3View.h" +#include ".\gde_3view.h" +#include "user.h" +#include "Wincon.h" +#include "Windows.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +extern WORD MAX_X; +extern WORD MAX_Y; + + +// CGDE_3View + +IMPLEMENT_DYNCREATE(CGDE_3View, CScrollView) + +BEGIN_MESSAGE_MAP(CGDE_3View, CScrollView) + // Standarddruckbefehle + ON_COMMAND(ID_STARTBUTTON, OnStartButton) + ON_COMMAND(ID_STOPBUTTON, OnStopButton) + ON_COMMAND(ID_BUTTONZOOMOUT, OnButtonzoomout) + ON_COMMAND(ID_BUTTONZOOMIN, OnButtonzoomin) + ON_COMMAND(ID_BUTTONZOOMFIT, OnButtonzoomfit) + ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) + ON_COMMAND(ID_FILE_SAVE, OnFileSave) + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_WM_RBUTTONDOWN() +// ON_WM_MOUSEACTIVATE() + ON_WM_MOUSEMOVE() + ON_WM_DESTROY() + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) + ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) + ON_COMMAND(ID_FILE_NEW, OnFileNew) +END_MESSAGE_MAP() + +// CGDE_3View Erstellung/Zerstörung + +CGDE_3View::CGDE_3View() +{ + // TODO: Hier Code zum Erstellen einfügen + m_fXScale = 1.0f; // zooming scale + m_fYScale = 1.0f; + m_fDelta = 1.2f; + m_nMapMode = MM_TEXT; + uthread = NULL; + +} + +CGDE_3View::~CGDE_3View() +{ +} + +BOOL CGDE_3View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Ändern Sie hier die Fensterklasse oder die Darstellung, indem Sie + // CREATESTRUCT cs modifizieren. + + return CScrollView::PreCreateWindow(cs); +} + +// CGDE_3View-Zeichnung + +void CGDE_3View::OnDraw(CDC* pDC) +{ + CGDE_3Doc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + // Das Array ab der vorgegebenen Position bis zum Ende durchlaufen... +// TRACE("CGDE_3View::OnDraw %d\n",pDoc->aShape.GetSize()); +// pDoc->nShapePos=0; +// for (; pDoc->nShapePosaShape.GetSize(); pDoc->nShapePos++) { +// pDoc->aShape[pDoc->nShapePos]->Draw(&pDoc->buffer); // ...und die Objekte Zeichnen. +// pDoc->aShape[pDoc->nShapePos]->Draw(pDC); // ...und die Objekte Zeichnen. +// } + + // TODO: Code zum Zeichnen der systemeigenen Daten hinzufügen + pDC->StretchBlt( 0, 0, (int)(MAX_X*m_fXScale), (int)(MAX_Y*m_fYScale), &pDoc->buffer, 0, 0, MAX_X, MAX_Y, SRCCOPY ); + +} + +void CGDE_3View::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + // TODO: Gesamte Größe dieser Ansicht berechnen + theApp.vw = this; // Pointer auf das aktuelle Window-Fenster speichern. + + // TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen + SetScrollSizes(MM_TEXT,CSize(MAX_X, MAX_Y)); + + CGDE_3Doc *pDoc = GetDocument(); + CDC *pdc=GetDC(); + pDoc->buffer.DeleteDC(); + if(!pDoc->buffer.CreateCompatibleDC(pdc)){ + AfxMessageBox("Cannot create buffer DC",MB_OK); + } + if(!(pDoc->memoryBmp.CreateCompatibleBitmap(pdc,MAX_X, MAX_Y))){ + AfxMessageBox("Cannot create Bitmap",MB_OK); + } + pDoc->buffer.SelectObject( &pDoc->memoryBmp ); // Das Speicher-Bitmap als Geraetekontext auswaehlen. + pDoc->nShapePos =0; + ReleaseDC(pdc); +} + + +// CGDE_3View drucken + +BOOL CGDE_3View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // Standardvorbereitung + return DoPreparePrinting(pInfo); +} + +void CGDE_3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: Zusätzliche Initialisierung vor dem Drucken hier einfügen +} + +void CGDE_3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: Bereinigung nach dem Drucken einfügen +} + + +// CGDE_3View Diagnose + +#ifdef _DEBUG +void CGDE_3View::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CGDE_3View::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} + +CGDE_3Doc* CGDE_3View::GetDocument() const // Nicht-Debugversion ist inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGDE_3Doc))); + return (CGDE_3Doc*)m_pDocument; +} +#endif //_DEBUG + + +// CGDE_3View Meldungshandler +void CGDE_3View::OnButtonzoomout() +{ + CSize size = GetTotalSize(); + CRect rect; + GetClientRect(rect); + int width = rect.Width(); + int height = rect.Height(); + if (size.cx <= rect.Width() && size.cy <= rect.Height()) + return; + + if (width < size.cx) + { + size.cx = (int)(size.cx / m_fDelta); + m_fXScale /= m_fDelta; + } + if (height < size.cy) + { + size.cy = (int)(size.cy / m_fDelta); + m_fYScale /= m_fDelta; + } + + if (size.cx <= rect.Width()) + { + size.cx = rect.Width(); + m_fXScale = 1.0f; + } + if (size.cy <= rect.Height()) + { + size.cy = rect.Height(); + m_fYScale = 1.0f; + } + + SetScrollSizes(m_nMapMode, size); + Invalidate(); + +} + +void CGDE_3View::OnButtonzoomin() +{ +// if (m_fXScale >= MAX_ZOOM_FACTOR && m_fYScale >= MAX_ZOOM_FACTOR) +// return; + + CSize size = GetTotalSize(); + size.cx = (int)(size.cx * m_fDelta); + size.cy = (int)(size.cy * m_fDelta); + m_fXScale *= m_fDelta; + m_fYScale *= m_fDelta; + + SetScrollSizes(m_nMapMode, size); + Invalidate(); + +} + +void CGDE_3View::OnButtonzoomfit() +{ + m_fXScale = 1.0; + m_fYScale = 1.0; + + SetScrollSizes(MM_TEXT, CSize(MAX_X,MAX_Y)); + Invalidate(); + +} +void CGDE_3View::OnStartButton() +{ + theApp.m_stopflag=FALSE; + if(theApp.vw->uthread==NULL) + theApp.vw->uthread = AfxBeginThread(StartGDE, &theApp, THREAD_PRIORITY_NORMAL); + else AfxMessageBox("User_main is already running\n",MB_OK); + +} +void CGDE_3View::OnStopButton() +{ + theApp.m_stopflag=TRUE; + int cc=0; + while(theApp.vw->uthread!=NULL){ + Sleep(100); + HWND hw=::GetConsoleWindow(); + ::SetForegroundWindow(hw); + //VOID keybd_event( BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo ); + keybd_event( '0', 0, 0, 0 ); + keybd_event( 13, 0, 0, 0 );//CR + cc++; + if(cc==10)break; + } + //TRACE("cc=%d\n",cc); + + +} + + +void CGDE_3View::OnFileSave() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. + CWaitCursor wait; + + CClientDC scrDC(this); + CDC memDC; // screen DC and memory DC + CBitmap bitmap; + CBitmap* pOldBitmap; // handles to device-dependent bitmaps + + CRect rect; + GetClientRect(&rect); + + memDC.CreateCompatibleDC(&scrDC); + bitmap.CreateCompatibleBitmap(&scrDC, rect.Width(), rect.Height()); + + pOldBitmap = memDC.SelectObject(&bitmap);// select new bitmap into memory DC + + memDC.BitBlt(0, 0, rect.Width(), rect.Height(), &scrDC, 0, 0, SRCCOPY); + + CGDE_3Doc* pDoc = GetDocument(); + CString filename = pDoc->GetPathName(); + + CDib dib; + try { + dib.Create(&bitmap); + dib.Save(filename); + } catch(CImageException& e) { + ::AfxMessageBox(e.what()); + } + + memDC.SelectObject(pOldBitmap); + memDC.DeleteDC(); + + +} + +void CGDE_3View::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein, und/oder benutzen Sie den Standard. + MouseClick = nFlags; // Tastenkombination und... + //printf("1.x:%d,y:%d\n",point.x,point.y); + CClientDC dc(this); + OnPrepareDC(&dc); + dc.DPtoLP(&point); + //printf("2.x:%d,y:%d\n",point.x,point.y); + CPoint shpoint=point; + shpoint.x = (int)(point.x/m_fXScale); + shpoint.y = (int)(point.y/m_fYScale); + MousePoint = shpoint; // ...Position speichern. + //printf("3.x:%d,y:%d\n",shpoint.x,shpoint.y); + + + CScrollView::OnLButtonDown(nFlags, point); +} + +void CGDE_3View::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein, und/oder benutzen Sie den Standard. + + CScrollView::OnLButtonUp(nFlags, point); +} + +void CGDE_3View::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein, und/oder benutzen Sie den Standard. + + + CScrollView::OnRButtonDown(nFlags, point); +} + + + +void CGDE_3View::OnMouseMove(UINT nFlags, CPoint point) +{ + // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein, und/oder benutzen Sie den Standard. + CClientDC dc(this); + OnPrepareDC(&dc); + //printf("1.x:%d,y:%d\n",point.x,point.y); + dc.DPtoLP(&point); + //printf("2.x:%d,y:%d\n",point.x,point.y); + CPoint shpoint=point; + shpoint.x = (int)(point.x/m_fXScale); + shpoint.y = (int)(point.y/m_fYScale); + //printf("3.x:%d,y:%d\n",shpoint.x,shpoint.y); + CString strCurPos; + strCurPos.Format("[x,y]=%d,%d ",shpoint.x, shpoint.y); + CStatusBar *sb= &((CMainFrame *)theApp.m_pMainWnd)->m_wndStatusBar; + sb->SetPaneText(sb->CommandToIndex(ID_INDICATOR_CURPOS),strCurPos); + + CScrollView::OnMouseMove(nFlags, point); +} + +void CGDE_3View::OnDestroy() +{ + CScrollView::OnDestroy(); + + // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein. + OnStopButton(); + +} + +void CGDE_3View::OnFileOpen() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. + TCHAR szFilters[] = _T ("bmp files (*.bmp)|*.bmp|All files (*.*)|*.*||"); + CFileDialog dlg(FALSE, _T ("bmp"), _T ("*.bmp"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY , + szFilters); + + CString filename; + if(dlg.DoModal() == IDOK) + filename = dlg.GetPathName(); + else + return; + + CDib dib; + try { + dib.Load(filename); + } catch(CImageException& e) { + ::AfxMessageBox(e.what()); + } + + CGDE_3Doc* pDoc = GetDocument(); + pDoc->SetTitle(dlg.GetFileName()); + dib.Load(filename); + int ww=dib.GetWidth(); + int hh=dib.GetHeight(); + dib.Draw(&(pDoc->buffer),0,0,ww,hh,SRCCOPY); + pDoc->SetTitle(filename); + pDoc->SetPathName(filename); + + Invalidate(); + +} + +void CGDE_3View::OnFileSaveAs() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. + CWaitCursor wait; + + CClientDC scrDC(this); + CDC memDC; // screen DC and memory DC + CBitmap bitmap; + CBitmap* pOldBitmap; // handles to device-dependent bitmaps + + CRect rect; + GetClientRect(&rect); + + memDC.CreateCompatibleDC(&scrDC); + bitmap.CreateCompatibleBitmap(&scrDC, rect.Width(), rect.Height()); + + pOldBitmap = memDC.SelectObject(&bitmap);// select new bitmap into memory DC + + memDC.BitBlt(0, 0, rect.Width(), rect.Height(), &scrDC, 0, 0, SRCCOPY); + + TCHAR szFilters[] = _T ("bmp files (*.bmp)|*.bmp|All files (*.*)|*.*||"); + CFileDialog dlg(FALSE, _T ("bmp"), _T ("*.bmp"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + szFilters); + + CString filename; + if(dlg.DoModal() == IDOK) + filename = dlg.GetPathName(); + else + return; + + CDib dib; + try { + dib.Create(&bitmap); + dib.Save(filename); + } catch(CImageException& e) { + ::AfxMessageBox(e.what()); + } + + memDC.SelectObject(pOldBitmap); + memDC.DeleteDC(); + + CGDE_3Doc* pDoc = GetDocument(); + pDoc->SetTitle(filename); + pDoc->SetPathName(filename); + } + +void CGDE_3View::OnFileNew() +{ + // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. + AfxMessageBox("Not supported",MB_OK); +} diff --git a/GDE_3_2008/GDE_3View.h b/GDE_3_2008/GDE_3View.h new file mode 100644 index 0000000..f2e7484 --- /dev/null +++ b/GDE_3_2008/GDE_3View.h @@ -0,0 +1,83 @@ +// GDE_3View.h : Schnittstelle der Klasse CGDE_3View +// +#ifndef _GDE_3VIEW_H +#define _GDE_3VIEW_H + +#pragma once + +extern UINT StartGDE(LPVOID lpv); + +class CGDE_3View : public CScrollView +{ +protected: // Nur aus Serialisierung erstellen + CGDE_3View(); + DECLARE_DYNCREATE(CGDE_3View) + +// Attribute +public: + CGDE_3Doc* GetDocument() const; + BYTE MouseClick; // Speichert Tastendruecke mit der Maus. + POINT MousePoint; // Position des Mauszeigers waehrend dem Klicken. + + // zooming + float m_fXScale; + float m_fYScale; + float m_fDelta; + int m_nMapMode; + + CWinThread* uthread; + +// Operationen +public: +void WRSetScrollSizes (int mode, CSize si) +{ + ((CGDE_3View *)FromHandle((theApp.vw->m_hWnd)))->SetScrollSizes(mode, si); + ((CGDE_3View *)FromHandle((theApp.vw->m_hWnd)))->Invalidate(); +} +// Überschreibungen + public: + virtual void OnDraw(CDC* pDC); // Überladen, um diese Ansicht darzustellen +virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual void OnInitialUpdate(); // Erster Aufruf nach Erstellung + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// Implementierung +public: + virtual ~CGDE_3View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generierte Funktionen für die Meldungstabellen +protected: + afx_msg void OnStopButton(); + afx_msg void OnStartButton(); + afx_msg void OnButtonzoomout(); + afx_msg void OnButtonzoomin(); + afx_msg void OnButtonzoomfit(); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnFileSave(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); +// afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnDestroy(); + afx_msg void OnFileOpen(); + afx_msg void OnFileSaveAs(); + afx_msg void OnFileNew(); +}; + +#ifndef _DEBUG // Debugversion in GDE_3View.cpp +inline CGDE_3Doc* CGDE_3View::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif + +#endif diff --git a/GDE_3_2008/Graphics/BaseException.h b/GDE_3_2008/Graphics/BaseException.h new file mode 100644 index 0000000..238931f --- /dev/null +++ b/GDE_3_2008/Graphics/BaseException.h @@ -0,0 +1,69 @@ +// BaseException.h: interface for the CBaseException class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_BASEEXCEPTION_H__0902F453_576E_48BB_90ED_7FC4CA666A82__INCLUDED_) +#define AFX_BASEEXCEPTION_H__0902F453_576E_48BB_90ED_7FC4CA666A82__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include +#include +using namespace std; + +#pragma warning( disable : 4290 ) // disable Exception Specification warning +#pragma warning( disable : 4996 ) // disable sprintf warning + +#define LOCATION Location(__FILE__, __LINE__) + +/** This function returns string object of Error filename and line number */ +inline string Location(string file, int lineNo) { + char buf[64]; + sprintf(buf, " line no. %d", lineNo); + + return file + buf; +} + +/** Base class of All Exception Classes. +* +* BaseException and all derivative classes have 3 Constructs. +* +* ex) You can throw BaseException object like this. +* +* 1. throw BaseException(); -> message would be "Exception" +* +* 2. throw BaseException(_T("Disaster")); -> message would be "Disaster" +* +* 3. throw BaseException(_T("Disaster"), LOCATION); ->message would be "Disaster SomeFile line no 11" +*/ +class BaseException : public runtime_error +{ +public: + /** Default Constructor + * @param None + * @exceptions None + */ + BaseException() throw() : runtime_error("error") {} + /** Constructor with string description + * @param message - This should be a useful message for error tracking. + * @exceptions None + */ + BaseException(string message) throw() : runtime_error(message) {} + /** Constructor with string description and error location + * @param message - This should be a useful message for error tracking. + * @param location - Location where Exception has occrurred. You can use LOCATION macro here. + * @exceptions None + */ + BaseException(string message, string location) throw() : runtime_error(message+location) {} + /** This function outputs the error message in some output stream + * @param os - some output stream + * @return None + * @exceptions None + */ + void Log(ostream& os) throw() { os << what() << endl; } +}; + +#endif // !defined(AFX_BASEEXCEPTION_H__0902F453_576E_48BB_90ED_7FC4CA666A82__INCLUDED_) diff --git a/GDE_3_2008/Graphics/Dib.cpp b/GDE_3_2008/Graphics/Dib.cpp new file mode 100644 index 0000000..28b9688 --- /dev/null +++ b/GDE_3_2008/Graphics/Dib.cpp @@ -0,0 +1,331 @@ +// Dib.cpp: implementation of the CDib class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Dib.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +CDib::CDib() throw() +{ + m_pBmpFileHeader = NULL; + m_pBmpInfo = NULL; + m_pBmpInfoHeader = NULL; + m_pRGBTable = NULL; + m_pDibBits = NULL; + m_uiNumColors = 0; +} + +CDib::~CDib() +{ + Clear(); +} +BOOL CDib::DibLoaded() const throw() +{ + return (m_pBmpInfoHeader!=NULL); +} +CSize CDib::GetDimensions() const throw() +{ + if (!DibLoaded()) return CSize(0,0); + return CSize((int)m_pBmpInfoHeader->biWidth,(int)m_pBmpInfoHeader->biHeight); +} + +void CDib::Clear() throw() +{ + if(m_pBmpFileHeader != NULL) { + delete[] m_pBmpFileHeader; + m_pBmpFileHeader = NULL; + } + if(m_pBmpInfo != NULL) { + delete[] m_pBmpInfo; + m_pBmpInfo = NULL; + } + if(m_pDibBits != NULL) { + delete[] m_pDibBits; + m_pDibBits = NULL; + } +} + +void CDib::Load(CString fileName) throw(CImageException) +{ + CFile file(fileName, CFile::modeRead | CFile::shareDenyNone); + Load(&file); +} + +void CDib::Load(CFile* pFile) throw(CImageException) +{ + Clear(); + + m_pBmpFileHeader = new BITMAPFILEHEADER; + pFile->Read(static_cast(m_pBmpFileHeader), sizeof(BITMAPFILEHEADER)); + + if(m_pBmpFileHeader->bfType != 0x4d42) { + Clear(); + pFile->Close(); + throw CImageException(_T("Failed to load document")); + } else { + DWORD dwLength; + dwLength = m_pBmpFileHeader->bfOffBits - sizeof(BITMAPFILEHEADER); + + m_pBmpInfo = reinterpret_cast(new BYTE[dwLength]); + pFile->Read(static_cast(m_pBmpInfo), dwLength); + m_pBmpInfoHeader = reinterpret_cast(m_pBmpInfo); + + if((m_pBmpInfoHeader->biClrUsed == 0)) + m_uiNumColors = 1 << m_pBmpInfoHeader->biBitCount; + else + m_uiNumColors = m_pBmpInfoHeader->biClrUsed; + + if(m_pBmpInfoHeader->biClrUsed == 0) + m_pBmpInfoHeader->biClrUsed = m_uiNumColors; + + if(m_uiNumColors <= 256) + m_pRGBTable = reinterpret_cast(reinterpret_cast(m_pBmpInfo) + m_pBmpInfoHeader->biSize); + + unsigned int dwDibLength = (unsigned int)pFile->GetLength() - m_pBmpFileHeader->bfOffBits / 4; + m_pDibBits = new BYTE[dwDibLength]; + pFile->Read(static_cast(m_pDibBits), dwDibLength); + } +} + +void CDib::Create(CBitmap* pBitmap) throw(CImageException) +{ + BITMAP Bitmap; + int rc = pBitmap->GetBitmap(&Bitmap); + if(rc == 0) + throw CImageException(_T("Can't get BITMAP from CBitmap*")); + + int iWidthBytes = ((Bitmap.bmWidth * Bitmap.bmBitsPixel + 15) & ~15) >> 3 ; + DWORD dwImgSize = iWidthBytes * Bitmap.bmHeight; + + // File header + m_pBmpFileHeader = new BITMAPFILEHEADER; + m_pBmpFileHeader->bfType = 0x4d42; + m_pBmpFileHeader->bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + dwImgSize; + m_pBmpFileHeader->bfReserved1 = 0; + m_pBmpFileHeader->bfReserved2 = 0; + m_pBmpFileHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + sizeof(RGBQUAD); + + // Bitmap Info header - no support for palette mode + m_pBmpInfo = new BITMAPINFO; + m_pBmpInfoHeader = reinterpret_cast(m_pBmpInfo); + ::ZeroMemory(m_pBmpInfoHeader, sizeof(BITMAPINFOHEADER)); + m_pBmpInfoHeader->biSize = sizeof(BITMAPINFOHEADER); + m_pBmpInfoHeader->biWidth = Bitmap.bmWidth; + m_pBmpInfoHeader->biHeight = Bitmap.bmHeight; + m_pBmpInfoHeader->biPlanes = 1; + m_pBmpInfoHeader->biBitCount = Bitmap.bmPlanes * Bitmap.bmBitsPixel; + m_pBmpInfoHeader->biSizeImage = dwImgSize; + + // Color Table + if((m_pBmpInfoHeader->biClrUsed == 0)) + m_uiNumColors = 1 << (m_pBmpInfoHeader->biBitCount-1); + else + m_uiNumColors = m_pBmpInfoHeader->biClrUsed; + if(m_pBmpInfoHeader->biClrUsed == 0) + m_pBmpInfoHeader->biClrUsed = m_uiNumColors; + if(m_uiNumColors <= 256) { + Clear(); + throw CImageException("Palette mode is not supported"); + } + // Data bits + m_pDibBits = new BYTE[dwImgSize]; + pBitmap->GetBitmapBits(dwImgSize, m_pDibBits); + LPBYTE pTemp = new BYTE[iWidthBytes]; + for(int i=0; i 8); + + Clear(); + + int iWidthBytes = ((width * bitCount + 15) & ~15) >> 3 ; + DWORD dwImgSize = iWidthBytes * height; + + // File header + m_pBmpFileHeader = new BITMAPFILEHEADER; + m_pBmpFileHeader->bfType = 0x4d42; + m_pBmpFileHeader->bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + dwImgSize; + m_pBmpFileHeader->bfReserved1 = 0; + m_pBmpFileHeader->bfReserved2 = 0; + m_pBmpFileHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + sizeof(RGBQUAD); + + // Bitmap Info header - no support for palette mode + m_pBmpInfo = new BITMAPINFO; + m_pBmpInfoHeader = reinterpret_cast(m_pBmpInfo); + ::ZeroMemory(m_pBmpInfoHeader, sizeof(BITMAPINFOHEADER)); + m_pBmpInfoHeader->biSize = sizeof(BITMAPINFOHEADER); + m_pBmpInfoHeader->biWidth = width; + m_pBmpInfoHeader->biHeight = height; + m_pBmpInfoHeader->biPlanes = 1; + m_pBmpInfoHeader->biBitCount = bitCount; + m_pBmpInfoHeader->biSizeImage = dwImgSize; + + // Color Table + if((m_pBmpInfoHeader->biClrUsed == 0)) + m_uiNumColors = 1 << m_pBmpInfoHeader->biBitCount; + else + m_uiNumColors = m_pBmpInfoHeader->biClrUsed; + if(m_pBmpInfoHeader->biClrUsed == 0) + m_pBmpInfoHeader->biClrUsed = m_uiNumColors; + + if(m_uiNumColors <= 256) { + Clear(); + throw CImageException("Palette mode is not supported"); + } + // data bits + m_pDibBits = pData; +} + +void CDib::Save(CString fileName) throw(CImageException) +{ + CFile file; + if(file.Open(fileName, CFile::modeWrite | CFile::modeCreate) == 0) + throw CImageException(_T("Cannot open a file")); + Save(&file); +} + +void CDib::Save(CFile* pFile) throw(CImageException) +{ + pFile->Write(static_cast(m_pBmpFileHeader), sizeof(BITMAPFILEHEADER)); + DWORD dwLength; + if(m_uiNumColors <= 256) + dwLength = sizeof(BITMAPINFOHEADER) + m_uiNumColors*sizeof(RGBQUAD); + else + dwLength = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD); + pFile->Write(static_cast(m_pBmpInfo), dwLength); + + DWORD dwImgSize = (((GetWidth() * m_pBmpInfoHeader->biBitCount + 15) & ~15) >> 3) * GetHeight() ; + pFile->Write(static_cast(m_pDibBits), dwImgSize); +} + +void CDib::Draw(CDC* pdc, int x, int y, double scale, DWORD dwROPCode) const throw(CImageException) { + if (!this->DibLoaded() ) return; + if(!m_pBmpInfo) + throw CImageException(); + int nScanLines = ::StretchDIBits(pdc->GetSafeHdc(), x, y, (int)(GetWidth()*scale) , (int)(GetHeight()*scale), 0, 0, GetWidth(), GetHeight(), + m_pDibBits, m_pBmpInfo, DIB_RGB_COLORS, dwROPCode); + if(nScanLines == GDI_ERROR) + throw CImageException(_T("CDib::Draw exception")); +} + +void CDib::Draw(CDC* pdc, int x, int y, int width, int height, DWORD dwROPCode) const throw(CImageException) { + if(!m_pBmpInfo) + throw CImageException(); + int nScanLines = ::StretchDIBits(pdc->GetSafeHdc(), x, y, width , height, 0, 0, GetWidth(), GetHeight(), + m_pDibBits, m_pBmpInfo, DIB_RGB_COLORS, dwROPCode); + if(nScanLines == GDI_ERROR) + throw CImageException(_T("CDib::Draw exception")); +} + +COLORREF CDib::GetPixel(int x, int y) const throw() { + int width = GetWidth(); + int height = GetHeight(); + + BYTE* pDibBits = m_pDibBits; + BYTE Red; + BYTE Green; + BYTE Blue; + int offset; + + SHORT* psDibBits; // for 16 bit + BYTE Index; + RGBQUAD* prgb; + + int bpp = GetBPP(); + switch(bpp) { + case 1: + case 2: + case 4: + case 8: + offset = width * (height - 1 - y) + x + 1; + pDibBits += offset; + Index = *pDibBits; + prgb = m_pRGBTable + Index; + Red = prgb->rgbRed; + Green = prgb->rgbGreen; + Blue = prgb->rgbBlue; + break; + case 16: // assuming 565 + offset = width * 2 * (height - 1 - y) + (x + 1) * 2; + pDibBits += offset; + psDibBits = (SHORT*)pDibBits; + Blue = *psDibBits >> 11; + Green = (*psDibBits >> 5) & 63; + Red = *psDibBits & 127; + break; + case 24: + offset = width * 3 * (height -1 - y) + (x + 1) * 3; + pDibBits += offset; + Blue = *pDibBits; + ++pDibBits; + Green = *pDibBits; + ++pDibBits; + Red = *pDibBits; + break; + case 32: + offset = width * 4 * (height -1 - y) + (x + 1) * 4; + pDibBits += offset; + Blue = *pDibBits; + ++pDibBits; + Green = *pDibBits; + ++pDibBits; + Red = *pDibBits; + break; + default: + break; + } + + return RGB(Red, Green, Blue); +} + +void CDib::SetPixel(int x, int y, COLORREF col) throw() { + int width = GetWidth(); + int height = GetHeight(); + + BYTE* pDibBits = m_pDibBits; + int offset; + + int bpp = GetBPP(); + switch(bpp) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; // no support for these modes... yet. + case 24: + offset = width * 3 * (height -1 - y) + (x + 1) * 3; + pDibBits += offset; + *pDibBits = GetBValue(col); + ++pDibBits; + *pDibBits = GetGValue(col); + ++pDibBits; + *pDibBits = GetRValue(col); + break; + case 32: + offset = width * 4 * (height -1 - y) + (x + 1) * 4; + pDibBits += offset; + *pDibBits = GetBValue(col); + ++pDibBits; + *pDibBits = GetGValue(col); + ++pDibBits; + *pDibBits = GetRValue(col); + break; + default: + break; + } +} \ No newline at end of file diff --git a/GDE_3_2008/Graphics/Dib.h b/GDE_3_2008/Graphics/Dib.h new file mode 100644 index 0000000..ec13b21 --- /dev/null +++ b/GDE_3_2008/Graphics/Dib.h @@ -0,0 +1,76 @@ +// Dib.h: interface for the CDib class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_DIB_H__3C441908_83F8_4989_BEB1_7F05D9BD732E__INCLUDED_) +#define AFX_DIB_H__3C441908_83F8_4989_BEB1_7F05D9BD732E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "Image.h" + +/** Bitmap handling Class. +* +* This class handles bmp objects. Normally you make CImage object for this. +* +* ex) CImage* pImage = new CDib; +* +* pImage->Draw(pDC); +*/ +class CDib : public CImage +{ +public: + /** Constructor. Uses 2 part initialization + * @exceptions None + */ + CDib() throw(); + + /** Destructor. + * Clean all the resources here + */ + virtual ~CDib(); + + virtual void Create(int width, int height, LPBYTE pData, int bitCount=24) throw(CImageException); + virtual void Load(CString fileName) throw(CImageException); + virtual void Load(CFile* pFile) throw(CImageException); + virtual void Save(CString fileName) throw(CImageException); + virtual void Save(CFile* pFile) throw(CImageException); + virtual void Draw(CDC* pdc, int x = 0, int y = 0, double scale = 1.0, DWORD dwROPCode = SRCCOPY) const throw(CImageException); + virtual void Draw(CDC* pdc, int x, int y, int width, int height, DWORD dwROPCode = SRCCOPY) const throw(CImageException); + virtual UINT GetWidth() const throw() { return m_pBmpInfoHeader->biWidth; } + virtual UINT GetHeight() const throw() { return m_pBmpInfoHeader->biHeight; } + virtual UINT GetBPP() const throw() { return m_pBmpInfoHeader->biBitCount; } + virtual COLORREF GetPixel(int x, int y) const throw(); + virtual LPBYTE GetDibBits() const throw() { return m_pDibBits; } + virtual BOOL DibLoaded() const throw(); + virtual CSize GetDimensions() const throw(); + + /** Create image from CBitmap pointer + * @param pBitmap - CBitmap pointer(DDB) + * @return None + * @exceptions CImageException + */ + void Create(CBitmap* pBitmap) throw(CImageException); + + /** Set COLORREF value of specified location + * @param x - x location + * @param y - y location + * @param col - COLORREF value to set + * @return None + * @exceptions None + */ + void SetPixel(int x, int y, COLORREF col) throw(); +protected: +private: + void Clear() throw(); + LPBITMAPFILEHEADER m_pBmpFileHeader; + LPBITMAPINFO m_pBmpInfo; + LPBITMAPINFOHEADER m_pBmpInfoHeader; + LPRGBQUAD m_pRGBTable; + LPBYTE m_pDibBits; + UINT m_uiNumColors; +}; + +#endif // !defined(AFX_DIB_H__3C441908_83F8_4989_BEB1_7F05D9BD732E__INCLUDED_) diff --git a/GDE_3_2008/Graphics/Graphicfunctions.cpp b/GDE_3_2008/Graphics/Graphicfunctions.cpp new file mode 100644 index 0000000..bcd52d6 --- /dev/null +++ b/GDE_3_2008/Graphics/Graphicfunctions.cpp @@ -0,0 +1,253 @@ +// Graphicfunctions.cpp : implementation of the GDE functions +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "shape.h" +#include "pointerarray.h" +#include "dib.h" +#include "..\mainfrm.h" +#include "..\GDE_3.h" +#include "..\GDE_3Doc.h" +#include "..\GDE_3View.h" + +#include "Graphicfunctions.h" + +#pragma once + + +extern CGDE_3App theApp; +void DoEvents() +{ + MSG oMSG; + while(::PeekMessage(&oMSG, NULL,0,0,PM_NOREMOVE)) + if(::GetMessage(&oMSG,NULL,0,0)) + { + ::TranslateMessage(&oMSG); + ::DispatchMessage(&oMSG); + } + else break; +} +// Makro Objekte von CShape abgeleiteten Klassen anzulegen und +// einen Zeiger darauf im Array aShape zu speichern. +#define __add_to_aShape(classname) theApp.vw->GetDocument()->aShape.Add( new classname); +void drawtobuffer() +{ + CGDE_3Doc *pDoc=theApp.vw->GetDocument(); + int siz = (int)(pDoc->aShape.GetSize()); + pDoc->aShape[siz-1]->Draw(&pDoc->buffer); +} + + +// Koordinaten und Fenstergroesse +WORD MAX_X = 600; // maximale x-Koordinate +WORD MAX_Y = 400; // maximale y-Koordinate + +void set_windowpos(int x, int y, int b, int h) +{ + extern CGDE_3App theApp; + + CRect client_rect, window_rect, status_rect, view_rect; + + theApp.m_pMainWnd->GetWindowRect(&window_rect); // Die Windowgroesse ermitteln. + int hhw=window_rect.Height(); + int www=window_rect.Width(); + + theApp.vw->GetWindowRect(&view_rect); //Die Viewgroesse ermitteln. + int hhv=view_rect.Height(); + int wwv=view_rect.Width(); + + + // Zur Breite den Bereich ausserhalb des clients hinzurechnen. + // Zusaetzlich muessen noch 3 addiert werden, da sonst die scrollbars gezeigt werden. + b += www - wwv + 5; + h += hhw - hhv + 5; + + theApp.m_pMainWnd->MoveWindow(x, y, b, h); + theApp.m_pMainWnd->Invalidate(); +} +void get_windowsize(int *b, int *h) +{ + RECT rect; + theApp.vw->GetClientRect(&rect); //Die Clientgroesse ermitteln + *b = rect.right; + *h = rect.bottom; +} +void set_drawarea(int b, int h) +{ + MAX_X = b; + MAX_Y = h; + + while (theApp.vw == NULL) Sleep(100);// Warten bis CGDEView konstruiert ist. + Sleep(100); + theApp.vw->WRSetScrollSizes(MM_TEXT, CSize(MAX_X,MAX_Y)); // Anpassen des Bereiches der scrollbars. + + theApp.vw->GetDocument()->memoryBmp.DeleteObject(); // Das alte Bitmap im Speicher loeschen. + CDC *pdc=theApp.vw->GetDC(); + if(!theApp.vw->GetDocument()->memoryBmp.CreateCompatibleBitmap(pdc,MAX_X, MAX_Y)){ + AfxMessageBox("Cannot create Bitmap",MB_OK); + } + theApp.vw->GetDocument()->buffer.SelectObject( &theApp.vw->GetDocument()->memoryBmp ); // Das Speicher-Bitmap als Geraetekontext auswaehlen. + theApp.vw->GetDocument()->buffer.PatBlt(0, 0, MAX_X, MAX_Y, WHITENESS); // Den ganzen Puffer weiss malen. + theApp.vw->GetDocument()->nShapePos = 0; // Zuruecksetzen der Position auf 0, um ein + // Neuzeichnen aller Objekte zu gewaehrleisten. + theApp.vw->Invalidate(TRUE); // Zeichenbereich aktualisieren. + // Der gesamte Zeichenbereich wird gelosescht. +} +void get_drawarea(int *b, int *h) +{ + *b = MAX_X; + *h = MAX_Y; +} + +// Bildpunkte und Bildschirmbereiche +void pixel(int x, int y, int color) +{ + __add_to_aShape( CPixel(x, y, color) ); + drawtobuffer(); + +} + +void fill (int x, int y, int color1, int color2) +{ + __add_to_aShape( CFill(x, y, color1, color2) ); + drawtobuffer(); + +} + + +// Linien +void moveto(int x, int y) +{ + __add_to_aShape( CMoveTo(x, y) ); + drawtobuffer(); + +} + +void lineto(int x, int y, int color) +{ + __add_to_aShape( CLineTo(x, y, color) ); + drawtobuffer(); + +} + +void line(int x1, int y1, int x2, int y2, int color) +{ + __add_to_aShape( CLine(x1, y1, x2, y2, color) ); + drawtobuffer(); + +} + + +// Rechtecke +void rectangle(int x1, int y1, int x2, int y2, int cframe, int cfill) +{ + __add_to_aShape( CRectangle( CRect(x1, y1, x2, y2), cframe, cfill) ); + drawtobuffer(); + +} + + +// Kreise und Ellipsen +void ellipse(int x1, int y1, int x2, int y2, int cframe, int cfill) +{ + __add_to_aShape( CEllipse( CRect(x1, y1, x2, y2), cframe, cfill) ); + drawtobuffer(); + +} + + +// Text +void text(int x, int y, int size, int color, char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + __add_to_aShape( CText(x, y, size*10, color, format, argptr) ); + drawtobuffer(); + +} +void text(int x, int y, int size, int color, int bkcolor, char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + __add_to_aShape( CText(x, y, size*10, color, bkcolor, format, argptr) ); + drawtobuffer(); + +} +void text(int x, int y, int size, int color, int angle, int align, char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + __add_to_aShape( CText(x, y, size*10, color, angle, align*10, format, argptr) ); + drawtobuffer(); +} +void text(int x, int y, int size, int color, int bkcolor, int angle, int align, char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + __add_to_aShape( CText(x, y, size*10, color, bkcolor, angle*10, align, format, argptr) ); + drawtobuffer(); +} + +void textbox(int x1, int y1, int x2, int y2, int size, int ctext, + int cframe, int cfill, int flags, char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + __add_to_aShape( CTextBox( CRect(x1, y1, x2, y2), size*10, ctext, cframe, cfill, flags, format, argptr) ); + drawtobuffer(); +} + + +// Ablaufsteuerung +int mouseclick(int *x, int *y) // Wartet auf einen Mausklick und gibt dann button & key zurueck. +{ + + theApp.vw->Invalidate(); // Zeichenbereich aktualisieren (GDEView::OnPaint() wird aufgerufen) + theApp.vw->MouseClick = 0; // Ruecksetzen der Maustaste. + while (theApp.vw->MouseClick == 0) // Warten bis eine Maustaste gedrueckt wird. + { + DoEvents(); + if(StopProcess())break; + Sleep(20); // 20ms warten + } + *x = theApp.vw->MousePoint.x; // Zurueckgeben der x-Koordinate des Mauszeigers. + *y = theApp.vw->MousePoint.y; // Zurueckgeben der y-Koordinate des Mauszeigers. + return theApp.vw->MouseClick; // Zurueckgeben der Maustasten- & Tastenkombination. +} + +int checkmouse() // Prueft ob zwischenzeitlich die Maus betaetigt wurde. +{ + DoEvents(); + theApp.vw->Invalidate(); // Zeichenbereich aktualisieren (GDEView::OnPaint() wird aufgerufen) + if (theApp.vw->MouseClick > 0) { // wenn Maustaste gedrueckt ... + theApp.vw->MouseClick = 0; // ... ruecksetzen der Maustaste ... + return theApp.vw->MouseClick; // ... und zurueckgeben der Tastenkombination. + } + else + return 0; // ansonsten 0 zurueckgeben. +} + +void wait(unsigned int msecs) // Wartet die vorgegebende Zeit in Millisekunden +{ + theApp.vw->Invalidate(FALSE); // Update screen ( GDEView::OnPaint() wird aufgerufen) + Sleep(msecs); +} + +void clrscr() // Loeschen des gesamten Zeichenbereiches. +{ + theApp.vw->GetDocument()->aShape.RemoveAll(); // Das Array leeren... + theApp.vw->GetDocument()->nShapePos = 0; // ...und die Position ruecksetzen. + theApp.vw->GetDocument()->buffer.PatBlt(0, 0, MAX_X, MAX_Y, WHITENESS); // Den ganzen Puffer weiss malen. + theApp.vw->Invalidate(FALSE); // Zeichenbereich aktualisieren (GDEView::OnPaint() wird aufgerufen) +// theApp.vw->SendMessage(WM_PAINT);//Zeichenbereich aktualisieren (GDEView::OnPaint() wird aufgerufen) +} + +void updatescr() // Neuzeichnen des gesamten Zeichenbereiches. +{ + theApp.vw->Invalidate(FALSE); // Zeichenbereich aktualisieren (GDEView::OnPaint() wird aufgerufen) +} +BOOL StopProcess() +{ + return theApp.m_stopflag ; +} diff --git a/GDE_3_2008/Graphics/Graphicfunctions.h b/GDE_3_2008/Graphics/Graphicfunctions.h new file mode 100644 index 0000000..701d270 --- /dev/null +++ b/GDE_3_2008/Graphics/Graphicfunctions.h @@ -0,0 +1,100 @@ +// Graphicfunctions.h : interface of the GDE functions +// +// In diesem Header-File sind alle Grafikfunktionen, die der Benutzer +// zur Programmierung verwenden kann deklariert. +// +///////////////////////////////////////////////////////////////////////////// + + +// Koordinaten und Fenstergroesse +void set_windowpos(int x, int y, int b, int h); // Groesse und Position des Grafikfensters setzen. +void get_windowsize(int *b, int *h); // Groesse des Grafikfensters ermitteln. +void set_drawarea(int b, int h); // Setzen der Groesse des Zeichenbereiches. +void get_drawarea(int *b, int *h); // Ermitteln der Groesse des Zeichenbereches. + +// Farben +#define BLACK 0 +#define WHITE RGB(255,255,255) +#define RED RGB(255,0,0) +#define GREEN RGB(0,255,0) +#define BLUE RGB(0,0,255) +#define YELLOW RGB(255,255,0) +#define GREY RGB(192,192,192) +#define BROWN RGB(128,64,0) + + +// Bildpunkte und Bildschirmbereiche +void pixel(int x, int y, int color); // Setzen eines einzenen Pixels. +void fill (int x, int y, int color1, int color2); // Fuellt einen Bereich des Fensters mit einer Farbe. + // color1: Fuellt den durch diese Farbe begrenzten Bereich. + // color2: Fuefarbe + +// Linien +void moveto(int x, int y); // Setzt die Position des virtuellen Grafikcursors. +void lineto(int x, int y, int color); // Zieht eine Linie von den Koordinaten des Grafikcursors aus. +void line(int x1, int y1, int x2, int y2, int color); // Zeichnet eine Linie. + +// Rechtecke +void rectangle(int x1, int y1, int x2, int y2, int cframe, int cfill = -1); + // Zeichnet ein Rechteck (optional deckend). + // x1, y1 : obere linke Ecke + // x2, y2 : untere rechte Ecke + // cframe : Rahmenfarbe + // cfill : Fuellfarbe + +// Kreise und Ellipsen +void ellipse(int x1, int y1, int x2, int y2, int cframe, int cfill = -1); + // Zeichnet eine Ellipse (optional deckend). + // x1, y1 : obere linke Ecke + // x2, y2 : untere rechte Ecke + // cframe : Rahmenfarbe + // cfill : Fuellfarbe + +// Text +#define LEFT_ALIGN DT_LEFT +#define RIGHT_ALIGN DT_RIGHT +#define CENTER_ALIGN DT_CENTER +#define TOP_ALIGN DT_TOP +#define BOTTOM_ALIGN DT_BOTTOM +#define VCENTER_ALIGN DT_VCENTER +#define BREAK_WORDS DT_WORDBREAK +#define NO_CLIPPING DT_NOCLIP +#define SINGLE_LINE DT_SINGLELINE + +void text(int x, int y, int size, int color, char *format, ...); +void text(int x, int y, int size, int color, int bkcolor, char *format, ...); +void text(int x, int y, int size, int color, int angle, int align, char *format, ...); +void text(int x, int y, int size, int color, int bkcolor, int angle, int align, char *format, ...); + // Mehrzeilige (\n) Textausgabe (analog printf); + // size : Textgroesse + // color : Textfarbe + // bkcolor : Hintergrundfarbe wenn deckend, sonst transparent. + // angle : Winkel um dem der Text gedreht wird. + // align : Ausrichtung des Textes. + // der hintere Teil funktioniert analog zu printf +void textbox(int x1, int y1, int x2, int y2, int size, int textcolor, + int framecolor, int fillcolor, int flags, char *format, ...); + // Einzeilige Textausgabe in einer Textbox. + // size : Textgroesse + // textcolor : Textfarbe + // framecolor: Randfarbe + // fillcolor : Fuellfarbe des Rahmens + // flags : Ausrichtung LEFT_ALIGN. RIGHT_ALIGN, CENTER_ALIGN, TOP_ALIGN, ... + // der hintere Teil funktioniert analog zu printf + +// Ablaufsteuerung (all Funktionen beinhalten ein neuzeichnen des Zeichenbereiches) +#define MBTN_LEFT MK_LBUTTON +#define MBTN_MIDDLE MK_MBUTTON +#define MBTN_RIGHT MK_RBUTTON +#define MBTN_SHIFT MK_SHIFT +#define MBTN_CONTROL MK_CONTROL + +int mouseclick(int *x, int *y); // Wartet auf einen Mausklick und gibt dann button & key zurueck. +int checkmouse(); // Prueft ob zwischenzeitlich die Maus betaetigt wurde. + // 0: nicht betaetigt, ... +void wait(unsigned int msecs); // Wartet die vorgegebende Zeit in Millisekunden. + +void clrscr(); // Loescht den gesamten Zeichenbereich. +void updatescr(); // Neuzeichnen des gesamten Zeichenbereiches. + +BOOL StopProcess(); // Gibt an ob ein Stopflagg gesetzt wurde \ No newline at end of file diff --git a/GDE_3_2008/Graphics/Image.h b/GDE_3_2008/Graphics/Image.h new file mode 100644 index 0000000..99cac4a --- /dev/null +++ b/GDE_3_2008/Graphics/Image.h @@ -0,0 +1,150 @@ +// Image.h: interface for the CImage class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_IMAGE_H__D3142778_9555_4128_887F_104A5F9478E1__INCLUDED_) +#define AFX_IMAGE_H__D3142778_9555_4128_887F_104A5F9478E1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "BaseException.h" + +/** ImageFormat constants */ +enum IMAGE_FORMAT { IF_BMP, IF_JPG }; + + +/** Exception class for CImage and its derivative classes. +* +* ex) You can throw CImageException object like this. +* +* 1. throw CImageException(); -> Reason would be "Exception". +* +* 2. throw CImageException(_T("Disaster")); -> Reason would be "Disaster". +* +* 3. throw CImageException(_T("Disaster"), LOCATION); ->Reason would be "Disaster SomeFile line no 11". +*/ +class CImageException : public BaseException +{ +public: + /** Default Constructor + * @param None + * @exceptions None + */ + CImageException() throw() : BaseException(_T("ImageException")) {} + /** Constructor with string description + * @param message - This should be a useful message for error tracking. + * @exceptions None + */ + CImageException(string message) throw() : BaseException(message) {} + /** Constructor with string description and error location + * @param message - This should be a useful message for error tracking. + * @param location - Location where Exception has occrurred. You can use LOCATION macro here. + * @exceptions None + */ + CImageException(string message, string location) throw() : BaseException(message, location) {} +}; + +/** Base class of all Image Class. +* +* Normally, you use this class for all bmp, jpg objects. +* +* ex) CImage* pImage = new CDib; +* +* pImage->Draw(pDC); +*/ +class CImage +{ +public: + /** Virtual Destructor. + * Does nothing + */ + virtual ~CImage(){} + /** Load image from specified filename. Overriding Function + * @param fileName - Name of the File + * @return None + * @exceptions CImageException + */ + virtual void Load(CString fileName) throw(CImageException) = 0; + /** Load image from CFile pointer. Overriding Function + * @param pFile - CFile pointer + * @return None + * @exceptions CImageException + */ + virtual void Load(CFile* pFile) throw(CImageException) = 0; + /** Save image with a specified filename. Overriding Function + * @param fileName - Name of the File to be saved + * @return None + * @exceptions CImageException + */ + virtual void Save(CString fileName) throw(CImageException) = 0; + /** Save image with a specified CFile pointer. Overriding Function + * @param pFile - CFile pointer + * @return None + * @exceptions CImageException + */ + virtual void Save(CFile* pFile) throw(CImageException) = 0; + /** Draw image to Screen with coordinate and scale ratio. Overriding Function + * @param pdc - Device Context + * @param x - x coordinate of destination image + * @param y - y coordinate of destination image + * @param scale - ratio of dest/source rectangle + * @param dwROPCode - ROP code + * @return None + * @exceptions CImageException + */ + virtual void Draw(CDC* pdc, int x=0, int y=0, double scale = 1.0, DWORD dwROPCode = SRCCOPY) const throw(CImageException) = 0; + /** Draw image to Screen with coordinate and fixed width/height. Overriding Function + * @param pdc - Device Context + * @param x - x coordinate of destination image + * @param y - y coordinate of destination image + * @param width - fixed width of destination image + * @param height - fixed height of destination image + * @param dwROPCode - ROP code + * @return None + * @exceptions CImageException + */ + virtual void Draw(CDC* pdc, int x, int y, int width, int height, DWORD dwROPCode = SRCCOPY) const throw(CImageException) = 0; + /** Create image from data bits. Overriding Function + * @param width - width of original image + * @param height - height of original Image + * @param pData - data bits. Contains rgb data(Pallette mode not supported) + * @return None + * @exceptions CImageException + */ + virtual void Create(int width, int height, LPBYTE pData, int bitCount=24) throw(CImageException) = 0; + /** Returns width of Image. Overriding Function + * @param None + * @return width of Image + * @exceptions None + */ + virtual UINT GetWidth() const throw() = 0; + /** Returns height of Image. Overriding Function + * @param None + * @return height of Image + * @exceptions None + */ + virtual UINT GetHeight() const throw() = 0; + /** Returns BitPerPixel value of current Image + * @param None + * @return BitPerPixel value + * @exceptions None + */ + virtual UINT GetBPP() const throw() = 0; + /** Get COLORREF value of given pixel + * @param x - x coordinate + * @param y - y coordinate + * @return COLORREF value of given pixel + * @exceptions None + */ + virtual COLORREF GetPixel(int x, int y) const throw() = 0; + /** Get DibBits directly + * @param None + * @return LPBYTE BYTE pointer of given Dib + * @exceptions None + */ + virtual LPBYTE GetDibBits() const throw() = 0; +}; + +#endif // !defined(AFX_IMAGE_H__D3142778_9555_4128_887F_104A5F9478E1__INCLUDED_) diff --git a/GDE_3_2008/Graphics/PointerArray.h b/GDE_3_2008/Graphics/PointerArray.h new file mode 100644 index 0000000..8aa9fb6 --- /dev/null +++ b/GDE_3_2008/Graphics/PointerArray.h @@ -0,0 +1,35 @@ +// PointerArray.h: interface for the CPointerArray class. +// +// Die von CArrray abgeleitete Klasse CPointerArray, +// stellt ein eindimensionales Feld dar, indem Zeiger +// beliebigen Types gespeichert werden koennen. +// Die Besonderheit liegt darin, dass, beim Loeschen eines Elementes +// (gespeicherten Zeigers), der Speicherbereich, den das Objekt, +// auf den der Zeiger zeigt, belegt, wieder freigegeben wird. +// Kleines Bsp.: +// Zeiger A zeigt auf das Objekt B, das im Speicher 200 Byte belegt. +// Zeiger A wird in diesem Array gespeichert. +// Beim Loeschen des Zeigers A wird auch das Objekt B geloescht. +// Dieses vorgehen ist eine einfache Form von "garbage collection" +// +////////////////////////////////////////////////////////////////////// + +#pragma once + +#include // includes CArray + +template class CPointerArray : public CArray +{ +public: + void RemoveAll() { // Leeren der gesamten Arrays. + for (int i=0; iGetSize(); i++) // Das Feld ganz durchlaufen... + delete(this->GetAt(i)); // ...und alle Speicherbloecke wieder freigeben. + CArray ::RemoveAll(); // Alle gespeicherten Zeiger aus dem Feld loeschen. + } + + void RemoveAt(int nIndex, int nCount = 1) { // Loeschen von nCount Elementen aus dem Array. + for (int i=nIndex; iGetAt(i)); // ...und die Speicherbloecke wieder freigeben. + CArray ::RemoveAt(nIndex, nCount); // + } +}; \ No newline at end of file diff --git a/GDE_3_2008/Graphics/Shape.cpp b/GDE_3_2008/Graphics/Shape.cpp new file mode 100644 index 0000000..2e089f5 --- /dev/null +++ b/GDE_3_2008/Graphics/Shape.cpp @@ -0,0 +1,241 @@ +// Shape.cpp: implementation of the CShape class and drived classes. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Shape.h" +#include + +#pragma warning( disable : 4996 ) // disable sprintf warning + + +// Dieses Makro changeflag holt aus der Variable "var" +// das flag "extract" heraus und fuegt dafuer das flag "insert" ein. +#define __changeflag(var, extract, insert) if (var & extract) { \ + var ^= extract; \ + var |= insert; \ + }; + +////////////////////////////////////////////////////////////////////// +// CShape Class + +CShape::CShape(short x, short y, COLORREF crColor) +{ + // Initialisieren der Member-Variablen + m_x = x; + m_y = y; + m_crColor = crColor; +} + + +////////////////////////////////////////////////////////////////////// +// CFill Class + +CFill::CFill(short x, short y, COLORREF crFillColor, COLORREF crBorderColor) : + CShape(x, y, crBorderColor) +{ + m_crFillColor = crFillColor; +}; + +void CFill::Draw(CDC* pDC) +{ + CBrush brush(m_crFillColor); // Erstellen... + pDC->SelectObject(&brush); // ...und auswaehlen ein GDI brushes + pDC->FloodFill(m_x, m_y, m_crColor);// Fuellen... + brush.DeleteObject(); // und Brush loeschen. +}; + + +////////////////////////////////////////////////////////////////////// +// CLineTo Class + +void CLineTo::Draw(CDC* pDC) +{ + + CPen pen; // Konstruieren, dann Initialisieren + if( pen.CreatePen( PS_SOLID, 1, m_crColor ) ) + { + // Auswahl des Objekts im Gerätekontext + // Gleichzeitiges Speichern des alten Stifts + CPen* pOldPen = pDC->SelectObject( &pen ); + + // Zeichnen mit dem Stift + pDC->LineTo(m_x, m_y); // Ziehen einer Linie... + // Wiederherstellen des alten Stifts im Gerätekontext + pDC->SelectObject( pOldPen ); + } + else + { + // Den Benutzer alarmieren, daß die Ressourcen knapp werden + } + +/* CPen pen(PS_SOLID, 1, m_crColor); // Generieren eines Zeichenstiftes... + pDC->SelectObject(&pen); // ...und auswaehlen dieses Stiftes. + pDC->LineTo(m_x, m_y); // Ziehen einer Linie... +*/ +// pen.DeleteObject(); // ...und anschliessendes Loeschen des ausgewaehlten Siftes. +} + + +////////////////////////////////////////////////////////////////////// +// CLine Class + +CLine::CLine(short x1, short y1, short x2, short y2, UINT crColor) : CLineTo(x1, y1, crColor) +{ + m_point = CPoint(x2, y2); +} + +void CLine::Draw(CDC* pDC) +{ + POINT currentpos; + currentpos = pDC->GetCurrentPosition(); // Ermitteln der aktuellen Cursorposition. + + pDC->MoveTo(m_point); // Bewegen des Cursors zum Zielpunkt, ... + CLineTo::Draw(pDC); // ...zeichnen der Linie und... + pDC->MoveTo(currentpos); // ...rueckkehren zum Ausgangspunkt. +} + + +////////////////////////////////////////////////////////////////////// +// CRectangle Class + +CRectangle::CRectangle(RECT rect, COLORREF crFrame, COLORREF crFill) : CShape(NULL, NULL, crFrame) +{ + m_rect = rect; + m_crFill = crFill; +} + +void CRectangle::Draw(CDC* pDC) +{ + if (m_crFill == -1) { // Ein durchsichtiges Rechteck zeichnen. + CBrush brush(m_crColor); // Erstellen eines graphics device interface (GDI) brushes... + pDC->SelectObject(&brush); // ...und auswaehlen des GDI brushes. + pDC->FrameRect(&m_rect, &brush); // Zeichnen... + brush.DeleteObject(); // ..und brush loeschen. + } + else { // Ein ausgefuelltes Rechteck zeichnen. + CPen pen(PS_SOLID, 1, m_crColor); // Zeichenstift fuer den Rand. + pDC->SelectObject(&pen); + + CBrush brush(m_crFill); // Brush fuer die ausgefuellte Flaeche. + pDC->SelectObject(&brush); + + pDC->Rectangle(&m_rect); + + brush.DeleteObject(); + pen.DeleteObject(); + }; +} + + +////////////////////////////////////////////////////////////////////// +// CEllipse Class + +CEllipse::CEllipse(RECT rect, COLORREF crFrame, COLORREF crFill) : CShape(NULL, NULL, crFrame) +{ + m_rect = rect; + m_zoomrect = rect; + m_crFill = crFill; +} + +void CEllipse::Draw(CDC* pDC) +{ + CBrush brush; + CPen pen(PS_SOLID, 1, m_crColor); + pDC->SelectObject(&pen); + + if (m_crFill == -1) // Eine transparente Ellipse zeichnen. + brush.CreateStockObject(NULL_BRUSH); + else // Eine ausgefuellte Ellipse zeichnen. + brush.CreateSolidBrush(m_crFill); + + pDC->SelectObject(&brush); + pDC->Ellipse(&m_zoomrect); + + pen.DeleteObject(); + brush.DeleteObject(); +} + + +////////////////////////////////////////////////////////////////////// +// CTextA Class + +CTextA::CTextA(short x1, short y1, WORD nSize, COLORREF crTextColor, COLORREF crBkground, short nAngle, + UINT nFlags, char* format, va_list argptr) : CShape(x1, y1, crTextColor) +{ + // Die Member-Variablen der Klasse initialisieren. + m_nSize = nSize; + m_crBkground= crBkground; + m_nBkMode = OPAQUE; + m_nAngle = nAngle; + m_nFlags = nFlags; + + // Da die Befehle TextOut und DrawText (in CTextBox benutzt) + // teilweise verschiedene numerische Konstanten fuer die Ausrichtung benutzen, + // jedoch global die einundselben verwendet werden sollen, muessen die flags, + // die sich unterscheiden veraendert werden. + __changeflag(m_nFlags, DT_VCENTER, TA_BASELINE); + __changeflag(m_nFlags, DT_CENTER, TA_CENTER); + + m_string = (char*) malloc(_MAX_STRING); // Einen ausreichend grossen Speicherblock zuweisen. + m_nCount = vsprintf(m_string, format, argptr); // Aus der Argumentenliste einen string generieren. + m_string = (char*) realloc(m_string, m_nCount+1); // Den Speicherblock auf die benoetigte Groesse verkleinern. +} + +void CTextA::Draw(CDC* pDC) +{ + // Setzen einer Schriftart mit speziellen Eignenschaften. + CFont font; + LOGFONT logfont = {m_nSize, 0, m_nAngle, 0, FW_DONTCARE, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial"}; + font.CreatePointFontIndirect(&logfont, pDC); + pDC->SelectObject(&font); + + pDC->SetTextColor(m_crColor); // Textfarbe setzen. + if (m_nBkMode == OPAQUE) // Wenn undurchsichtig, ... + pDC->SetBkColor(m_crBkground); // ...dann Hintergrundfarbe setzen. + pDC->SetBkMode(m_nBkMode); // Festlegen ob durchsichtig oder undurchsichtig. + pDC->SetTextAlign(m_nFlags); // Setzen der Textausrichtung. + pDC->TextOut(m_x, m_y, m_string, m_nCount); // Ausgabe des Textes. + font.DeleteObject(); // Loeschen der Ausgewaehlten Schriftcharakteristik +} + + +////////////////////////////////////////////////////////////////////// +// CTextBox Class + +CTextBox::CTextBox(RECT rect, WORD nSize, COLORREF crText, COLORREF crFrame, COLORREF crFill, + UINT nFormat, char* format, va_list argptr) : CShape(NULL, NULL, crText) +{ + m_rect = rect; + m_nSize = nSize; + m_nFormat = nFormat; + m_crFrame = crFrame; + m_crFill = crFill; + + m_string = (char*) malloc(_MAX_STRING); // Einen ausreichend grossen Speicherblock zuweisen. + m_nCount = vsprintf(m_string, format, argptr); // Aus der Argumentenliste einen string generieren. + m_string = (char*) realloc(m_string, m_nCount+1); // Den Speicherblock auf die benoetigte Groesse verkleinern. +} + +void CTextBox::Draw(CDC* pDC) +{ + // Setzen einer Schriftart mit speziellen Eignenschaften. + CFont font; + font.CreatePointFont(m_nSize, "Arial", pDC); + pDC->SelectObject(&font); + + pDC->SetTextColor(m_crColor); // Textfarbe setzen. + pDC->SetBkMode(TRANSPARENT); // Festlegen auf durchsichtig. + + // Zeichnen eines fuellenden Rechteckes. + CRectangle rectangle(m_rect, m_crFrame, m_crFill); + rectangle.Draw(pDC); + + m_rect.DeflateRect(1, 1, 1, 1); // Verkleinern des virtuellen Rechteckes + // um die Linienbreite des Rahmens. + pDC->SetTextAlign(NULL); // Textausrichtung zuruecksetzen. + pDC->DrawText(m_string, m_nCount, &m_rect, m_nFormat); // Text ausgeben. + + font.DeleteObject(); +} \ No newline at end of file diff --git a/GDE_3_2008/Graphics/Shape.h b/GDE_3_2008/Graphics/Shape.h new file mode 100644 index 0000000..c0cb2f2 --- /dev/null +++ b/GDE_3_2008/Graphics/Shape.h @@ -0,0 +1,196 @@ +// Shape.h: interface for the CShape class and derived classes. +// +////////////////////////////////////////////////////////////////////// +#ifndef _SHAPE_H +#define _SHAPE_H +#define _MAX_STRING 255 // Festlegen der maximal moeglichen string-Laenge (CText, CTextBox) + + +///////////////////////////////////////////////////////////////////////////// +// Die Klasse CShape ist die Basisklasse aller Grafikklassen. +// ALLE Grafikklassen haben diese als "Vorfahren". +// +// Allen Klassen ist gemeinsam, dass mit der Funktion +// Draw() gezeichnet und mit der Funktion Zoom() gezoomt werden kann. +// Diese beiden Funktionen sind aus diesem Grunde auch in der Basisklasse +// CShape mit dem Keywort "virtual" versehen. +class CShape +{ +// Member-Variablen +protected: + short m_x, + m_y; + COLORREF m_crColor; + +public: + CShape(short x, short y, COLORREF crColor = 0); + virtual ~CShape() {}; + virtual void Draw(CDC* pDC) = 0; // virtuelle Klasse zum zeichnen des Objektes + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Diese Klasse dient dazu im Zeichenbereich einen einzelnen Bildpunkt +// mit einer gewuenschten Farbe zu setzen. +class CPixel : public CShape +{ +public: + CPixel(short x, short y, COLORREF crColor) : CShape(x, y, crColor) {}; + virtual ~CPixel() {}; + void Draw(CDC* pDC) { pDC->SetPixel(m_x, m_y, m_crColor); }; + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Diese Klasse dient zum Fuellen des Bereiches des Grafikfensters, +// der den Punkt (x, y) enthaelt und durch die Farbe crBorderColor begrenzt ist, +// mit der Fullfarbe crFillClor1 +class CFill : public CShape +{ +protected: + COLORREF m_crFillColor; + +public: + CFill(short x, short y, COLORREF crFillColor, COLORREF crBorderColor); + virtual ~CFill() {}; + void Draw(CDC* pDC); +}; + + +///////////////////////////////////////////////////////////////////////////// +// Klasse zum Positionieren des Cursors auf einem bestimmten Bildschirmpunkt. +// Diese Klasse muss im Zusammenhang mit der Klasse "LineTo" verwendet werden. +class CMoveTo : public CShape +{ +public: + CMoveTo(short x, short y) : CShape(x, y) {}; + virtual ~CMoveTo() {}; + void Draw(CDC* pDC) { pDC->MoveTo(m_x, m_y); }; + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Klasse zum ziehen einer Linie mit bestimmter Farbe zu einem Zielpunkt. +// Als Ausgangskoordinate dient der Cursor, der mit der Klasse "MoveTo" frei +// bewegt werden kann. +class CLineTo : public CShape +{ +public: + CLineTo(short x, short y, COLORREF crColor) : CShape(x, y, crColor) {}; + virtual ~CLineTo() {}; + void Draw(CDC* pDC); + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Dient zum Zeichnen einer Linie vom Startpunkt (m_x, m_y) aus +// zum Zielpunk (m_point) mit der gewuenschten Farbe crColor. +class CLine : public CLineTo +{ +protected: + POINT m_point; + +public: + CLine(short x1, short y1, short x2, short y2, UINT crColor); + virtual ~CLine() {}; + void Draw(CDC* pDC); + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Zeichnen eines Rechteckes oder nur eines Rechteckrahmens (crFill = -1) +// mit einer gewuenschten Rahmenfarbe bzw. Fullfarbe. +class CRectangle : public CShape +{ +protected: + RECT m_rect; + COLORREF m_crFill; + +public: + CRectangle(RECT rect, COLORREF crFrame, COLORREF crFill = -1); + virtual ~CRectangle() {}; + void Draw(CDC* pDC); + +}; + + +///////////////////////////////////////////////////////////////////////////// +// Zeichnen einer durchsichtigen oder undurchsichtigen (crFill = -1) Ellipse +// mit einer gewuenschten Rahmenfarbe bzw. Fullfarbe. +class CEllipse : public CShape +{ +protected: + RECT m_rect; + RECT m_zoomrect; + COLORREF m_crFill; + +public: + CEllipse(RECT rect, COLORREF crFrame, COLORREF crFill = -1); + virtual ~CEllipse() {}; + void Draw(CDC* pDC); + +}; + + +///////////////////////////////////////////////////////////////////////////// +class CTextA : public CShape +{ +protected: + BYTE m_nBkMode; + WORD m_nSize; + short m_nAngle; + UINT m_nCount, + m_nFlags; + char* m_string; + COLORREF m_crBkground; + +public: + CTextA(short x1, short y1, WORD nSize, COLORREF crTextColor, COLORREF crBkground, short nAngle, UINT nFlags, char* format, va_list argptr); + virtual ~CTextA() { free(m_string); }; + void Draw(CDC* pDC); + +}; + + +///////////////////////////////////////////////////////////////////////////// +class CText : public CTextA +{ +public: + CText(short x1, short y1, WORD nSize, COLORREF crTextColor, char* format, va_list argptr) + : CTextA(x1, y1, nSize, crTextColor, NULL, NULL, NULL, format, argptr) {m_nBkMode = TRANSPARENT;}; + CText(short x1, short y1, WORD nSize, COLORREF crTextColor, COLORREF crBkground, char* format, va_list argptr) + : CTextA(x1, y1, nSize, crTextColor, crBkground, NULL, NULL, format, argptr) {}; + CText(short x1, short y1, WORD nSize, COLORREF crTextColor, short nAngle, UINT nFlags, char* format, va_list argptr) + : CTextA(x1, y1, nSize, crTextColor, NULL, nAngle, nFlags, format, argptr) {m_nBkMode = TRANSPARENT;}; + CText(short x1, short y1, WORD nSize, COLORREF crTextColor, COLORREF crBkground, short nAngle, UINT nFlags, char* format, va_list argptr) + : CTextA(x1, y1, nSize, crTextColor, crBkground, nAngle, nFlags, format, argptr) {}; + +}; + + +///////////////////////////////////////////////////////////////////////////// +class CTextBox : public CShape +{ +protected: + CRect m_rect; + WORD m_nSize; + BYTE m_nFormat; + RECT m_nRect; + COLORREF m_crFrame, + m_crFill; + WORD m_nCount; + char* m_string; + +public: + CTextBox(RECT rect, WORD nSize, COLORREF crText, COLORREF crFrame, + COLORREF crFill, UINT nFormat, char* format, va_list argptr); + virtual ~CTextBox() { free(m_string); }; + void Draw(CDC* pDC); + +}; +#endif \ No newline at end of file diff --git a/GDE_3_2008/MainFrm.cpp b/GDE_3_2008/MainFrm.cpp new file mode 100644 index 0000000..84a3d2b --- /dev/null +++ b/GDE_3_2008/MainFrm.cpp @@ -0,0 +1,99 @@ +// MainFrm.cpp : Implementierung der Klasse CMainFrame +// +#include "stdafx.h" +#include "GDE_3.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + ON_WM_CREATE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // Statusleistenanzeige + ID_INDICATOR_CURPOS, + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + + +// CMainFrame Erstellung/Zerstörung + +CMainFrame::CMainFrame() +{ + // TODO: Hier Code für die Memberinitialisierung einfügen +} + +CMainFrame::~CMainFrame() +{ +} + + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Symbolleiste konnte nicht erstellt werden\n"); + return -1; // Fehler bei Erstellung + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Statusleiste konnte nicht erstellt werden\n"); + return -1; // Fehler bei Erstellung + } + // TODO: Löschen Sie diese drei Zeilen, wenn Sie nicht möchten, dass die Systemleiste andockbar ist + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Ändern Sie hier die Fensterklasse oder die Darstellung, indem Sie + // CREATESTRUCT cs modifizieren. + + return TRUE; +} + + +// CMainFrame Diagnose + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CMainFrame Meldungshandler + diff --git a/GDE_3_2008/MainFrm.h b/GDE_3_2008/MainFrm.h new file mode 100644 index 0000000..7c4ac98 --- /dev/null +++ b/GDE_3_2008/MainFrm.h @@ -0,0 +1,43 @@ +// MainFrm.h : Schnittstelle der Klasse CMainFrame +// +#ifndef _MAINFRM_H +#define _MAINFRM_H + +#pragma once +class CMainFrame : public CFrameWnd +{ + +protected: // Nur aus Serialisierung erstellen + CMainFrame(); + DECLARE_DYNCREATE(CMainFrame) + +// Attribute +public: + +// Operationen +public: + +// Überschreibungen +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementierung +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +public: + CStatusBar m_wndStatusBar; +protected: // Eingebundene Elemente der Steuerleiste + CToolBar m_wndToolBar; + +// Generierte Funktionen für die Meldungstabellen +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + DECLARE_MESSAGE_MAP() +}; + +#endif diff --git a/GDE_3_2008/PrimImplikant.cpp b/GDE_3_2008/PrimImplikant.cpp new file mode 100644 index 0000000..2087a9d --- /dev/null +++ b/GDE_3_2008/PrimImplikant.cpp @@ -0,0 +1,36 @@ +#include +#include +#include "PrimImplikanten.h" + +using namespace std; + +/* + +PrimImplikant::PrimImplikant(int input) +{ + implikant.push_back(input); +} +*/ +PrimImplikant::PrimImplikant(string input) +{ + vector arr; + + + +} +bool PrimImplikant::valueAt(int x) { +} + +int PrimImplikant::parser(string input){ // Analyser + string text = new char [input.size()]; + //string text2 = new char [input.size()]; + text= input; + char yytext[]= ""; + for( int i=0;i +#include +#include "PrimImplikanten.h" + +using namespace std; + +class PrimImplikantCollection{ +public: + void Add(PrimImplikant &pi); + //void Add(string input); + void Add(int input); + + bool ValueAt(int position); + + PrimImplikant SolveNextHazard(); + +private: + vector PIVector; +} + +#endif \ No newline at end of file diff --git a/GDE_3_2008/PrimImplikanten.h b/GDE_3_2008/PrimImplikanten.h new file mode 100644 index 0000000..34d81d2 --- /dev/null +++ b/GDE_3_2008/PrimImplikanten.h @@ -0,0 +1,25 @@ +#ifndef PRIMIMPLIKANTEN +#define PRIMIMPLIKANTEN + +#include +#include +#include + +using namespace std; + +class PrimImplikant +{ +public: + PrimImplikant(string input); + //PrimImplikant(int input); + + bool valueAt(int position); + + +private: + map implikant; +} + + + +#endif \ No newline at end of file diff --git a/GDE_3_2008/ReadMe.txt b/GDE_3_2008/ReadMe.txt new file mode 100644 index 0000000..2d9097b --- /dev/null +++ b/GDE_3_2008/ReadMe.txt @@ -0,0 +1,103 @@ +================================================================================ + MICROSOFT FOUNDATION CLASS LIBRARY : GDE_3 Projektübersicht +================================================================================ + +Der Anwendungs-Assistent hat diese GDE_3-Anwendung erstellt. +Diese Anwendung zeigt die prinzipielle Anwendung der Microsoft Foundation Classes +und dient als Ausgangspunkt für die Erstellung Ihrer eigenen Anwendungen. + +Diese Datei enthält die Zusammenfassung der Bestandteile aller Dateien, die +Ihre GDE_3-Anwendung bilden. + +GDE_3.vcproj + Dies ist die Hauptprojektdatei für VC++-Projekte, die vom Anwendungs-Assistenten + erstellt wird. Sie enthält Informationen über die Version von Visual C++, mit der + die Datei generiert wurde, über die Plattformen, Konfigurationen und Projektfeatures, + die mit dem Anwendungs-Assistenten ausgewählt wurden. + +GDE_3.h + Hierbei handelt es sich um die Haupt-Headerdatei der Anwendung. Diese enthält + andere projektspezifische Header (einschließlich Resource.h) und deklariert die + CGDE_3App-Anwendungsklasse. + +GDE_3.cpp + Hierbei handelt es sich um die Haupt-Quellcodedatei der Anwendung. Diese enthält die + Anwendungsklasse CGDE_3App. + +GDE_3.rc + Hierbei handelt es sich um eine Auflistung aller Ressourcen von Microsoft Windows, die + vom Programm verwendet werden. Sie enthält die Symbole, Bitmaps und Cursors, die im + Unterverzeichnis RES gespeichert sind. Diese Datei lässt sich direkt in Microsoft + Visual C++ bearbeiten. Ihre Projektressourcen befinden sich in 1031. + +res\GDE_3.ico + Dies ist eine Symboldatei, die als Symbol für die Anwendung verwendet wird. Dieses + Symbol wird durch die Haupt-Ressourcendatei GDE_3.rc eingebunden. + +res\GDE_3.rc2 + Diese Datei enthält Ressourcen, die nicht von Microsoft Visual C++ bearbeitet wurden. + In dieser Datei werden alle Ressourcen gespeichert, die vom Ressourcen-Editor nicht bearbeitet + werden können. +///////////////////////////////////////////////////////////////////////////// + +Für das Hauptfenster: + Das Projekt enthält eine MFC-Standardschnittstelle. +MainFrm.h, MainFrm.cpp + Diese Dateien enthalten die Frame-Klasse CMainFrame, die von + CFrameWnd abgeleitet wird und steuert alle SDI-Framefeatures. +res\Toolbar.bmp + Diese Bitmap-Datei wird zum Erstellen unterteilter Bilder für die Symbolleiste verwendet. + Die erste Symbol- und Statusleiste wird in der Klasse CMainFrame + erstellt. Bearbeiten Sie diese Bitmap der Symbolleiste mit dem Ressourcen-Editor, und + aktualisieren Sie das Array IDR_MAINFRAME TOOLBAR in GDE_3.rc, um + Schaltflächen für die Symbolleiste hinzuzufügen. +///////////////////////////////////////////////////////////////////////////// + +Der Anwendungs-Assistent erstellt einen Dokumenttyp und eine Ansicht: + +GDE_3Doc.h, GDE_3Doc.cpp - das Dokument + Diese Dateien enthalten die Klasse CGDE_3Doc. Bearbeiten Sie diese Dateien, + um Ihre speziellen Dokumentdaten hinzuzufügen und das Speichern und Laden von + Dateien zu implementieren (mit CGDE_3Doc::Serialize). +GDE_3View.h, GDE_3View.cpp - die Ansicht des Dokuments + Diese Dateien enthalten die Klasse CGDE_3View. + CGDE_3View-Objekte werden verwendet, um CGDE_3Doc-Objekte anzuzeigen. +///////////////////////////////////////////////////////////////////////////// + +Weitere Features: + +ActiveX-Steuerelemente + Die Anwendung unterstützt die Verwendung von ActiveX-Steuerelementen. + +Unterstützung für das Drucken und die Seitenansicht + Der Anwendungs-Assistent hat den Code zum Verarbeiten der Befehle "Drucken", "Seite einrichten" und + "Seitenansicht" durch Aufrufen der Memberfuntkionen in der CView-Klasse der MFC-Bibliothek generiert. +///////////////////////////////////////////////////////////////////////////// + +Weitere Standarddateien: + +StdAfx.h, StdAfx.cpp + Mit diesen Dateien werden vorkompilierte Headerdateien (PCH) mit der Bezeichnung + GDE_3.pch und eine vorkompilierte Typdatei mit der Bezeichnung + StdAfx.obj erstellt. + +Resource.h + Dies ist die Standard-Headerdatei, die neue Ressourcen-IDs definiert. + Microsoft Visual C++ liest und aktualisiert diese Datei. + +///////////////////////////////////////////////////////////////////////////// + +Weitere Hinweise: + +Der Anwendungs-Assistent verwendet "TODO:", um die Stellen anzuzeigen, +an denen Sie Erweiterungen oder Anpassungen vornehmen können. + +Wenn Ihre Anwendung die MFC in einer gemeinsam genutzten DLL verwendet und +eine andere als die aktuell auf dem Betriebssystem eingestellte Sprache verwendet, muss +die entsprechend lokalisierte Ressource MFC70XXX.DLL von der Microsoft Visual C++ CD-ROM +in das Verzeichnis system oder system32 kopiert und in MFCLOC.DLL umbenannt werden +("XXX" steht für die Abkürzung der Sprache. So enthält beispielsweise MFC70DEU.DLL die ins Deutsche +übersetzten Ressourcen.) Anderenfalls werden einige Oberflächenelemente Ihrer Anwendung +in der Sprache des Betriebssystems angezeigt. + +///////////////////////////////////////////////////////////////////////////// diff --git a/GDE_3_2008/Readme2.txt b/GDE_3_2008/Readme2.txt new file mode 100644 index 0000000..5cc832f --- /dev/null +++ b/GDE_3_2008/Readme2.txt @@ -0,0 +1,11 @@ +//GDE3_3 +1. Abgebrochene Zeichenaktion behoben (z.B. IBM Notebook) +2. Die Applikation muss jetzt mit dem RUN Button gestartet werden. + Es gibt zusätzlich eine Funktion StopProcess(), die in die Benutzerapplikation eingebaut werden kann. + (z.B. Einleseschleife) + Wird auf den Stop Button gedrückt wird ein Flag gesetzt, das im StopProzess abgefragt wird. + Dann gibt StopProcess() eine 1 zurück sonst 0. An die Abfrage kann dann ein break gehängt werden, + um die laufende Aktion zu beenden. +3. Der Thread, der den Benutzerprozess enthält, wird jetzt in der Regel sauber angehalten. +4. Die Ausgabe kann in eine bmp Datei gespeichert und auch wieder eingelesen werden. + Paint kann die so erzeugte Datei ebenfalls darstellen. diff --git a/GDE_3_2008/User.h b/GDE_3_2008/User.h new file mode 100644 index 0000000..4ec30aa --- /dev/null +++ b/GDE_3_2008/User.h @@ -0,0 +1,7 @@ +// User.h : header file +// +// Das Benutzer interface. +///////////////////////////////////////////////////////////////////////////// + +void user_main(); // Funktion in der der Benutzer seinen eigenen + // Code programmieren kann. \ No newline at end of file diff --git a/GDE_3_2008/res/GDE_3.ico b/GDE_3_2008/res/GDE_3.ico new file mode 100644 index 0000000..8a84ca3 Binary files /dev/null and b/GDE_3_2008/res/GDE_3.ico differ diff --git a/GDE_3_2008/res/GDE_3.manifest b/GDE_3_2008/res/GDE_3.manifest new file mode 100644 index 0000000..c125e5e --- /dev/null +++ b/GDE_3_2008/res/GDE_3.manifest @@ -0,0 +1,22 @@ + + + +Fügen Sie hier die Anwendungsbeschreibung ein + + + + + + diff --git a/GDE_3_2008/res/GDE_3.rc2 b/GDE_3_2008/res/GDE_3.rc2 new file mode 100644 index 0000000..9f90d0b --- /dev/null +++ b/GDE_3_2008/res/GDE_3.rc2 @@ -0,0 +1,13 @@ +// +// GDE_3.RC2 - Ressourcen, die Microsoft Visual C++ nicht direkt bearbeitet +// + +#ifdef APSTUDIO_INVOKED +#error Diese Datei kann nicht in Microsoft Visual C++ bearbeitet werden. +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Fügen Sie hier manuell bearbeitete Ressourcen hinzu... + +///////////////////////////////////////////////////////////////////////////// diff --git a/GDE_3_2008/res/GDE_3Doc.ico b/GDE_3_2008/res/GDE_3Doc.ico new file mode 100644 index 0000000..2a1f1ae Binary files /dev/null and b/GDE_3_2008/res/GDE_3Doc.ico differ diff --git a/GDE_3_2008/res/Toolbar.bmp b/GDE_3_2008/res/Toolbar.bmp new file mode 100644 index 0000000..7960b39 Binary files /dev/null and b/GDE_3_2008/res/Toolbar.bmp differ diff --git a/GDE_3_2008/res/Toolbar.bmpold b/GDE_3_2008/res/Toolbar.bmpold new file mode 100644 index 0000000..d501723 Binary files /dev/null and b/GDE_3_2008/res/Toolbar.bmpold differ diff --git a/GDE_3_2008/resource.h b/GDE_3_2008/resource.h new file mode 100644 index 0000000..483c94f --- /dev/null +++ b/GDE_3_2008/resource.h @@ -0,0 +1,25 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by GDE_3.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_MAINFRAME 128 +#define IDR_GDE_3TYPE 129 +#define ID_BUTTONZOOMOUT 32771 +#define ID_BUTTONZOOMIN 32772 +#define ID_BUTTONZOOMFIT 32773 +#define ID_STARTBUTTON 32776 +#define ID_STOPBUTTON 32777 +#define ID_INDICATOR_CURPOS 32778 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32779 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/GDE_3_2008/stdafx.cpp b/GDE_3_2008/stdafx.cpp new file mode 100644 index 0000000..1b9befa --- /dev/null +++ b/GDE_3_2008/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet +// GDE_3.pch ist der vorcompilierte Header +// stdafx.obj enthält die vorcompilierte Typinformation + +#include "stdafx.h" + + diff --git a/GDE_3_2008/stdafx.h b/GDE_3_2008/stdafx.h new file mode 100644 index 0000000..ae85a43 --- /dev/null +++ b/GDE_3_2008/stdafx.h @@ -0,0 +1,47 @@ +// stdafx.h : Includedatei für Standardsystem-Includedateien, +// oder häufig verwendete, projektspezifische Includedateien, +// die nur in unregelmäßigen Abständen geändert werden. + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Selten verwendete Teile der Windows-Header nicht einbinden +#endif + +// Ändern Sie folgende Definitionen für Plattformen, die älter als die unten angegebenen sind. +// Unter MSDN finden Sie die neuesten Informationen über die entsprechenden Werte für die unterschiedlichen Plattformen. +#ifndef WINVER // Lassen Sie die Verwendung von Features spezifisch für Windows 95 und Windows NT 4 oder später zu. +#define WINVER 0x0400 // Ändern Sie den entsprechenden Wert, um auf Windows 98 und mindestens Windows 2000 abzuzielen. +#endif + +#ifndef _WIN32_WINNT // Lassen Sie die Verwendung von Features spezifisch für Windows NT 4 oder später zu. +//#define _WIN32_WINNT 0x0400 // Ändern Sie den entsprechenden Wert, um auf Windows 98 und mindestens Windows 2000 abzuzielen. +#define _WIN32_WINNT 0x0500 // Ändern Sie den entsprechenden Wert, um auf Windows 98 und mindestens Windows 2000 abzuzielen. +#endif + +#ifndef _WIN32_WINDOWS // Lassen Sie die Verwendung von Features spezifisch für Windows 98 oder später zu. +#define _WIN32_WINDOWS 0x0410 // Ändern Sie den entsprechenden Wert, um auf mindestens Windows Me abzuzielen. +#endif + +#ifndef _WIN32_IE // Lassen Sie die Verwendung von Features spezifisch für IE 4.0 oder später zu. +#define _WIN32_IE 0x0400 // Ändern Sie den entsprechenden Wert, um auf mindestens IE 5.0 abzuzielen. +#endif + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // einige CString-Konstruktoren sind explizit + +// Deaktiviert das Ausblenden von einigen häufigen und oft ignorierten Warnungen +#define _AFX_ALL_WARNINGS +#include "memory.h" + +#include // MFC-Kern- und -Standardkomponenten +#include // MFC-Erweiterungen +#include // MFC-Automatisierungsklassen + +#include // MFC-Unterstützung für allgemeine Steuerelemente von Internet Explorer 4 + +#include +#include +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC-Unterstützung für allgemeine Windows-Steuerelemente +#endif // _AFX_NO_AFXCMN_SUPPORT + diff --git a/GDE_3_2008/user.cpp b/GDE_3_2008/user.cpp new file mode 100644 index 0000000..3bceeee --- /dev/null +++ b/GDE_3_2008/user.cpp @@ -0,0 +1,153 @@ +// User.cpp : header file +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "user.h" +#include "graphics\graphicfunctions.h" + +#include +#include + +#ifndef _USE_OLD_OSTREAMS +using namespace std; +#endif + + + +#include "math.h" + +#define _pi 3.1415926535 // Die Zahl Pi. +#define _180_durch_pi 57.2957795147 // = 180 * pi. Dient zur Laufzeitoptinierung. +#define _sinus(winkel) sin((winkel) / _180_durch_pi) // Funktion im Gradmass. +#define _cosinus(winkel) cos((winkel) / _180_durch_pi) // Funktion im Gradmass. + +COLORREF Colref[]={BLACK,RED,GREEN,BLUE,YELLOW,BROWN}; +int Colind=0; + +struct _BAUM { // Die fuenf Eingangsparameter des Baumes. + int Tiefe; + int Neigung_links; + float Wachstum_links; + int Neigung_rechts; + float Wachstum_rechts; + void WerteKorrigieren() + { + if (Wachstum_links > 1) Wachstum_links = 1 / Wachstum_links; + if (Wachstum_rechts > 1) Wachstum_rechts = 1 / Wachstum_rechts; + Neigung_rechts = -Neigung_rechts; + }; +} baum; + + +void Zeichne_Ast(int x, int y, float n, float Tiefe, float Laenge) +{ + int x_rel; + int y_rel; + if(StopProcess())return; + if (Tiefe > 1) { // Stopbedingung fuer die Rekursion. + // Zeichnen des linken Astes. + x_rel = (int)(Laenge * _sinus(n + baum.Neigung_links)); // Berechnen der x-Koordinate. + y_rel = (int)(Laenge * _cosinus(n + baum.Neigung_links)); // Berechnen der y-Koordinate. + COLORREF cref=Colref[Colind++]; if(Colind>5)Colind=0; + lineto(x-x_rel, y-y_rel, cref); // Zeichnen + // Rekursion!! Zeichnen des nachfolgenden Astes. + //Sleep(5);updatescr(); + Zeichne_Ast(x-x_rel, y-y_rel, n+baum.Neigung_links, Tiefe-1, Laenge*baum.Wachstum_links); + moveto(x,y); // Cursor zur Anfangsposition zuruecksetzen. + + // Zeichnen des rechten Astes. + x_rel = (int)(Laenge * _sinus(n + baum.Neigung_rechts)); + y_rel = (int)(Laenge * _cosinus(n + baum.Neigung_rechts)); + cref=Colref[Colind++];if(Colind>5)Colind=0; + lineto(x-x_rel, y-y_rel, cref); + //Sleep(5);updatescr(); + Zeichne_Ast(x-x_rel, y-y_rel, n+baum.Neigung_rechts, Tiefe-1, Laenge*baum.Wachstum_rechts); + } + +} + +void Zeichne_Baum() +{ + int Weite, Hoehe, x, y, StammLaenge; + + // Berechnen des Gesamtwachstums. + float GesamtWachstum = 1; + float Wachstum = (baum.Wachstum_links > baum.Wachstum_rechts) ? baum.Wachstum_links : baum.Wachstum_rechts; + float WT = 1; + for (int i=1; i b-120) && (x < b-5)) && + ((y > h-40) && (y < h-5)) + )) { + printf("."); + if(StopProcess())break; + }; + + printf("######################################\n\n"); + clrscr(); + printf("######################################\n\n"); +} + + +void user_main() +{ + int ww,hh; + set_windowpos(0,0,600,400); + while(1){ // Endlosschleife + get_windowsize(&ww,&hh); + set_drawarea(ww,hh); // Setzen des Zeichenbereiches + clrscr(); + cout <<"Startvorschlag Tiefe:10\nNeigung links:15,Wachstum links:0.7\nNeigung rechts: 18,Wachstum rechts:0.8\n"; + cout <<"Tiefe ( >1 ): "; + cin >> baum.Tiefe; // Die Tiefe einlesen. + + cout<<"Neigung nach links in Grad: "; // Die Neigung links einlesen. + cin >> baum.Neigung_links; + + cout<<"Wachstum nach links ( <1 ): ";// Das Wachstum links einlesen... + cin >>baum.Wachstum_links; + + cout<<"Neigung nach rechts in Grad: "; + cin>>baum.Neigung_rechts; + + cout<<"Wachstum nach rechts ( <1 ): "; + cin>>baum.Wachstum_rechts; + + baum.WerteKorrigieren(); // Die Werte fuer das Wachstum ueberpruefen + // und wennn notwendig korrigieren. + Zeichne_Baum(); // Den Baum zeichnen. + cout << "Baum gezeichnet\n"; + Restart(); // Den "Restart"-Button malen und auf eine Aktivierung warten. + if(StopProcess())break; + + } +} \ No newline at end of file diff --git a/VSMacros80/Samples/Samples.vsmacros b/VSMacros80/Samples/Samples.vsmacros new file mode 100644 index 0000000..f0d90f1 Binary files /dev/null and b/VSMacros80/Samples/Samples.vsmacros differ