home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-20 | 1.6 KB | 72 lines | [TEXT/CWIE] |
- //Copyright (c) 1997 Aidan Cully
- //All rights reserved
-
- #include "DismissButton.h"
- #include "CLEventDispatcher.h"
- #include "CLKeyboardHandler.h"
- #include "CLBaseWindow.h"
- #include <QuickDrawText.h>
- #include <Fonts.h>
-
- TDismissButton::TDismissButton( TLayoutBranch *super, unsigned char *message ):
- TControl( super ),
- mString( message )
- {
- }
-
- void TDismissButton::AttachedToWindow( TBaseWindow *win, Rect r )
- {
- TControl::AttachedToWindow( win, r );
- TKeyboardHandler::GetKeyboard()->SetListener( this );
- }
-
- void TDismissButton::DrawSelf( TDrawSlate *gr )
- {
- Rect drawRect= mContentRect;
- FontInfo metric;
-
- ::FrameRoundRect( &drawRect, 8, 8 );
- ::TextFont( ::GetSysFont() );
- ::GetFontInfo( &metric );
- ::MoveTo( (drawRect.left+drawRect.right-StringWidth( mString ))/2,
- (drawRect.top+drawRect.bottom+metric.ascent-metric.descent)/2 );
- ::DrawString( mString );
- }
-
- void TDismissButton::TrackMouseDown( TMouseEvent *ev )
- {
- TrackMouseChange( ev, true );
- }
-
- void TDismissButton::TrackMouseChange( TMouseEvent *ev, BOOLEAN in )
- {
- Rect drawRect= mContentRect;
-
- ::InsetRect( &drawRect, 1, 1 );
- ::InvertRoundRect( &drawRect, 6, 6 );
- }
-
- void TDismissButton::TrackMouseUp( TMouseEvent *ev )
- {
- MEventDispatcher::GetDispatcher()->Quit();
- }
-
- Rect TDismissButton::GetLargestSize()
- {
- return( mContentRect );
- }
-
- void TDismissButton::RespondKeyboard( const TKeyEvent *ev )
- {
- if( ev->asciiCode==0x0D ) {
- mWindow->GetDrawFocus();
- Rect drawRect= mContentRect;
- ::InsetRect( &drawRect, 1, 1 );
- ::InvertRoundRect( &drawRect, 6, 6 );
- long ret;
- ::Delay( 3, &ret );
- ::InvertRoundRect( &drawRect, 6, 6 );
- mWindow->ReleaseDrawFocus();
- MEventDispatcher::GetDispatcher()->Quit();
- }
- }