Exemple #1
0
tri_val_t finish_do_drink(obj_t *otmp, Boolean nothing, Boolean unkn)
{
  Boolean go_on = false;
  if (!otmp) return NO_OP; // bug if that happens
  if (nothing) {
    unkn = true;
    message("You have a peculiar feeling for a moment, then it passes.");
  }
  if ((otmp->bitflags & O_IS_DESCKNOWN) &&
      !BITTEST(oc_name_known, otmp->otype)) {
    if (!unkn) {
      BITSET(oc_name_known, otmp->otype);//objects[otmp->otyp].oc_name_known=1;
      more_experienced(0,10);
    } else if (!oc_has_uname(otmp->otype)) {
      // here's what I'll do instead of do_call/docall(otmp) :
      show_all_messages();
      clone_for_call(otmp); // so we don't have to worry about useup!
      FrmPopupForm(EngraveForm);
      go_on = true;
    }
  }
  useup(otmp);
  if (go_on) return GO_ON;
  else       return DONE;
}
/*
** Go to the record specified gadgetID and open the specified
** "field" (the note dialog, the details dialog, ...)
*/
static void GotoRecordField(UInt16 gadgetID, UInt16 field) {
  FormType* frm = FrmGetActiveForm();
  DynamicButtonType* btn = (DynamicButtonType*) FrmGetGadgetData(frm, FrmGetObjectIndex(frm, gadgetID));

  p.dbI = btn->value;
  LoadRecordData();

  switch (field) {
  case ffNote:
    DoNoteDialog(0, 0);
    break;

  case ffDetails:
    d.detailsWithSketch = false;
    FrmPopupForm(RecordDetailsForm);
    break;

  case ffAlarm:
    recordUnsetCountdown();
    FrmGotoForm(TimeForm);
    break;

  default:
    /* ignore */
  }
}
Exemple #3
0
// in tele, if you have "Teleport_control" you can choose where to go.
// similarly, level_tele will let you choose what level to teleport to.
Boolean tele()
{
  //  Short nux,nuy;
  if (Teleport_control) {
    extern Boolean took_time;
    extern Short map_mode_teleport;
    //    coord cc;
    took_time = false;
    curr_state.cmd = '\024';
    curr_state.item = NULL;
    /*
      // the old technique, which sort of worked, locally:
    curr_state.mode = MODE_GETCELL;
    message("To what position do you want to be teleported?");
    return false;
    */
    /* 1: force valid */
    //    cc = getpos(1, "the desired position");
    /* possible extensions: introduce a small error if
       magic power is low; allow transfer to solid rock */
    // the new whole-dungeon-level technique:
    if (!map_mode_teleport)
      map_mode_teleport = TELE_RNDTIMER;
    FrmPopupForm(MapForm); // this will call do_xy_command for you
    return false;
  } else {
    tele_finish(0, 0, false);
    return true;
  }
}
Exemple #4
0
UInt16 DisplayDialog( UInt16 formID, FormEventHandlerPtr handler ) 
{ 
	FormPtr active = FrmGetActiveForm();
    
	UInt16 activeID = ( active != NULL ) ? FrmGetFormId( active ) : 0;
	FormPtr dialog = FrmInitForm( formID );
	UInt16 buttonPressed = 0;
    
	FrmSetActiveForm( dialog ); 
	if( handler ){ 
		FrmSetEventHandler( dialog, handler ); 
	} 
	FrmPopupForm( formID ); 
	buttonPressed = FrmDoDialog( dialog ); 
	FrmReturnToForm( activeID );
    
	return buttonPressed;
} 
Exemple #5
0
// also used for scrolls.
Boolean strange_feeling(obj_t *obj, Char *txt)
{
  Boolean engrave = false;
  if (flags.beginner)
    message("You have a strange feeling for a moment, then it passes.");
  else
    message(txt);
  if (!BITTEST(oc_name_known, obj->otype) &&
      !oc_has_uname(obj->otype)) {
    // here's what I'll do instead of do_call/docall(obj) :
    show_all_messages();
    clone_for_call(obj); // so we don't have to worry about useup!
    FrmPopupForm(EngraveForm);
    engrave = true;
  }
  useup(obj);
  return engrave;
}
Exemple #6
0
static Err RecentLookupsResponseProcessor(AppContext* appContext, void* context, const char* responseBegin, const char* responseEnd)
{
    ResponseParsingResult result;
    Err error=ProcessResponse(appContext, responseBegin, responseEnd, 
        responseWordsList|responseMessage|responseErrorMessage, result);
    if (!error) 
    {
        if (responseWordsList==result)
            FrmPopupForm(formWordsList);
        else if (responseMessage==result || responseErrorMessage==result)
        {
            appContext->mainFormContent=mainFormShowsMessage;
            appContext->firstDispLine=0;
        }
        else
            Assert(false);
    }        
    return error;
}
Exemple #7
0
static Err WordLookupResponseProcessor(AppContext* appContext, void* context, const char* responseBegin, const char* responseEnd)
{
    ResponseParsingResult result;
    Err error=ProcessResponse(appContext, responseBegin, responseEnd, 
        responseDefinition|responseMessage|responseErrorMessage|responseWordsList|responseRegistrationFailed, result);
    if (error)
    {
#ifdef DEBUG
        LogStrN(appContext, responseBegin, (long) (responseEnd-responseBegin) );
#endif
        return error;
    }

    switch (result)
    {
        case responseDefinition:
            appContext->mainFormContent=mainFormShowsDefinition;
            appContext->firstDispLine=0;
            break;
            
        case responseMessage:
        case responseErrorMessage:
            appContext->mainFormContent=mainFormShowsMessage;
            appContext->firstDispLine=0;
            break;
            
        case responseWordsList:
            FrmPopupForm(formWordsList);
            break;

        case responseRegistrationFailed:
            SendEvtWithType(evtRegistrationFailed);
            break;
            
        default:
            Assert(false);
    }
    return error;
}
Exemple #8
0
/*!
 * Ensures that the list is populated with all the cities in the save game
 * slots.
 */
Boolean
hFiles(EventPtr event)
{
	Boolean handled = false;
	char	*currentcity;
	FormPtr form;
#if defined(HRSUPPORT)
	Int16 hOff = 0, vOff = 0;
#endif

	switch (event->eType) {
	case frmOpenEvent:
		form = FrmGetActiveForm();
		SetSilkResizable(form, true);
		collapseMove(form, CM_DEFAULT, &hOff, &vOff);
		resizeSavegameForm(form, hOff, vOff);
		filesSetup(form);
		FrmDrawForm(form);
		handled = true;
		break;
	case frmCloseEvent:
		CleanSaveGameList();
		SetSilkResizable(NULL, false);
		break;
	case ctlSelectEvent:
		switch (event->data.ctlSelect.controlID) {
		case buttonID_FilesNew:
			/* create new game and add it to the list */
			FrmPopupForm(formID_filesNew);
			handled = true;
			break;
		case buttonID_FilesLoad:
			/* create new game */
			if (LoadFromList() != -1)
				FrmGotoForm(formID_pocketCity);
			handled = true;
			break;
		case buttonID_FilesDelete:
			currentcity = GetCurrentCityOnList();
			if ((currentcity != NULL) &&
			  (FrmCustomAlert(alertID_deleteCityConfirm,
				currentcity, NULL, NULL) == 0)) {
				DeleteFromList();
				CleanSaveGameList();
				UpdateSaveGameList();
			}
			handled = true;
			break;
		}
		break;
#if defined(HRSUPPORT)
	case winDisplayChangedEvent:
#if defined(SONY_CLIE)
	case vchrSilkResize:
#endif
		form = FrmGetActiveForm();
		if (collapseMove(form, CM_DEFAULT, &hOff, &vOff)) {
			resizeSavegameForm(form, hOff, vOff);
			FrmDrawForm(form);
		}
		handled = true;
		break;
#endif
	default:
		break;
	}

	return (handled);
}
/* Perform action for specified select type */
void DoSelectTypeAction
    (
    SelectType selection    /* selection type */
    )
{
    if ( IsMainFormWinActive() || IsFullscreenformActive()
         || FrmGetActiveFormID() == frmLibrary ) {
        if ( IsMainFormWinActive() &&
             selection != SELECT_TOGGLE_AUTOSCROLL &&
             selection != SELECT_INCREASE_AUTOSCROLL &&
             selection != SELECT_DECREASE_AUTOSCROLL &&
             selection != SELECT_FULL_PAGE_UP &&
             selection != SELECT_FULL_PAGE_DOWN &&
             selection != SELECT_HALF_PAGE_UP &&
             selection != SELECT_HALF_PAGE_DOWN &&
             selection != SELECT_ONE_LINE_UP &&
             selection != SELECT_ONE_LINE_DOWN ) {
            DoAutoscrollToggle( AUTOSCROLL_OFF );
        }
        switch ( selection ) {
            case SELECT_NONE:
                break;

#ifdef SUPPORT_WORD_LOOKUP
#ifdef SUPPORT_PPI
            case SELECT_WORD_LOOKUP_PPI:
                isSelectWordTapMode = ! isSelectWordTapMode;
                selectedWordAction  = SELECT_WORD_PPI;
                ShowSelectWordTapIcon();
                break;
#endif
#ifdef SUPPORT_ANNOTATION
            case SELECT_WORD_LOOKUP_ANNOTATE:
                isSelectWordTapMode = ! isSelectWordTapMode;
                selectedWordAction  = SELECT_WORD_ANNOTATE;
                ShowSelectWordTapIcon();
                break;
#endif
            case SELECT_WORD_LOOKUP_SEARCH_FORM:
                isSelectWordTapMode = ! isSelectWordTapMode;
                selectedWordAction  = SELECT_WORD_SEARCH_FORM;
                ShowSelectWordTapIcon();
                break;
            case SELECT_WORD_LOOKUP_TO_CLIPBOARD:
                isSelectWordTapMode = ! isSelectWordTapMode;
                selectedWordAction  = SELECT_WORD_TO_CLIPBOARD;
                ShowSelectWordTapIcon();
                break;
#endif

            case SELECT_SAVE_POSITION:
                AddToHistory( GetCurrentRecordId() );
                break;

            case SELECT_BRIGHTNESS_ADJUST:
                EmitKey( vchrBrightness, commandKeyMask );
                break;

            case SELECT_TOGGLE_BACKLIGHT:
                EmitKey( vchrBacklight, commandKeyMask );
                break;
                
            case SELECT_CONTRAST_ADJUST:
                EmitKey( vchrContrast, commandKeyMask );
                break;

            case SELECT_ONE_LINE_UP:
                DoPageMove( GetDefaultMainStyleHeight() );
                break;

            case SELECT_ONE_LINE_DOWN:
                DoPageMove( -GetDefaultMainStyleHeight() );
                break;

            case SELECT_FULL_PAGE_UP:
                if ( Prefs()->autoscrollEnabled &&
                     Prefs()->autoscrollDir == AUTOSCROLL_UP )
                    DoAutoscrollIncr();
                else if ( Prefs()->autoscrollEnabled )
                    DoAutoscrollDecr();
                else if ( Prefs()->pageControlsLink && OnFirstScreen() &&
                          NO_RECORD == GetSequentialRecordId( DIRECTION_UP ) )
                    GoToFirstAnchor();
                else
                    DoPageMove( RotGetScrollValue() );
                break;

            case SELECT_HALF_PAGE_UP:
                if ( Prefs()->autoscrollEnabled &&
                     Prefs()->autoscrollDir == AUTOSCROLL_UP )
                    DoAutoscrollIncr();
                else if ( Prefs()->autoscrollEnabled )
                    DoAutoscrollDecr();
                else if ( Prefs()->pageControlsLink && OnFirstScreen() &&
                          NO_RECORD == GetSequentialRecordId( DIRECTION_UP ) )
                    GoToFirstAnchor();
                else
                    DoPageMove( RotGetScrollValue() / 2 );
                break;

            case SELECT_FULL_PAGE_DOWN:
                if ( Prefs()->autoscrollEnabled &&
                     Prefs()->autoscrollDir == AUTOSCROLL_UP )
                    DoAutoscrollDecr();
                else if ( Prefs()->autoscrollEnabled )
                    DoAutoscrollIncr();
                else if ( Prefs()->pageControlsLink && OnLastScreen() )
                    GoToLastAnchor();
                else
                    DoPageMove( -RotGetScrollValue() );
                break;

            case SELECT_HALF_PAGE_DOWN:
                if ( Prefs()->autoscrollEnabled &&
                     Prefs()->autoscrollDir == AUTOSCROLL_UP )
                    DoAutoscrollDecr();
                else if ( Prefs()->autoscrollEnabled )
                    DoAutoscrollIncr();
                else if ( Prefs()->pageControlsLink && OnLastScreen() )
                    GoToLastAnchor();
                else
                    DoPageMove( -RotGetScrollValue() / 2 );
                break;

            case SELECT_GO_BACK:
                if ( IsFullscreenformActive() )
                    FsDoControlAction( -( LEFTCONTROL + 1 ) );
                else
                    DoControlAction( -( LEFTCONTROL + 1 ) );
                break;

            case SELECT_GO_FORWARD:
                if ( IsFullscreenformActive() )
                    FsDoControlAction( -( RIGHTCONTROL + 1 ) );
                else
                    DoControlAction( -( RIGHTCONTROL + 1 ) );
                break;

            case SELECT_GO_HOME:
                if ( IsFullscreenformActive() )
                    FsDoControlAction( -( HOMECONTROL + 1 ) );
                else
                    DoControlAction( -( HOMECONTROL + 1 ) );
                break;

            case SELECT_GO_TO_TOP:
                if ( IsFullscreenformActive() )
                    FsAdjustVerticalOffset( FULLSCREEN_TOP );
                else
                    GotoLocation( TOP );
                break;

            case SELECT_GO_TO_BOTTOM:
                if ( IsFullscreenformActive() )
                    FsAdjustVerticalOffset( FULLSCREEN_BOTTOM );
                else
                    GotoLocation( BOTTOM );
                break;

            case SELECT_FIND:
                FrmPopupForm( frmSearch );
                break;

            case SELECT_FIND_AGAIN:
                SearchAgain();
                break;

            case SELECT_ADD_BOOKMARK:
                DoAddBookmark();
                break;

            case SELECT_VIEW_BOOKMARKS:
                FrmPopupForm( frmBookmarks );
                break;

            case SELECT_OPEN_LIBRARY:
                CloseDocument();
                FrmGotoForm( GetValidForm( frmLibrary ) );
                break;

            case SELECT_DETAILS:
                FrmPopupForm( frmDetails );
                break;

            case SELECT_PREFS:
                FrmGotoForm( frmPrefs );
                break;

            case SELECT_BUTTON_ACTION:
                PrefsButtonShowFirst();
                FrmGotoForm( frmPrefs );
                break;

            case SELECT_TAP_ACTION:
                PrefsControlShowFirst();
                FrmGotoForm( frmPrefs );
                break;

            case SELECT_GESTURE_ACTION:
                PrefsGestureShowFirst();
                FrmGotoForm( frmPrefs );
                break;

            case SELECT_TOGGLE_AUTOSCROLL:
                DoAutoscrollToggle( AUTOSCROLL_TOGGLE );
                break;

            case SELECT_INCREASE_AUTOSCROLL:
                DoAutoscrollIncr();
                break;
                
            case SELECT_DECREASE_AUTOSCROLL:
                DoAutoscrollDecr();
                break;

            case SELECT_NEXT_ANCHOR:
                HandleNextControl();
                break;

            case SELECT_PREV_ANCHOR:
                HandlePrevControl();
                break;

            case SELECT_GO_TO_LINK:
                if ( IsFullscreenformActive() ) {
                    if ( 0 < actualAnchor )
                        FsDoControlAction( actualAnchor );
                } else {
                    DoControlAction( actualAnchor );
                }
                break;

            case SELECT_COPY_TO_MEMO:
                DoHardcopy();
                break;

            case SELECT_DELETE_DOCUMENT:
                DoDeleteDocument();
                break;

            case SELECT_FONT:
                PrefsFontShowFirst();
                FrmGotoForm( frmPrefs );
                break;

            case SELECT_COMMAND_STROKE:
                EmitKey( vchrCommand, commandKeyMask );
                break;

            case SELECT_MENU:
                EmitKey( vchrMenu, commandKeyMask );
                break;

#ifdef HAVE_ROTATE
            case SELECT_ROTATE_LEFT: {
                RotateType angle;
                angle = Prefs()->rotate;
                switch ( angle ) {
                    case ROTATE_ZERO:
                        angle = ROTATE_PLUS90;
                        break;
                    case ROTATE_PLUS90:
                        angle = ROTATE_MINUS90;
                        break;
                    case ROTATE_MINUS90:
                        angle = ROTATE_ZERO;
                }
                if ( Prefs()->individualDocumentLayout )
                    GetHistoryPtr()->rotate = angle;
                else
                    Prefs()->rotate = angle;
                FrmUpdateForm( Prefs()->lastForm, frmRedrawUpdateCode );
                break;
            }

            case SELECT_ROTATE_RIGHT: {
                RotateType angle;
                angle = Prefs()->rotate;
                switch ( angle ) {
                    case ROTATE_PLUS90:
                        angle = ROTATE_ZERO;
                        break;
                    case ROTATE_MINUS90:
                        angle = ROTATE_PLUS90;
                        break;
                    case ROTATE_ZERO:
                        angle = ROTATE_MINUS90;
                        break;
                }
                if ( Prefs()->individualDocumentLayout )
                    GetHistoryPtr()->rotate = angle;
                else
                    Prefs()->rotate = angle;
                FrmUpdateForm( Prefs()->lastForm, frmRedrawUpdateCode );
                break;
            }
#endif

            case SELECT_TOGGLE_TOOLBAR:
                if ( ! IsFormMain( Prefs()->lastForm ) )
                    break;
                if ( Prefs()->toolbar != TOOLBAR_NONE ) {
                    Prefs()->savedToolbar = Prefs()->toolbar;
                    Prefs()->toolbar      = TOOLBAR_NONE;
                }
                else {
                    if ( Prefs()->savedToolbar == TOOLBAR_NONE )
                        Prefs()->toolbar = TOOLBAR_TOP;
                    else
                        Prefs()->toolbar = Prefs()->savedToolbar;
                }
#ifdef HAVE_SILKSCREEN
                if ( GetDIAState() == DIA_STATE_NO_STATUS_BAR &&
                   Prefs()->toolbar != TOOLBAR_NONE )
                    SetDIAState( Prefs()->savedSilkscreen );
#endif
                FrmUpdateForm( Prefs()->lastForm, frmRedrawUpdateCode );
                break;

            case SELECT_TOGGLE_FULLSCREEN: {
                UInt16       newToolbarState;
                UInt16       newScrollbarState;
                DIAStateType newDIAState;
                if ( Prefs()->toolbar == TOOLBAR_NONE &&
                    Prefs()->scrollbar == SCROLLBAR_NONE
                   ) {
                    /* From fullscreen to non-fullscreen */
                    if ( Prefs()->savedToolbar == TOOLBAR_NONE &&
                         Prefs()->savedScrollbar == SCROLLBAR_NONE ) {
                        Prefs()->savedToolbar   = TOOLBAR_TOP;
                        Prefs()->savedScrollbar = SCROLLBAR_RIGHT;
                    }
                    if ( Prefs()->savedSilkscreen == DIA_STATE_NO_STATUS_BAR ) {
                        Prefs()->savedSilkscreen = DIA_STATE_MIN;
                    }
                    newToolbarState   = Prefs()->savedToolbar;
                    newScrollbarState = Prefs()->savedScrollbar;
                    newDIAState       = Prefs()->savedSilkscreen;
                }
                else {
                    /* From non-fullscreen to fullscreen */
                    newToolbarState   = TOOLBAR_NONE;
                    newScrollbarState = SCROLLBAR_NONE;
                    newDIAState       = DIA_STATE_NO_STATUS_BAR;
                }
                Prefs()->savedToolbar    = Prefs()->toolbar;
                Prefs()->savedScrollbar  = Prefs()->scrollbar;
                Prefs()->savedSilkscreen = GetDIAState();
                Prefs()->toolbar         = newToolbarState;
                Prefs()->scrollbar       = newScrollbarState;
                SetDIAState( newDIAState );
                FrmUpdateForm( Prefs()->lastForm, frmRedrawUpdateCode );
                break;
            }

            default:
                break;
        }
    }
}
Exemple #10
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;
    }
}
Exemple #11
0
static Boolean MainFormHandleEvent (EventPtr e)
{
    Boolean handled = false;
    FormPtr frm;
    static UInt32 start_sec=0;
    static UInt32 start_tik;
    static UInt32 end_sec;
    static UInt32 end_tik;
    //static int run = 0;
    
    switch (e->eType) {
    case frmOpenEvent:
	frm = FrmGetActiveForm();
	FrmDrawForm(frm);

	// resume interrupted count
	// note now stopWatchPrefs.tik_timestamp != stopWatchPrefs.timestamp
        // now this does work okay when switching away from app BUT
        // not when palm is turned off & on but stays in app
        // I think possibly GetTicks gets ticks from start of app
        // when palm off the ticks do not increment
	if (stopWatchPrefs.timestamp != 0) {
	    stopWatchPrefs.tik_timestamp = TimGetSeconds();
	    start_tik = TimGetTicks();
	    RunCount(start_tik);
	}

	handled = true;
	break;

    case menuEvent:
	MenuEraseStatus(NULL);

	switch(e->data.menu.itemID) {
	    // TODO add to TestTemp code
	    //case itemBar:
	    case itemRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case itemHold:
		// break the run loop
		run = 0;
		break;
	    case itemStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case itemClear:
		// break the run loop
		run = 0;
		start_sec = 0;
		stopWatchPrefs.timestamp = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	    case itemPrefs:
		FrmPopupForm(PrefForm);
		break;

	    case itemTest1:

		WinDrawLine(20,20,50,50);
//void WinDrawChar (WChar theChar, Coord x, Coord y)
///void WinDrawChars (const Char *chars, Int16 len, Coord x, Coord y)
//void WinPaintChar (WChar theChar, Coord x, Coord y)
//void WinPaintChars (const Char *chars, Int16 len, Coord x, Coord y)
///opt/palmdev/sdk-5/include/Core/System/Window.h
// Font.h
		WinDrawChar('X',20,50);
		FntSetFont(symbol11Font);
		WinDrawChar('Y',40,50);
		FntSetFont(largeFont);
		WinDrawChar('Z',60,50);
		WinDrawChars("large Font",10,80,50);
		FntSetFont(largeBoldFont);
		WinDrawChars("large Bold",10,110,50);

		{
		    char buf[100];
		    int l=0;
		    UInt32 t = SysTicksPerSecond();
		    l+=StrPrintF(buf+l, "SysTicksPerSec is %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 16;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,9,ft,WinDrawLineF);
		    drawVSeg(10,10,ft,WinDrawLineF);
		    drawHSeg(11,36,ft,WinDrawLineF);
		    drawVSeg(39,10,ft,WinDrawLineF);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 12;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,59,ft,WinDrawLineF);
		    drawVSeg(10,60,ft,WinDrawLineF);
		    drawVSeg(38,60,ft,WinDrawLineF);
		    drawHSeg(11,79,ft,WinDrawLineF);
		    drawVSeg(10,80,ft,WinDrawLineF);
		    drawVSeg(38,80,ft,WinDrawLineF);
		    drawHSeg(11,99,ft,WinDrawLineF);
		}

		bigDigit(5,20,'2',WinDrawLineF);
		bigDigit(40,20,'5',WinDrawLineF);
		bigDigit(5,70,'7',WinDrawLineF);
		break;

	    case itemTest2:

		bigDigit(5,20,'8',WinEraseLineF);
		bigDigit(40,20,'8',WinEraseLineF);
		bigDigit(5,70,'8',WinEraseLineF);

		WinDrawChars("Hello",5,20,80);
		WinPaintChars("Paint",5,20,110);

		//Err err; err = TimInit();
		{
		    char buf[100];
		    int l=0;
		    UInt32 s,t;
		    UInt32 hour,min,sec;
		    UInt32 day;
		    // seconds since 1/1/1904
		    //void TimSetSeconds(UInt32 seconds) 	
		    // ticks since power on
		    t = TimGetTicks();
		    s = TimGetSeconds();
		    
		    l+=StrPrintF(buf+l, "Secs %lu", s);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);

		    l=0;
		    l+=StrPrintF(buf+l, "Ticks %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,40);

		    day = s / (UInt32)(24 * 60 * 60);
		    s = s - day * (24 * 60 * 60);
		    hour = s / (60 * 60);
		    s = s - hour * (60 * 60);
		    min = s / 60;
		    sec = s - min * 60;
		    l=0;
		    l+=StrPrintF(buf+l, "%07d:%02d:%02d:%02d", day, hour,min,sec);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,60);

		}
		break;

		// call this periodically to hold off auto off  
		// Err EvtResetAutoOffTimer(void)

// SystemMgr.h
//Err SysTimerCreate(UInt32 *timerIDP, UInt32 *tagP, 
//            SysTimerProcPtr timerProc, UInt32 periodicDelay, UInt32	param)
//Err		SysTimerDelete(UInt32 timerID)
//Err		SysTimerWrite(UInt32 timerID, UInt32 value)
//Err		SysTimerRead(UInt32 timerID, UInt32 *valueP)

//      SysTaskDelay((100 * SysTicksPerSecond())/1000);

	    case itemOptHelp:
		FrmHelp(hlpHelp);
		break;
		//case itemOptDbgDump:
		//debugDump(e->eType);
		//break;
	    case itemOptCopy:
		FrmHelp(hlpCopy);
		break;
	    case itemOptAbout:
		FrmCustomAlert(alertInfo, 
			       "stopWatch v" VERSION " not even Alpha. "
			       "Built " __DATE__ ", " __TIME__ ". "
			       "James Coleman http://www.dspsrv.com/~jamesc "
			       "copyleft me.", "", "");
		break;

	}

	//DEBUGBOX("menuEvent","");

    	handled = true;
	break;

    case ctlSelectEvent:
	switch(e->data.ctlSelect.controlID) {

	    case btnRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case btnHold:
		// break the run loop
		run = 0;
		break;
	    case btnStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case btnClear:
		// break the run loop
		run = 0;
		stopWatchPrefs.timestamp = start_sec = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	}
	break;

    //case ctlRepeatEvent:
    //break;

    case penDownEvent:
    case penMoveEvent:
      doPenAction( e->eType, e->screenX, e->screenY, 0, 0); 
      //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2");
      break;

    case penUpEvent:
      doPenAction( penUpEvent, 
      	   e->data.penUp.start.x, e->data.penUp.start.y, 
      	   e->data.penUp.end.x, e->data.penUp.end.y);
      break;

    case keyDownEvent:

      {
	char buf[1000];
	int l=0;
	l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr);
	buf[l]=0;
	DEBUGBOX("keyDownEvent",buf);
      }

      switch(e->data.keyDown.chr) {
      case pageUpChr:
      case pageDownChr:
	handled = true;
	break;
      case prevFieldChr:
      case nextFieldChr:
      case '\n':
	handled = true;
	break;
      default:
	if (!TxtCharIsCntrl(e->data.keyDown.chr)) {
	  handled = true;                 /* Swallow event */
	}
	break;
      }
      break;

    default:
        break;
    }

    return handled;
}
Exemple #12
0
// Note: this is a litte different, it will return true
// iff the action is COMPLETE, and false if there was no action OR
// the action is needing to finish up (after leaving SenseForm).
// So if (do_drink) the caller should exit invform _and_ tick,
// otherwise the caller should just exit invform.
// (exiting the invform occurs _before_ calling do_drink..)
// .. Ok, I've modified this again so that it lets the caller distinguish
// between "it worked" and "it worked and I popped up EngraveForm".
tri_val_t do_drink(obj_t *otmp)
{
  obj_t *objs;
  //  monst_t *mtmp;
  Boolean unkn = false, nothing = false, b;
  Short tmp;

  if (!otmp) return NO_OP;
  tmp = oc_descr_offset[otmp->otype];
  if (tmp >= 0 && (0 == StrNCompare("smoky", oc_descrs+tmp, 5)) && !rund(13)) {
    ghost_from_bottle();
    useup(otmp);
    return DONE;
  }
  switch(otmp->otype) {
  case POT_RESTORE_STRENGTH:
    unkn = true;
    message("Wow!  This makes you feel great!");
    if (you.ustr < you.ustrmax) {
      you.ustr = you.ustrmax;
      flags.botl |= BOTL_STR;
    }
    break;
  case POT_BOOZE:
    unkn = true;
    message("Ooph!  This tastes like liquid fire!");
    Confusion += dice(3,8);
    /* the whiskey makes us feel better */
    if (you.uhp < you.uhpmax) losehp(-1, "bottle of whiskey");
    if (!rund(4)) {
      tri_val_t t;
      //      Short coma;
      message("You pass out.");
      multi = -rnd(15);
      spin_multi("You awake with a headache.");
      //      coma = rnd(15); //
      //      do { tick(); } while (--coma > 0);
      //      message("You awake with a headache.");
      // // nomovemsg = "You awake with a headache.";
      t = finish_do_drink(otmp, nothing, unkn); //.... I guess....
      return (t==DONE ? NO_OP : t); // so that we don't take any _more_ turns
    }
    break;
  case POT_INVISIBILITY:
    if (Invis || See_invisible)
      nothing = true;
    else {
      if (!Blind)
	message("Gee!  All of a sudden, you can't see yourself.");
      else {
	message("You feel rather airy.");
	unkn = true;
      }
      newsym(you.ux,you.uy);
    }
    Invis += rund(15)+31;
    break;
  case POT_FRUIT_JUICE:
    message("This tastes like fruit juice.");
    lesshungry(20);
    break;
  case POT_HEALING:
    message("You begin to feel better.");
    you.uhp += rnd(10);
    if (you.uhp > you.uhpmax)
      you.uhp = ++you.uhpmax;
    if (Blind) Blind = 1;	/* you'll see again on the next move */
    if (Sick) Sick = 0;
    flags.botl |= BOTL_HP;
    break;
  case POT_PARALYSIS:
    if (Levitation)
      message("You are motionlessly suspended.");
    else
      message("Your feet are frozen to the floor!");
    nomul(-(rund(10)+25));
    break;
  case POT_MONSTER_DETECTION:
    if (!fmon) {
      b = strange_feeling(otmp, "You feel threatened.");
      return ((b) ? GO_ON : DONE);
    } else {
      sense_what = SENSE_MONSTERS;
      sense_by_what = otmp;
      sense_init_screen();
      FrmPopupForm(SenseForm);
      return GO_ON; // to postpone the tick!
    }
    break;
  case POT_OBJECT_DETECTION:
    if (!fobj) {
      b = strange_feeling(otmp, "You feel a pull downward.");
      return ((b) ? GO_ON : DONE);
    } else {
      for (objs = fobj; objs; objs = objs->nobj)
	if (objs->ox != you.ux || objs->oy != you.uy) {
	  sense_what = SENSE_OBJECTS;
	  sense_by_what = otmp;
	  sense_init_screen();
	  FrmPopupForm(SenseForm);
	  return GO_ON; // to postpone the tick!
	}
      message("You sense the presence of objects close nearby.");
      break;
    }
    break;
  case POT_SICKNESS:
    message("Yech! This stuff tastes like poison.");
    if (Poison_resistance)
      message("(But in fact it was biologically contaminated orange juice.)");
    losestr(rund(4)+3);
    losehp(rnd(10), "contaminated potion");
    flags.botl |= BOTL_STR;
    break;
  case POT_CONFUSION:
    if (!Confusion)
      message("Huh, What?  Where am I?");
    else
      nothing = true;
    Confusion += rund(7)+16;
    break;
  case POT_GAIN_STRENGTH:
    message("Wow do you feel strong!");
    if (you.ustr >= 118) break;	/* > 118 is impossible */
    if (you.ustr > 17) you.ustr += rnd(118-you.ustr);
    else you.ustr++;
    if (you.ustr > you.ustrmax) you.ustrmax = you.ustr;
    flags.botl |= BOTL_STR;
    break;
  case POT_SPEED:
    if (Wounded_legs) {
      heal_legs();
      unkn = true;
      break;
    }
    if (!(Fast & ~INTRINSIC))
      message("You are suddenly moving much faster.");
    else {
      message("Your legs get new energy.");
      unkn = true;
    }
    Fast += rund(10)+100;
    break;
  case POT_BLINDNESS:
    if (!Blind)
      message("A cloud of darkness falls upon you.");
    else
      nothing = true;
    Blind += rund(100)+250;
    seeoff(false);
    break;
  case POT_GAIN_LEVEL: 
    pluslvl();
    break;
  case POT_EXTRA_HEALING:
    message("You feel much better.");
    you.uhp += dice(2,20)+1;
    if (you.uhp > you.uhpmax)
      you.uhp = (you.uhpmax += 2);
    if (Blind) Blind = 1;
    if (Sick) Sick = 0;
    flags.botl |= BOTL_HP;
    break;
  case POT_LEVITATION:
    if (!Levitation)
      float_up();
    else
      nothing = true;
    Levitation += rnd(100);
    //    you.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down; // UNNEEDED,
    // it has been replaced by tweaking timeout.c to call float_down directly!
    break;
  default:
    StrPrintF(ScratchBuffer, "What a funny potion! (%u)", otmp->otype);
    message(ScratchBuffer);
    return NO_OP;
  }
  return finish_do_drink(otmp, nothing, unkn);
}
Exemple #13
0
/*****************************************************************************
* Function: GadgetHintTap
*
* Description: Handles penDown events (taps) on the hint gadget
*****************************************************************************/
void
GadgetHintTap(FormGadgetType *pGadget, EventType *event)
{
  //you may find it useful to track if they
  //lift the pen still within the boundaries of the gadget
  Boolean isPenDown = true;
  Int16 newPointX, newPointY, startPointX, startPointY;
  UInt16 index;
  RectangleType bounds, rect;
  Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
  FontID oldFont;
  Boolean drawn=false;
  IndexedColorType curForeColor, curBackColor, curTextColor;

  // This is just needed since we do not want to access internal structure
  // data directly in FormGadgetType (need rect field below)
  index = TNGetObjectIndexFromPtr(FrmGetActiveForm(), pGadget);
  FrmGetObjectBounds(FrmGetActiveForm(), index, &bounds);

  oldFont = FntSetFont(symbolFont);
  RctSetRectangle(&rect,
                  bounds.topLeft.x+1,  // +1 for border
                  bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget
                  bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border
  RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8,
                         rect.topLeft.y+rect.extent.y-12,
                         FntLineWidth(noteSymb, 1), FntLineHeight());


  //track the pen down event
  EvtGetPen(&newPointX, &newPointY, &isPenDown);
  startPointX = newPointX;
  startPointY = newPointY;
  while (isPenDown){
    EvtGetPen(&newPointX, &newPointY, &isPenDown);

    if (gHintNote) {
      if (! drawn && RctPtInRectangle(newPointX, newPointY, &rect)) {
        curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
        curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectSelectedFill));
        curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
        TNDrawCharsToFitWidth(noteSymb, &rect);
        WinSetForeColor(curForeColor);
        WinSetForeColor(curBackColor);
        WinSetForeColor(curTextColor);
        drawn = true;
      } else if (drawn && ! RctPtInRectangle(newPointX, newPointY, &rect)) {
        curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
        curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectFill));
        curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
        TNDrawCharsToFitWidth(noteSymb, &rect);
        WinSetForeColor(curForeColor);
        WinSetForeColor(curBackColor);
        WinSetForeColor(curTextColor);
        drawn = false;
      }
    }

  }

  FntSetFont(oldFont);

  if (gHintNote && RctPtInRectangle(newPointX, newPointY, &rect)) {
    NoteSet(GadgetGetHintTimeIndex(), FORM_main);
    FrmPopupForm(NewNoteView);
  } // else outside gadget bounds -> do nothing
}
void DoAnnotate
     (
     AnnotationIdentifier* idP,
     UInt32  flags,
     UInt16  uid,
     Int16   paragraph,
     UInt16  start,
     UInt16  stop,
     Char*   word
     )
{
    if ( IsFullscreenformActive() ) {
        return;
    }

    entryP = SafeMemPtrNew( MAX_ANNOTATION_ENTRY_SIZE );
    MemSet( entryP, MAX_ANNOTATION_ENTRY_SIZE, 0 );
    entryP->flags = flags;

    data   = SafeMemPtrNew( MAX_FIELD + 1 );

    if ( idP == NULL ) {
        idP = &( entryP->id );

        if ( stop <= start ||
             ! FindAnnotation( entryP, uid, paragraph, start, stop ) ) {
            idP->indexInParagraph = NEW_ANNOTATION;
            idP->uid              = uid;
            idP->paragraphNum     = paragraph;
            entryP->triggerStart  = start;
            entryP->triggerStop   = stop;
        }
    }

    if ( idP->indexInParagraph == NEW_ANNOTATION ) {
        if ( word == NULL ) {
            *data = 0;
        }
        else {
            StrNCopy( data, word, MAX_FIELD - 2 );
            data[ MAX_FIELD - 2 ] = 0;
            if ( ! ( flags & ANNOTATION_BOOKMARK ) )
                StrCat( data, ": " );
        }
    }
    else {
        MemHandle h;
        AnnotationEntry* e;
        UInt16           size;

        h = GetAnnotation( idP->uid, idP->paragraphNum, idP->indexInParagraph, NULL );

        if ( h == NULL ) {
            SafeMemPtrFree( entryP );
            SafeMemPtrFree( data );
            return;
        }
        
        e = MemHandleLock( h );
        
        size = e->dataLength;
        
        if ( MAX_FIELD < size )
            size = MAX_FIELD;
            
        if ( 0 < size ) {
            MemMove( data, ( UInt8* )e + e->dataOffset, size );
            data[ size ] = 0;
        }
        
        if ( MAX_ANNOTATION_ENTRY_SIZE < e->headerLength ) {
            SafeMemPtrFree( entryP );
            SafeMemPtrFree( data );
            MemHandleUnlock( h );
            return;
        }

        MemMove( entryP, e, e->headerLength );

        MemHandleUnlock( h );
    }

    FrmPopupForm( frmAnnotation );
}
Exemple #15
0
static Boolean MainFormMenuCommand(AppContext* appContext, FormType* form, EventType* event)
{
    Boolean handled=false;
    switch (event->data.menu.itemID)
    {
        case menuItemAbout: 
            MainFormHandleAbout(appContext);
            handled=true;
            break;

        case menuItemCopy:
            MainFormHandleCopy(appContext);
            handled=true;
            break;

        case menuItemLookupClipboard:
            MainFormLookupClipboard(appContext);
            handled=true;
            break;

        case menuItemRandomWord:
            LookupRandomWord(appContext);
            handled=true;
            break;

        case menuItemRecentLookups:
            MainFormHandleRecentLookups(appContext);
            handled=true;
            break;

        case menuItemPrefs:
            FrmPopupForm(formPrefs);
            handled=true;
            break;

        case menuItemDispPrefs:
            FrmPopupForm(formDisplayPrefs);
            handled=true;
            break;

        case menuItemRegister:
#ifdef UNLOCKED
            FrmAlert(alreadyRegisteredAlert);
#else
            MainFormHandleRegister(appContext,false);
#endif
            FrmUpdateForm(formDictMain, redrawAll); 
            handled=true;
            break;

        case menuItemBookmarkView:
            if (GetBookmarksCount(appContext)>0)
                FrmPopupForm(formBookmarks);
            else
                FrmAlert(alertNoBookmarks);
            handled=true;
            break;

        case menuItemBookmarkWord:
            if (ebufGetDataSize(&appContext->currentWordBuf))
                AddBookmark(appContext, ebufGetDataPointer(&appContext->currentWordBuf));
            handled=true;
            break;

        case menuItemBookmarkDelete:
            if (ebufGetDataSize(&appContext->currentWordBuf))
                DeleteBookmark(appContext, ebufGetDataPointer(&appContext->currentWordBuf));
            handled=true;
            break;

        case menuItemGotoWebsite:
            //if ( errNone != ErrWebBrowserCommand(false, 0, sysAppLaunchCmdGoToURL, "http://arslexis.local.org:4080/pda/palm.html",NULL) )
            if ( errNone != ErrWebBrowserCommand(false, 0, sysAppLaunchCmdGoToURL, "http://www.arslexis.com/pda/palm.html",NULL) )
                FrmAlert(alertNoWebBrowser);
            handled=true;
            break;

        case menuItemCheckUpdates:
            //if ( errNone != ErrWebBrowserCommand(false, 0, sysAppLaunchCmdGoToURL, "http://arslexis.local.org:4080/updates/palm-inoah-1-0.html",NULL) )
            if ( errNone != ErrWebBrowserCommand(false, 0, sysAppLaunchCmdGoToURL, "http://www.arslexis.com/updates/palm-inoah-1-1.html",NULL) )
                FrmAlert(alertNoWebBrowser);
            handled=true;
            break;
        case forwardMenuItem:
            DoForward(appContext);
            handled=true;
            break;
        case backMenuItem:
            DoBack(appContext);
            handled=true;
            break;
#ifdef DEBUG
        case menuItemStress:
            appContext->fInStress = true;
            LookupRandomWord(appContext);
            handled=true;
            break;
#endif

        case sysEditMenuCopyCmd:
        case sysEditMenuCutCmd:
        case sysEditMenuPasteCmd:
            // generated by command bar, not sure what to do with those
            // so just ignore them
            handled = false;
            break;
        default:
            Assert(false);
    }
    return handled;
}
Exemple #16
0
Boolean
ExamsFormHandleEvent(EventPtr event)
{
  FormPtr frm=FrmGetActiveForm();
  Boolean handled = false;
  Boolean categoryEdited, reDraw=false;
  UInt16 category, numRecords;
  ControlType *ctl;
  UInt32 *recordList;

  if (event->eType == ctlSelectEvent) {
    // button handling
    switch (event->data.ctlSelect.controlID) {
      case BUTTON_ex_back:
        handled=true;
        FrmGotoForm(FORM_main);
        break;

      case BUTTON_ex_add:
        handled=true;
        if (CountCourses() > 0) {
          gExamsLastSelRowUID=0;
          FrmPopupForm(FORM_exam_details);
        } else {
          FrmAlert(ALERT_nocourses);
        }
        break;

      case BUTTON_ex_edit:
        handled=true;
        gExamsLastSelRowUID=TblGetRowData(GetObjectPtr(TABLE_exams), gExamsSelRow);
        FrmPopupForm(FORM_exam_details);
        break;

      case BUTTON_ex_note:
      {
        UInt16 index=0;

        handled=true;

        gExamsLastSelRowUID=TblGetRowData(GetObjectPtr(TABLE_exams), gExamsSelRow);
        DmFindRecordByID(DatabaseGetRefN(DB_MAIN), gExamsLastSelRowUID, &index);
        NoteSet(index, FORM_exams);
        FrmPopupForm(NewNoteView);
        break;
      }

      case BUTTON_ex_del:
        handled=true;
        gExamsLastSelRowUID=TblGetRowData(GetObjectPtr(TABLE_exams), gExamsSelRow);
        ExamDelete();
        break;

      case BUTTON_ex_beam:
        handled=true;
        gExamsLastSelRowUID=TblGetRowData(GetObjectPtr(TABLE_exams), gExamsSelRow);
        ExamBeam();
        break;

      case LIST_ex_cat_trigger:
        handled=true;
        category=DatabaseGetCat();
        numRecords=DmNumRecordsInCategory(DatabaseGetRef(), DELETE_CATEGORY);
        recordList=(UInt32 *)MemPtrNew(numRecords * sizeof(UInt32));
        CatPreEdit(numRecords, recordList);
        categoryEdited = CategorySelect(DatabaseGetRef(), frm,
                                        LIST_ex_cat_trigger, LIST_ex_cat, false,
                                        &category, gCategoryName, 0,
                                        STRING_cat_edit); // categoryDefaultEditCategoryString
        if (categoryEdited || (category != DatabaseGetCat())) {
          reDraw=true;
          DatabaseSetCat(category);
          ctl = GetObjectPtr(LIST_ex_cat_trigger);
          CategoryGetName(DatabaseGetRef(), category, gCategoryName); 
          CategorySetTriggerLabel(ctl, gCategoryName);
        }
        CatPostEdit(numRecords, recordList);
        if (reDraw) {
          gExamsOffset=0;
          gExamsSelRow=0;
          FrmUpdateForm(FORM_exams, frmRedrawUpdateCode);
        }
        if (recordList != NULL)  MemPtrFree((MemPtr)recordList);
        break;

      default:
        break;
    }
  } else if (event->eType == tblEnterEvent) {
    UInt16 i;
    
    if (event->data.tblEnter.column == EXCOL_DONE) {
      handled=false;
    } else if (event->data.tblEnter.column == EXCOL_NOTE) {
      MemHandle m;
      Boolean hasNote=false;

      gExamsSelRow=event->data.tblEnter.row;
      for (i=0; i < TblGetNumberOfRows(event->data.tblEnter.pTable); ++i) {
        RectangleType r;
        TblGetItemBounds(event->data.tblEnter.pTable, i, EXCOL_SELI, &r);
        TableDrawSelection(event->data.tblEnter.pTable, i, event->data.tblEnter.column, &r);
      }


      m = DmQueryRecord(DatabaseGetRefN(DB_MAIN), TblGetRowID(event->data.tblEnter.pTable, event->data.tblEnter.row));
      if (m) {
        ExamDBRecord *ex = (ExamDBRecord *)MemHandleLock(m);
        if (ex->note) hasNote = true;
        else          hasNote = false;
        MemHandleUnlock(m);
      }

      if (hasNote) {
        Coord newPointX, newPointY;
        Boolean isPenDown=false, drawn=false;
        RectangleType fieldBounds;
        IndexedColorType curForeColor, curBackColor, curTextColor;
        Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
        FontID oldFont;
  
  
        EvtGetPen(&newPointX, &newPointY, &isPenDown);
        TblGetItemBounds(event->data.tblEnter.pTable, event->data.tblEnter.row, EXCOL_NOTE, &fieldBounds);
  
        oldFont = FntSetFont(symbolFont);
        while (isPenDown){
          if (! drawn && RctPtInRectangle(newPointX, newPointY, &fieldBounds)) {
            curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
            curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectSelectedFill));
            curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
            TNDrawCharsToFitWidth(noteSymb, &fieldBounds);
            WinSetForeColor(curForeColor);
            WinSetForeColor(curBackColor);
            WinSetForeColor(curTextColor);
            drawn = true;
          } else if (drawn && ! RctPtInRectangle(newPointX, newPointY, &fieldBounds)) {
            curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
            curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectFill));
            curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
            TNDrawCharsToFitWidth(noteSymb, &fieldBounds);
            WinSetForeColor(curForeColor);
            WinSetForeColor(curBackColor);
            WinSetForeColor(curTextColor);
            drawn = false;
          }
          EvtGetPen(&newPointX, &newPointY, &isPenDown);
        }
        FntSetFont(oldFont);
      } else {
        handled = true;
      }
    } else {
      gExamsSelRow=event->data.tblEnter.row;
      for (i=0; i < TblGetNumberOfRows(event->data.tblEnter.pTable); ++i) {
        RectangleType r;
        TblGetItemBounds(event->data.tblEnter.pTable, i, EXCOL_SELI, &r);
        TableDrawSelection(event->data.tblEnter.pTable, i, event->data.tblEnter.column, &r);
      }
      handled=true;
    }
  } else if (event->eType == tblSelectEvent) {
    if (event->data.tblEnter.column == EXCOL_DONE) {
      MemHandle mex;
      ExamDBRecord *ex;
      Boolean done=(TblGetItemInt(event->data.tblSelect.pTable, event->data.tblSelect.row, event->data.tblSelect.column) == 0) ? false : true;
      UInt16 flags, index=TblGetRowID(event->data.tblSelect.pTable, event->data.tblSelect.row);

      mex=DmGetRecord(DatabaseGetRefN(DB_MAIN), index);
      ex = MemHandleLock(mex);
      flags = ex->flags;

      if (done) {
        flags |= EX_FLAG_DONE;
      } else {
        flags &= (EX_FLAG_DONE ^ 0xFFFF);
      }

      DmWrite(ex, offsetof(ExamDBRecord, flags), &flags, sizeof(flags));
      DmReleaseRecord(DatabaseGetRefN(DB_MAIN), index, false);

      TblMarkRowInvalid(event->data.tblSelect.pTable, event->data.tblSelect.row);
      TblRedrawTable(event->data.tblSelect.pTable);

      MemHandleUnlock(mex);

    } else if (event->data.tblEnter.column == EXCOL_NOTE) {
      ControlType *ctl=GetObjectPtr(BUTTON_ex_note);
      // Don't need code twice, just read ctlSelect Event for BUTTON_ex_note
      CtlHitControl(ctl);
    }
    handled=true;
  } else if (event->eType == ctlRepeatEvent) {
    // Repeat buttons pressed
    if( event->data.ctlRepeat.controlID == REPEAT_ex_up )
      gExamsOffset -= 1;
    else
      gExamsOffset += 1;

    ExamsTableInit();
    TblMarkTableInvalid(GetObjectPtr(TABLE_exams));
    TblRedrawTable(GetObjectPtr(TABLE_exams));
  } else if (event->eType == keyDownEvent) {
    // We have a hard button assigned and it was pressed
    if (TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr)) {
      if (! (event->data.keyDown.modifiers & poweredOnKeyMask)) {
        FrmGotoForm(FORM_main);
        handled = true;
      }
    }
  } else if (event->eType == menuOpenEvent) {
    return HandleMenuOpenEvent(event);
  } else if (event->eType == menuEvent) {
    // forwarding of menu events
    return HandleMenuEvent(event->data.menu.itemID);
  } else if (event->eType == frmOpenEvent) {
    // initializes and draws the form
    ControlType *ctl;

    gExamsOffset=0;
    ExamsTableInit();
    FrmDrawForm (frm);

    ctl = GetObjectPtr(LIST_ex_cat_trigger);
    CategoryGetName (DatabaseGetRef(), DatabaseGetCat(), gCategoryName); 
    CategorySetTriggerLabel (ctl, gCategoryName); 

    handled = true;
  } else if (event->eType == frmUpdateEvent) {
    // redraws the form if needed
    gExamsOffset=0;
    ExamsTableInit();
    FrmDrawForm(frm);
    handled = false;
  } else if (event->eType == frmCloseEvent) {
    // this is done if form is closed
    // TblEraseTable(GetObjectPtr(TABLE_exams));
    // ExamsFormFree();
    FrmEraseForm(frm);
  }

  return (handled);

}
Exemple #17
0
/***********************************************************************
 * handling for the main drop down menu actions
 ***********************************************************************/
Boolean
HandleMenuEvent (UInt16 command)
{
  Boolean handled = false;
  MenuEraseStatus(0);
  gMenuCurrentForm=FrmGetFormId(FrmGetActiveForm());

  switch (command) {
  case MENUITEM_about:
    FrmDoDialog(FrmInitForm(FORM_about));
    handled=true;
    break;

  case MENUITEM_course:
    AddCourse();
    handled=true;
    break;

  case MENUITEM_time:
    if (CountCourses() != 0) {
      AddTime();
    } else {
      FrmAlert(ALERT_nocourses);
    }
    handled=true;
    break;

  case MENUITEM_courselist:
    FrmGotoForm(FORM_courselist);
    handled=true;
    break;

  case MENUITEM_settings:
    FrmPopupForm(FORM_settings);
    handled=true;
    break;

  case MENUITEM_alarm:
    FrmPopupForm(FORM_alarm_sets);
    handled=true;
    break;

  case MENUITEM_exams:
    FrmGotoForm(FORM_exams);
    handled=true;
    break;

  case MENUITEM_beam:
    BeamSemester(DatabaseGetCat());
    handled=true;
    break;

  case MENUITEM_chat:
    AppLaunchWithCommand(UNICHAT_APP_CREATOR, sysAppLaunchCmdNormalLaunch, NULL);
    handled=true;
    break;

  case MENUITEM_mensa:
    AppLaunchWithCommand(UNIMENSA_APP_CREATOR, sysAppLaunchCmdNormalLaunch, NULL);
    handled=true;
    break;

  default:
    break;
  }

  return handled;
}