Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Main Class Reference

#include <Main.h>

Collaboration diagram for Main:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Main (int argc, char *argv[])
 ~Main ()
bool IsOK ()
void MainLoop ()
MainWindowGetWindow ()

Private Member Functions

void AddForm (IOMessage *)
void KeyboardEvent (SDL_KeyboardEvent &)
void UserEvent (SDL_UserEvent &)

Private Attributes

SDLControl m_clControl
MainWindowm_pclMainWindow
double m_angle1
double m_angle2

Constructor & Destructor Documentation

Main::Main int  argc,
char *  argv[]
 

Definition at line 45 of file Main.cpp.

References DEB, IsOK(), m_clControl, m_pclMainWindow, Main(), XMAX, and YMAX.

Referenced by Main().

00046 :GuiEvent() 00047 ,m_clControl(argc,argv,XMAX,YMAX) //m_clInitSDL(argc,argv) 00048 ,m_pclMainWindow(NULL) 00049 ,m_angle1(90) 00050 ,m_angle2(1) 00051 { 00052 if (IsOK()) 00053 { 00054 DEB(printf("Allt OK\n");) 00055 m_pclMainWindow = new MainWindow( &m_clControl ); 00056 } 00057 else 00058 { 00059 DEB(printf("Ej OK\n");) 00060 } 00061 00062 // init gui event 00063 if (IsOK()) 00064 { 00065 SetRootSurface(m_pclMainWindow); 00066 SetSDLControl(&m_clControl); 00067 } 00068 }

Main::~Main  ) 
 

Definition at line 71 of file Main.cpp.

References m_pclMainWindow.

00072 { 00073 if (m_pclMainWindow) 00074 { 00075 delete m_pclMainWindow; 00076 } 00077 }


Member Function Documentation

void Main::AddForm IOMessage *   )  [private]
 

Definition at line 96 of file Main.cpp.

References AddForm().

Referenced by AddForm().

00097 { 00098 // m_forms.insert(m_forms.end(), (Form::Form *)pclForm); 00099 }

MainWindow * Main::GetWindow  ) 
 

Definition at line 240 of file Main.cpp.

References m_pclMainWindow.

00241 { 00242 return m_pclMainWindow; 00243 }

bool Main::IsOK  ) 
 

Definition at line 80 of file Main.cpp.

References m_clControl.

Referenced by Main().

00081 { 00082 #ifdef WIN32 00083 if (!m_clWinSock.IsOK()) 00084 { 00085 return false; 00086 } 00087 #endif 00088 if (!m_clControl.IsOK()) 00089 { 00090 return false; 00091 } 00092 return true; 00093 }

void Main::KeyboardEvent SDL_KeyboardEvent &   )  [private]
 

Definition at line 153 of file Main.cpp.

References KeyboardEvent(), and m_pclMainWindow.

Referenced by KeyboardEvent().

00154 { 00155 if (e.type == SDL_KEYDOWN) 00156 { 00157 switch (e.keysym.sym) 00158 { 00159 case SDLK_F2: 00160 m_pclMainWindow -> ShowText(); 00161 break; 00162 case SDLK_ESCAPE: 00163 m_pclMainWindow -> ShowMenu(); 00164 break; 00165 00166 // mandel test 00167 case SDLK_PAGEUP: 00168 m_pclMainWindow -> IncreaseBase(); 00169 break; 00170 case SDLK_PAGEDOWN: 00171 m_pclMainWindow -> DecreaseBase(); 00172 break; 00173 case SDLK_UP: 00174 Globals::m_zy -= Globals::m_scale; 00175 m_pclMainWindow -> Redraw(); 00176 break; 00177 case SDLK_DOWN: 00178 Globals::m_zy += Globals::m_scale; 00179 m_pclMainWindow -> Redraw(); 00180 break; 00181 case SDLK_RIGHT: 00182 Globals::m_zx += Globals::m_scale; 00183 m_pclMainWindow -> Redraw(); 00184 break; 00185 case SDLK_LEFT: 00186 Globals::m_zx -= Globals::m_scale; 00187 m_pclMainWindow -> Redraw(); 00188 break; 00189 case SDLK_HOME: 00190 Globals::m_scale *= 1.05; 00191 m_pclMainWindow -> Redraw(); 00192 break; 00193 case SDLK_END: 00194 Globals::m_scale *= 0.95; 00195 m_pclMainWindow -> Redraw(); 00196 break; 00197 00198 default: 00199 GuiEvent::KeyboardEvent(e); 00200 break; 00201 } 00202 } 00203 else 00204 { 00205 GuiEvent::KeyboardEvent(e); 00206 } 00207 }

void Main::MainLoop  ) 
 

Definition at line 210 of file Main.cpp.

References m_pclMainWindow.

Referenced by main().

00211 { 00212 SDL_Event event; 00213 00214 // draw surfaces in local pixel surface 00215 // flyttat till basklass 00216 // m_pclMainWindow -> DrawAll(); 00217 // m_pclMainWindow -> CalculateAbsolute(); 00218 00219 // m_pclMainWindow -> ShowText(); 00220 // pprintf("Welcome...\n"); 00221 00222 event.user.type = SDL_USEREVENT; 00223 event.user.code = SDL_USEREVENT_PAINT; 00224 event.user.data1 = NULL; 00225 event.user.data2 = NULL; 00226 SDL_PushEvent(&event); 00227 00228 event.type = SDL_KEYDOWN; 00229 event.key.keysym.sym = SDLK_F2; 00230 SDL_PushEvent(&event); 00231 00232 SetDefaultFocus( m_pclMainWindow -> GetInput() ); 00233 00234 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 00235 00236 EventLoop(); 00237 }

void Main::UserEvent SDL_UserEvent &   )  [private]
 

Definition at line 102 of file Main.cpp.

References m_pclMainWindow, SDL_USEREVENT_ADDFORM, SDL_USEREVENT_DISCONNECT, UICOMMAND_QUIT, UICOMMAND_XMLSAVE, and UserEvent().

Referenced by UserEvent().

00103 { 00104 switch (e.code) 00105 { 00106 case SDL_USEREVENT_ADDFORM: 00107 { 00108 Form::Form *pclForm = reinterpret_cast<Form::Form *>(e.data1); 00109 pclForm -> FormCreateDialog(m_pclMainWindow); 00110 // AddForm( pclForm ); 00111 } 00112 break; 00113 case SDL_USEREVENT_DISCONNECT: 00114 m_pclMainWindow -> Disconnect(); 00115 m_pclMainWindow -> SetDirty(true); 00116 break; 00117 case SDL_USEREVENT_UICOMMAND: 00118 Surface *pclSurface; 00119 long cmd; 00120 memmove(&pclSurface,&e.data1,4); 00121 memmove(&cmd,&e.data2,4); 00122 switch (cmd) 00123 { 00124 case UICOMMAND_QUIT: 00125 SetQuit(true); 00126 break; 00127 case UICOMMAND_XMLSAVE: 00128 { 00129 m_pclMainWindow -> SaveDialogs(); 00130 /* 00131 FILE *fil; 00132 if ((fil = fopen("mainwindow.xml","wt")) != NULL) 00133 { 00134 fprintf(fil,"<?xml version=\"1.0\"?>\n"); 00135 m_pclMainWindow -> Dump(fil); 00136 fclose(fil); 00137 } 00138 */ 00139 } 00140 break; 00141 default: 00142 GuiEvent::UserEvent(e); 00143 } 00144 break; 00145 00146 default: 00147 GuiEvent::UserEvent(e); 00148 break; 00149 } 00150 }


Member Data Documentation

double Main::m_angle1 [private]
 

Definition at line 72 of file Main.h.

double Main::m_angle2 [private]
 

Definition at line 73 of file Main.h.

SDLControl Main::m_clControl [private]
 

Definition at line 68 of file Main.h.

Referenced by IsOK(), and Main().

MainWindow* Main::m_pclMainWindow [private]
 

Definition at line 69 of file Main.h.

Referenced by GetWindow(), KeyboardEvent(), Main(), MainLoop(), UserEvent(), and ~Main().


The documentation for this class was generated from the following files:
Generated for SDL C++ GUI by doxygen 1.3.6