Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Source/CModalDialog.cp
/* |
File: CModalDialog.cp |
Contains: xxx put contents here xxx |
Version: xxx put version here xxx |
Copyright: © 1999 by Apple Computer, Inc., all rights reserved. |
File Ownership: |
DRI: xxx put dri here xxx |
Other Contact: xxx put other contact here xxx |
Technology: xxx put technology here xxx |
Writers: |
(BWS) Brent Schorsch |
Change History (most recent first): |
<SP1> 7/1/99 BWS first checked in |
*/ |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Includes |
#include <ControlDefinitions.h> |
#include <Controls.h> |
#include <Dialogs.h> |
#include <MacWindows.h> |
#include "MemoryHandler.h" |
#include "CModalDialog.h" |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Private Definitions |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Private Types |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Private Variables |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Private Functions |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Public Variables |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog |
CModalDialog::CModalDialog(const short inDialogID) |
{ |
dialog = ::GetNewDialog(inDialogID, nil, (WindowPtr) -1L); |
numBaseItems = ::CountDITL(dialog); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ ~CModalDialog |
CModalDialog::~CModalDialog() |
{ |
::DisposeDialogZ(&dialog); |
} |
#pragma mark - |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::Show |
void |
CModalDialog::Show(void) |
{ |
::ShowWindow(dialog); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::Hide |
void |
CModalDialog::Hide(void) |
{ |
::HideWindow(dialog); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::MakeCurrentPort |
void |
CModalDialog::MakeCurrentPort(void) |
{ |
::SetPort(dialog); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SetDefaultItem |
void |
CModalDialog::SetDefaultItem(const short inWhichItem) |
{ |
::SetDialogDefaultItem(dialog, inWhichItem); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SetCancelItem |
void |
CModalDialog::SetCancelItem(const short inWhichItem) |
{ |
::SetDialogCancelItem(dialog, inWhichItem); |
} |
#pragma mark - |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::GetItemValue |
short |
CModalDialog::GetItemValue(const short inWhichCheckBox) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichCheckBox, &theControl); |
return (::GetControlValue(theControl)); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::GetEditText |
void |
CModalDialog::GetEditText(const short inWhichItem, Str255 outText) |
{ |
ControlHandle theControl; |
Size realSize; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
::GetControlData(theControl, kControlEditTextPart, kControlEditTextTextTag, 255, (Ptr) &outText[1], &realSize); |
outText[0] = realSize; |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::GetStaticText |
void |
CModalDialog::GetStaticText(const short inWhichItem, Str255 outText) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
::GetDialogItemText((Handle) theControl, outText); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::GetItemMenuHandle |
MenuHandle |
CModalDialog::GetItemMenuHandle(const short inWhichItem) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
return ((MenuHandle) theControl); |
} |
#pragma mark - |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SetItemValue |
void |
CModalDialog::GetItemValue(const short inWhichCheckBox, const short inValue) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichCheckBox, &theControl); |
::SetControlValue(theControl, inValue); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SetEditText |
void |
CModalDialog::SetEditText(const short inWhichItem, Str255 inText) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
::SetControlData(theControl, kControlEditTextPart, kControlEditTextTextTag, inText[0], (Ptr) &inText[1]); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SetStaticText |
void |
CModalDialog::SetStaticText(const short inWhichItem, Str255 inText) |
{ |
ControlHandle theControl; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
::SetDialogItemText((Handle) theControl, inText); |
} |
//¥ ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CModalDialog::SelectEditText |
void |
CModalDialog::SelectEditText(const short inWhichItem, const short inStart, const short inEnd) |
{ |
ControlHandle theControl; |
ControlEditTextSelectionRec selection; |
selection.selStart = inStart; |
selection.selEnd = inEnd; |
::GetDialogItemAsControl(dialog, inWhichItem, &theControl); |
::SetControlData( |
theControl, |
kControlEditTextPart, |
kControlEditTextSelectionTag, |
sizeof (ControlEditTextSelectionRec), |
(Ptr) &selection); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14