From 80fd59ce85c9869b6413c100b8fad4513c24c182 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Mon, 10 Feb 2003 18:45:27 +0000 Subject: [PATCH] Mac GUI stuff svn path=/trunk/boinc/; revision=884 --- client/client_types.h | 2 +- client/mac/mac_join.cpp | 38 +++++++++++++++++++++++++++----------- client/mac/mac_join.h | 2 +- client/mac/mac_main.h | 5 +++++ 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/client/client_types.h b/client/client_types.h index 46d974f8f3..4d4715b7d6 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -1,4 +1,4 @@ - // The contents of this file are subject to the Mozilla Public License +// The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ diff --git a/client/mac/mac_join.cpp b/client/mac/mac_join.cpp index d0d103ec16..6d86318eb3 100644 --- a/client/mac/mac_join.cpp +++ b/client/mac/mac_join.cpp @@ -19,16 +19,29 @@ #include "mac_join.h" -// Create, show and run modally our dialog window +bool success; + +#define kJoinSignature 'join' +#define kProjectURLFieldID 128 +#define kAccountKeyFieldID 129 + +// Create, show and run modally our join window // -OSStatus CreateJoinDialog() +OSStatus CreateJoinDialog( char *master_url, char *account_key ) { IBNibRef nibRef; EventTypeSpec dialogSpec = {kEventClassCommand, kEventCommandProcess }; WindowRef dialogWindow; EventHandlerUPP dialogUPP; OSStatus err = noErr; - + Size realSize; + ControlID projectURLID = { kJoinSignature, kProjectURLFieldID }; + ControlID accountKeyID = { kJoinSignature, kAccountKeyFieldID }; + ControlHandle zeControl; + CFStringRef text; + + success = false; + // Find the dialog nib err = CreateNibReference(CFSTR("JoinDialog"), &nibRef); require_noerr( err, CantFindDialogNib ); @@ -47,10 +60,18 @@ OSStatus CreateJoinDialog() // Show the window ShowWindow( dialogWindow ); - + // Run modally RunAppModalLoopForWindow(dialogWindow); + GetControlByID( dialogWindow, &projectURLID, &zeControl ); + GetControlData( zeControl, 0, kControlEditTextCFStringTag, sizeof(CFStringRef), &text, &realSize); + CFStringGetCString( text, master_url, 256, CFStringGetSystemEncoding() ); + + GetControlByID( dialogWindow, &accountKeyID, &zeControl ); + GetControlData( zeControl, 0, kControlEditTextCFStringTag, sizeof(CFStringRef), &text, &realSize); + CFStringGetCString( text, account_key, 256, CFStringGetSystemEncoding() ); + HideWindow(dialogWindow); DisposeWindow(dialogWindow); DisposeEventHandlerUPP(dialogUPP); @@ -59,7 +80,7 @@ CantFindDialogNib: CantCreateDialogWindow: CantInstallDialogHandler: - return err; + return success; } // Dialog event handler @@ -75,12 +96,8 @@ pascal OSStatus JoinDialogEventHandler (EventHandlerCallRef myHandler, EventRef // Look for our Yes Join and No Join commands switch (command.commandID) { case kHICommandOK: // 'ok ' - //HandleResponse(TRUE); - stopModalLoop = TRUE; - result = noErr; - break; + success = true; case kHICommandCancel: // 'not!' - //HandleResponse(FALSE); stopModalLoop = TRUE; result = noErr; break; @@ -94,4 +111,3 @@ pascal OSStatus JoinDialogEventHandler (EventHandlerCallRef myHandler, EventRef //Return how we handled the event. return result; } - diff --git a/client/mac/mac_join.h b/client/mac/mac_join.h index 01f2c86993..c3d95d4138 100644 --- a/client/mac/mac_join.h +++ b/client/mac/mac_join.h @@ -24,7 +24,7 @@ extern "C" { #endif pascal OSStatus JoinDialogEventHandler (EventHandlerCallRef myHandler, EventRef event, void *userData); -OSStatus CreateJoinDialog(); +OSStatus CreateJoinDialog( char *master_url, char *account_key ); #ifdef __cplusplus } diff --git a/client/mac/mac_main.h b/client/mac/mac_main.h index 3ccb42860f..caa2497564 100644 --- a/client/mac/mac_main.h +++ b/client/mac/mac_main.h @@ -24,9 +24,14 @@ extern "C" { #endif void InitMainWindow(void); +void GUIRedraw(); void DisplayBOINCStatusWindow (int left, int top, int width, int height); pascal OSStatus MainAppEventHandler(EventHandlerCallRef appHandler, EventRef theEvent, void* appData); +pascal OSStatus MainWinEventHandler(EventHandlerCallRef appHandler, EventRef theEvent, void* appData); pascal void BOINCPollLoopProcessor(EventLoopTimerRef inTimer, void* timeData); +pascal void BOINCIdleDetect(EventLoopTimerRef inTimer, void* timeData); +int SaveBOINCPreferences( void ); +int ReadBOINCPreferences( void ); int mac_setup (void); void mac_cleanup (void);