#include "camtypes.h"
#include "menuitem.h"
#include "menucmds.h"
#include "menupref.h"
#include "menuops.h"
#include "oilfiles.h"
Go to the source code of this file.
Defines | |
#define | new CAM_DEBUG_NEW |
Functions | |
DECLARE_SOURCE ("$Revision: 1550 $") | |
MenuItem * | CreateMenuItem (TCHAR *OpToken, UINT32 ParentId, BOOL Separator) |
Creates a MenuItem given an Optoken. | |
void | ClearArray (TCHAR buffer[], INT32 size) |
Initialises a Character Array with Nulls. | |
MenuItem * | GetMenuPreferences (UINT32 ResourceID) |
Parses a Menu Script representing the Camelot Default Menus. | |
BOOL | GetKeyword (CCResTextFile *pResScript, TCHAR keyword[], INT32 size) |
Parses a Menu Script Keyword. | |
BOOL | GetToken (CCResTextFile *pMenuScript, TCHAR OpToken[], INT32 TokenSize) |
Parses a Menu Script Token. | |
BOOL | GetSeparator (CCResTextFile *pMenuScript, const String &separator_sym, TCHAR SepKeyword[], INT32 size) |
Parses a Menu Script Menu Separator Token. | |
Variables | |
UINT32 | WindowMenuID |
|
Definition at line 117 of file menupref.cpp. |
|
Initialises a Character Array with Nulls.
Definition at line 139 of file menupref.cpp. 00140 { 00141 ::memset(buffer, 0, size * sizeof(buffer[0])); 00142 }
|
|
Creates a MenuItem given an Optoken.
Definition at line 321 of file menupref.cpp. 00322 { 00323 OpDescriptor *Operation = OpDescriptor::FindOpDescriptor(OpToken); 00324 00325 PORTNOTE( "other", "Use DO_NOTHING op for menuitem, if optoken not found" ); 00326 #if defined(EXCLUDE_FROM_XARALX) 00327 if( NULL == Operation ) 00328 Operation = OpDescriptor::FindOpDescriptor( OPTOKEN_DO_NOTHING ); 00329 #endif 00330 00331 if (!Operation) 00332 { 00333 String_256 ErrorMsg(_R(IDE_OPNOTFOUND)); 00334 ErrorMsg += OpToken; 00335 00336 Error::SetError(_R(IDE_OPNOTFOUND), ErrorMsg, 0); 00337 InformError(); 00338 00339 return NULL; 00340 } 00341 else 00342 { 00343 MenuItem *pMenuItem; 00344 00345 // Create an instance of a MenuItem 00346 pMenuItem = new MenuItem( ParentId, 00347 Operation, 00348 Separator 00349 ); 00350 00351 ERROR3IF( pMenuItem==NULL, "CreateMenuItem failed" ); 00352 00353 return pMenuItem; 00354 } 00355 }
|
|
|
|
Parses a Menu Script Keyword.
Definition at line 373 of file menupref.cpp. 00374 { 00375 // Get Keyword 00376 TCHAR ch; 00377 INT32 i = 0; 00378 00379 ClearArray(keyword, size); 00380 00381 pResScript->read(ch); 00382 00383 // if not a keyword return false! 00384 if (!String::IsAlpha(ch) && (!pResScript->eof())) 00385 return FALSE; 00386 00387 while (String::IsAlpha(ch) && !pResScript->eof() && i < size) 00388 { 00389 keyword[i++] = ch; 00390 pResScript->read(ch); 00391 } 00392 00393 if (!pResScript->eof()) 00394 return TRUE; 00395 else 00396 { 00397 // TRACEUSER( "JustinF", _T("Menu GetKeyword() - read %s\n"), keyword); 00398 return FALSE; 00399 } 00400 }
|
|
Parses a Menu Script representing the Camelot Default Menus.
Definition at line 164 of file menupref.cpp. 00165 { 00166 // Keyword Buffer 00167 const INT32 keywordSize = 10; 00168 TCHAR keyword[keywordSize]; 00169 00170 // Token Buffer 00171 const INT32 TokenSize = 30; 00172 TCHAR OpToken[TokenSize]; 00173 00174 // Lexical Tokens 00175 const String_256 menu_sym = "MENU"; 00176 const String_256 submenu_sym = "SUBMENU"; 00177 const String_256 menuitem_sym = "MENUITEM"; 00178 const String_256 end_sym = "END"; 00179 const String_256 separator_sym = "SEPARATOR"; 00180 00181 CCResTextFile MenuScript; // Resource File 00182 00183 // Open Resource File 00184 MenuScript.open(ResourceID, _R(IDT_CAM_MENU_RES)); 00185 00186 // Stack of all the Menus and SubMenus currently in Scope! 00187 List MenuStack; 00188 00189 MenuItem* pCurMenu = NULL; // Menu Currently in Scope 00190 00191 MenuItem* pMenu = NULL; 00192 MenuItem* pSubMenu; 00193 MenuItem* pMenuItem; 00194 00195 while ((MenuScript.isOpen()) && (!MenuScript.eof())) 00196 { 00197 ClearArray(keyword, keywordSize); 00198 00199 //Get The Keyword 00200 if (GetKeyword(&MenuScript, keyword, keywordSize)) 00201 { 00202 // MENU reserved word 00203 if (menu_sym == keyword) 00204 { 00205 ERRORIF((!GetToken(&MenuScript, OpToken, TokenSize)), 00206 _R(IDE_SYNTAX_ERROR), 00207 NULL); 00208 00209 pMenu = new MenuItem(OpToken); 00210 00211 if (pMenu==NULL) 00212 { 00213 TRACEALL( _T("GetMenuPrefs: failed to allocate MenuItem")); 00214 break; // willeventually return NULL 00215 } 00216 00217 pCurMenu = pMenu; 00218 } 00219 // SUBMENU reserved word 00220 else if (submenu_sym == keyword) 00221 { 00222 ERRORIF((!GetToken(&MenuScript, OpToken, TokenSize)), 00223 _R(IDE_SYNTAX_ERROR), 00224 NULL); 00225 00226 TRACEUSER( "luke", _T("SUBMENU \"%s\" \"%s\"\n"), OpToken, OPTOKEN_DEBUG_MENU ); 00227 00228 #if !defined(_DEBUG) 00229 // Remove DEBUG menu 00230 if( 0 == camStrcmp( OpToken, OPTOKEN_DEBUG_MENU ) ) 00231 { 00232 TRACEUSER( "luke", _T(">-SUBMENU %s\n"), OPTOKEN_DEBUG_MENU ); 00233 MenuStack.AddHead(pCurMenu); //Push Current Menu onto stack 00234 pCurMenu = NULL; 00235 continue; 00236 } 00237 #endif 00238 00239 pSubMenu = CreateMenuItem( OpToken, 00240 pCurMenu->GetMenuId(), 00241 GetSeparator( &MenuScript, 00242 separator_sym, 00243 keyword, 00244 keywordSize) 00245 ); 00246 00247 // stop now if run out of memory 00248 if (pSubMenu==NULL) 00249 break; 00250 00251 // Get the ID for the Window Menu 00252 if (String(OpToken) == String(OPTOKEN_WINDOW_MENU)) 00253 //MenuItem ID must be first sub element of menu because in windows 00254 //menus do not have IDs 00255 WindowMenuID = ((pSubMenu->GetMenuId()) + 1); 00256 00257 pCurMenu->AddMenuItem(pSubMenu); 00258 MenuStack.AddHead(pCurMenu); //Push Current Menu onto stack 00259 pCurMenu = pSubMenu; 00260 } 00261 // MENUITEM reserved word 00262 else if (menuitem_sym == keyword) 00263 { 00264 ERRORIF((!GetToken(&MenuScript, OpToken, TokenSize)), 00265 _R(IDE_SYNTAX_ERROR), 00266 NULL); 00267 00268 #if !defined(_DEBUG) 00269 // Don't add menu itemns if parent not wanted 00270 if( NULL == pCurMenu ) 00271 continue; 00272 #endif 00273 00274 pMenuItem = CreateMenuItem( OpToken, 00275 pCurMenu->GetMenuId(), 00276 GetSeparator( &MenuScript, 00277 separator_sym, 00278 keyword, 00279 keywordSize) 00280 ); 00281 00282 if (pMenuItem != NULL) 00283 pCurMenu->AddMenuItem(pMenuItem); 00284 else 00285 break; 00286 00287 } 00288 // END reserved word 00289 else if (end_sym == keyword) 00290 { // Pop Menu from stack 00291 pCurMenu = (MenuItem*) MenuStack.RemoveHead(); 00292 // WEBSTER - markn 22/1/97 00293 // Stops circular menu lists being generated when the last main menu item 00294 // contains a sub menu (thank you mario) 00295 if (pCurMenu != NULL) 00296 pCurMenu->ClearPointers(); 00297 } 00298 } 00299 00300 } 00301 00302 MenuScript.close(); 00303 00304 return pMenu; 00305 }
|
|
Parses a Menu Script Menu Separator Token.
Definition at line 482 of file menupref.cpp. 00486 { 00487 // Get Keyword 00488 TCHAR ch; 00489 INT32 i = 0; 00490 00491 ClearArray(SepKeyword, size); 00492 00493 //Go back one place and reread last character. 00494 pMenuScript->seek((pMenuScript->tell() - 1)); 00495 pMenuScript->read(ch); 00496 00497 //Find First Alpha Numeric Character 00498 while(!String::IsAlpha(ch) && (!pMenuScript->eof()) && (ch != '\n')) 00499 pMenuScript->read(ch); 00500 00501 //Read in the keyword until not Alpha Numeric 00502 while (String::IsAlpha(ch) && (!pMenuScript->eof()) && (i < size)) 00503 { 00504 SepKeyword[i++] = ch; 00505 pMenuScript->read(ch); 00506 } 00507 00508 if (separator_sym == SepKeyword) 00509 return TRUE; 00510 else 00511 { 00512 // TRACEUSER( "JustinF", _T("Menu GetSeparator() - read %s\n"), SepKeyword); 00513 return FALSE; 00514 } 00515 }
|
|
Parses a Menu Script Token.
Definition at line 418 of file menupref.cpp. 00419 { 00420 // Get Keyword 00421 TCHAR ch; 00422 INT32 i = 0; 00423 00424 ClearArray(OpToken, TokenSize); 00425 00426 //Go back one place and reread last character. 00427 pMenuScript->seek((pMenuScript->tell() - 1)); 00428 pMenuScript->read(ch); 00429 00430 while (StringBase::IsSpace(ch) && !pMenuScript->eof()) 00431 pMenuScript->read(ch); 00432 00433 if (ch == TEXT('"')) 00434 pMenuScript->read(ch); 00435 else 00436 { 00437 // TRACEUSER( "JustinF", _T("Menu GetToken() - no opening \"\n")); 00438 pMenuScript->close(); 00439 return FALSE; 00440 } 00441 00442 while ((String::IsAlphaNumeric(ch) || (ch == _T('_'))) && 00443 ch != TEXT('"') && 00444 !pMenuScript->eof() && 00445 i < TokenSize) 00446 { 00447 OpToken[i++] = ch; 00448 pMenuScript->read(ch); 00449 } 00450 00451 if (ch == TEXT('"') && !pMenuScript->eof()) 00452 return TRUE; 00453 else 00454 { 00455 // TRACEUSER( "JustinF", _T("Menu GetToken() - read %s\n"), OpToken); 00456 pMenuScript->close(); 00457 return FALSE; 00458 } 00459 }
|
|
Definition at line 121 of file menupref.cpp. |