// =========================================================================== // CSimlabConstPanel.cp // ©1995 J. Rodden, DD/MF & Associates. All rights reserved // =========================================================================== #include "RuntimeMessages.h" #include "RuntimeResources.h" #include "CSimlabConstPanel.h" #include <3DAttachments.h> #include <3DDrawingUtils.h> #include <3DTextFields.h> #include #include #include #include // --------------------------------------------------------------------------- const ResIDT kThumbWheelCDEF = 129; const Int32 kUniversalLineAdj = 2; const Int32 kUniversalInset = 4; const Int32 kUniversalHeightAdj = 2*kUniversalInset + kUniversalLineAdj; const Int32 kCaptionWidth = 90; const Int32 kTextFieldWidth = 30; const Int32 kThumbWheelHeight = 18; const Int32 kThumbWheelWidth = 11; const Int32 kCaptionOffset = kUniversalInset; const Int32 kValueFieldOffset = kUniversalInset + kCaptionOffset + kCaptionWidth; const Int32 kSliderROffset = kUniversalInset + kValueFieldOffset + kTextFieldWidth; const Int32 kMinWheelOffset = kUniversalInset + kThumbWheelWidth; const Int32 kMinFieldOffset = kUniversalInset + kMinWheelOffset + kTextFieldWidth; const Int32 kSliderLOffset = kUniversalInset + kMinFieldOffset; // --------------------------------------------------------------------------- // € CSimlabConstPanel(SPaneInfo&, SViewInfo&) // --------------------------------------------------------------------------- // Construct View from input parameters CSimlabConstPanel::CSimlabConstPanel( const SPaneInfo& inPaneInfo, const SViewInfo& inViewInfo, LCommander* inSuper, LListener* inListener, Str255 inString, SimlabListTag inTag) : LView(inPaneInfo,inViewInfo) { SPaneInfo thePaneInfo = inPaneInfo; // Universal pane settings thePaneInfo.paneID = 0; thePaneInfo.userCon = 0; thePaneInfo.superView = this; thePaneInfo.top = kUniversalInset; thePaneInfo.height = inPaneInfo.height - kUniversalHeightAdj; thePaneInfo.bindings.left = true; thePaneInfo.bindings.top = false; thePaneInfo.bindings.right = false; thePaneInfo.bindings.bottom = false; // Setup caption thePaneInfo.left = kCaptionOffset; thePaneInfo.width = kCaptionWidth; new LCaption( thePaneInfo, inString, (inTag != tagSetupVar) ? Txtr_Geneva9 : Txtr_Geneva9Italic); // Setup value field thePaneInfo.top = 1; thePaneInfo.height = inPaneInfo.height - kUniversalInset; thePaneInfo.left = kValueFieldOffset; thePaneInfo.width = kTextFieldWidth; LCaption* theValueField = C3DCaption::CreateFromData( thePaneInfo, "\p0", Txtr_Geneva9Right); //LEditField* theValueField = C3DEditField::CreateFromData( thePaneInfo, "\p0", // Txtr_Geneva9Right, 20, false, // (KeyFilterFunc) UKeyFilters::IntegerField, inSuper); // Setup slider control thePaneInfo.top = kUniversalInset; thePaneInfo.height = inPaneInfo.height - kUniversalHeightAdj; thePaneInfo.left = kSliderROffset; thePaneInfo.width = inPaneInfo.width - kSliderROffset - kSliderLOffset; thePaneInfo.bindings.right = true; mSliderCtrl = new CSliderCtrl( thePaneInfo, msg_ChangeConstant, 0, 0, 100); mSliderCtrl->AttachValuePane(theValueField); mSliderCtrl->StopIdling(); mSliderCtrl->AddListener(this); // Setup min field thePaneInfo.top = 1; thePaneInfo.height = inPaneInfo.height - kUniversalInset; thePaneInfo.left = inPaneInfo.width - kMinFieldOffset; thePaneInfo.width = kTextFieldWidth; thePaneInfo.bindings.left = false; //LEditField* theValueField = C3DEditField::CreateFromData( thePaneInfo, "\p0", Txtr_Geneva9Right, 20, false, (KeyFilterFunc) UKeyFilters::IntegerField, inSuper); // Setup thumbwheel control thePaneInfo.top = (inPaneInfo.height - kUniversalLineAdj)/2 - kThumbWheelHeight/2; thePaneInfo.height = kThumbWheelHeight; thePaneInfo.left = inPaneInfo.width - kMinWheelOffset; thePaneInfo.width = kThumbWheelWidth; new LStdControl(thePaneInfo, msg_ChangeConstant, 0, min_Int16, max_Int16, kThumbWheelCDEF << 4, Txtr_Geneva9, 0, 0); // Attach listener AddListener(inListener); } // --------------------------------------------------------------------------- // € ~CSimlabConstPanel // --------------------------------------------------------------------------- // Destructor // CSimlabConstPanel::~CSimlabConstPanel() { } // --------------------------------------------------------------------------- // € ListenToMessage // --------------------------------------------------------------------------- void CSimlabConstPanel::ListenToMessage(MessageT inMessage, void *ioParam) { switch ( inMessage ) { case msg_ChangeConstant: break; } } // --------------------------------------------------------------------------- // € DrawSelf // --------------------------------------------------------------------------- void CSimlabConstPanel::DrawSelf() { PenState thePenState; U3DDrawingUtils::Get3DPenState(&thePenState); Rect theRect; CalcLocalFrameRect(theRect); theRect.left += thePenState.pnSize.h; theRect.right -= thePenState.pnSize.h; RGBColor theBkgdColor; U3DDrawingUtils::Get3DBackColor(&theBkgdColor); ::RGBBackColor(&theBkgdColor); ::EraseRect(&theRect); U3DDrawingUtils::Draw3DInsetHLine( theRect.bottom - 2*thePenState.pnSize.v, theRect.left - thePenState.pnSize.h, theRect.right + thePenState.pnSize.h); LView::DrawSelf(); }