Esempio n. 1
0
/*!
 * Makes sure that the text field is given focus.
 */
Boolean
hFilesNew(EventPtr event)
{
	Boolean handled = false;
	FormPtr form;
	UInt16 fieldID;
	WChar chr;

	switch (event->eType) {
	case frmOpenEvent:
		setGameInProgress(0);
		form = FrmGetActiveForm();
		SetSilkResizable(form, true);
		collapseMove(form, CM_DEFAULT, NULL, NULL);
		FrmDrawForm(cityNewSetup(form));
		handled = true;
		break;
	case frmCloseEvent:
		break;
	case keyDownEvent:
		form = FrmGetActiveForm();
		fieldID = FrmGetObjectId(form, FrmGetFocus(form));
		if (fieldID < fieldID_width || fieldID > fieldID_width)
			break;

		chr = event->data.keyDown.chr;
		if (((chr >= chrDigitZero) && (chr <= chrDigitNine)) ||
			(chr == chrBackspace)) {
			EvtEnqueueKey(chrTilde, 0, 0);
			break;
		}
		if (chr == chrTilde)
			cnFieldContentChanged(fieldID);
		break;

	case ctlRepeatEvent:
		cnRepeatPressed(event);
		break;
	case ctlSelectEvent:
		switch (event->data.ctlSelect.controlID) {
		case buttonID_FilesNewCreate:
			cnCreateButtonPressed();
			handled = true;
			break;
		case buttonID_FilesNewCancel:
			cnCancelButtonPressed();
			handled = true;
			break;
		}
		break;
#if defined(HRSUPPORT)
	case winDisplayChangedEvent:
#if defined(SONY_CLIE)
	case vchrSilkResize:
#endif
		form = FrmGetActiveForm();
		if (collapseMove(form, CM_DEFAULT, NULL, NULL)) {
			FrmEraseForm(form);
			FrmDrawForm(form);
		}
		handled = true;
		break;
#endif
	default:
		break;
	}

	return (handled);
}
Esempio n. 2
0
/* Perform action assigned to given control object */
void DoControlAction
    (
    const Int16 control /* control value of the object */
    )
{
    UInt16  newRecord;
    Int16   controlID;

    /* Clear location of find pattern */
    ClearFindPatternData();

    if ( 0 < control ) {
        Int16   anchorIndex;
        UInt16  reference;
        Int16   paragraphOffset;
        Int16   byteOffsetInPara;
        UInt16  image;
        AnchorMode type;

        anchorIndex         = control - 1;
        reference           = GetVisibleReference( anchorIndex );
        paragraphOffset     = GetVisibleParagraphOffset( anchorIndex );
        byteOffsetInPara    = GetVisibleByteOffset( anchorIndex );
        image               = GetVisibleImage( anchorIndex );
        image               = GetVisibleImage( anchorIndex );
        type                = GetVisibleMode( anchorIndex );

        SndPlaySystemSound( sndClick );

        if ( image != 0 ) {
            RectangleType   bounds;
            ListType*       list;
            Int16           x;
            Int16           y;
            UInt16          prevCoordSys;
            Int16           selection;

            bounds  = GetVisibleImagePosition( anchorIndex );
            list    = GetObjectPtr( frmMainImageDialog );

            x = ( bounds.extent.x - 60 ) / 2;
            if ( x < 0 )
                x = 0;
            y = ( bounds.extent.y - 22 ) / 2;
            if ( y < 0 )
                y = 0;
            x += bounds.topLeft.x;
            y += bounds.topLeft.y;
            LstSetPosition( list, x, y );

            prevCoordSys    = PalmSetCoordinateSystem( STANDARD );
            selection       = LstPopupList( list );
            PalmSetCoordinateSystem( prevCoordSys );
            if ( selection == noListSelection ) {
                return;
            }
            else if ( selection == 1 ) {
                reference = image;
            }
        }
        if ( type == ANCHORMODE_LINK ) {
            Int16 byteOffset;
            
            if ( byteOffsetInPara == 0 ) {
                byteOffset = NO_OFFSET;
            }
            else {
                byteOffset      = ParagraphNumToByteOffset( paragraphOffset ) +
                                      byteOffsetInPara;
                paragraphOffset = NO_OFFSET;
            }
            JumpToRecord( reference, paragraphOffset, byteOffset );
        }
#ifdef SUPPORT_ANNOTATION
        else if ( type == ANCHORMODE_ANNOTATION ) {
            DoAnnotate( GetVisibleAnnotationIdentifier( anchorIndex ),
                0, 0, 0, 0, 0, NULL );
        }
#endif

        return;
    }

    if ( control != 0 )
        SndPlaySystemSound( sndClick );

    controlID = -( control + 1 );
    switch ( controlID ) {
        case HOMECONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            ViewRecord( HOME_PAGE_ID, ADD_TO_HISTORY, 0, 0,
                WRITEMODE_DRAW_CHAR );
            SetVisitedLink( HOME_PAGE_ID );
            break;

        case LEFTCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            newRecord = GetHistoryPrev();
            if ( newRecord != NO_RECORD ) {
                ViewRecord( newRecord, FROM_HISTORY, NO_OFFSET, NO_OFFSET,
                    WRITEMODE_DRAW_CHAR );
                SetVisitedLink( newRecord );
            }
            else {
                FrmGotoForm( GetValidForm( frmLibrary ) );
            }
            break;

        case RIGHTCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            newRecord = GetHistoryNext();
            if ( newRecord != NO_RECORD ) {
                ViewRecord( newRecord, FROM_HISTORY, NO_OFFSET, NO_OFFSET,
                    WRITEMODE_DRAW_CHAR );
                SetVisitedLink( newRecord );
            }
            break;

        case LIBRARYCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            CloseDocument();
            FrmGotoForm( GetValidForm( frmLibrary ) );
            break;

        case FINDCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            FrmPopupForm( frmSearch );
            break;

        case AGAINCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            SearchAgain();
            break;

        case MENUCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_OFF );
            EvtEnqueueKey( menuChr, 0, commandKeyMask );
            break;

        case OFFSETCONTROL:
        {
            UInt16 prevCoordSys;
            Int16  selection;

            DoAutoscrollToggle( AUTOSCROLL_OFF );
            prevCoordSys = PalmSetCoordinateSystem( STANDARD );
            selection = LstPopupList( GetObjectPtr( frmMainPercentList ) );
            PalmSetCoordinateSystem( prevCoordSys );
            if ( selection != noListSelection )
                GotoLocation( selection );

            break;
        }

        case BOOKMARKCONTROL:
        {
            UInt16      prevCoordSys;
            ListType*   list;
            Int16       selection;
            UInt16      numOfBookmarks;

            DoAutoscrollToggle( AUTOSCROLL_OFF );

            prevCoordSys = PalmSetCoordinateSystem( STANDARD );

            list            = GetObjectPtr( frmMainBookmarkList );
            numOfBookmarks  = CreatePopupBookmarkList( list );
            if ( numOfBookmarks == 0 ) {
                PalmSetCoordinateSystem( prevCoordSys );
                break;
            }
            
            selection = LstPopupList( GetObjectPtr( frmMainBookmarkList ) );
            
            if ( 0 <= selection ) {
                BookmarkListEntry e;

                MemMove( &e, GetBookmarkListEntry( selection ), sizeof( BookmarkListEntry ) );

                ReleaseBookmarkList();
                PalmSetCoordinateSystem( prevCoordSys );

                switch ( e.kind ) {
                    case BOOKMARK_ADD_BOOKMARK: 
                        DoAddBookmark();
                        break;
                    case BOOKMARK_EDIT_BOOKMARK:
                        FrmPopupForm( frmBookmarks );
                        break;
#ifdef SUPPORT_ANNOTATION
                    case BOOKMARK_ADD_ANNOTATION:
                        isSelectWordTapMode = true;
                        selectedWordAction  = SELECT_WORD_ANNOTATE;
                        ShowSelectWordTapIcon();
                        break;
#endif
                    case BOOKMARK_BOOKMARK:
                    case BOOKMARK_ANNOTATION:
                        SendBookmarkGoToEvent( &e, false );
                        break;

                    case BOOKMARK_EXT_BOOKMARK:
                        GoToExtBookmark( e.recordNum );
                        break;
                        
                    case BOOKMARK_INVALID:
                        break;
                }
            }
            else {
                ReleaseBookmarkList();
                PalmSetCoordinateSystem( prevCoordSys );
            }

            break;
        }

        case AUTOSCROLLSTARTCONTROL:
        case AUTOSCROLLSTOPCONTROL:
            DoAutoscrollToggle( AUTOSCROLL_TOGGLE );
            break;

        case AUTOSCROLLINCRCONTROL:
            DoAutoscrollIncr();
            break;

        case AUTOSCROLLDECRCONTROL:
            DoAutoscrollDecr();
            break;

        case COPYTOMEMOCONTROL:
            DoHardcopy();
            break;

#ifdef SUPPORT_WORD_LOOKUP
        case SELECTEDWORDCONTROL: {
            EventType newEvent;

            MemSet( &newEvent, sizeof( newEvent ), 0 );
            newEvent.eType                   = pluckerSelectedWordEvent;
            newEvent.data.generic.datum[ 0 ] = selectedWordAction;
            EvtAddEventToQueue( &newEvent );

            break;
        }
#endif

        default:
            break;
    }
}