예제 #1
0
/**
 *  MouseFinish is called when you are done with the mouse module
 *  and no longer need it.  All hooks and variables are changed to non-
 *  active mode and you can consider it no longer being used.
 *
 *<!-----------------------------------------------------------------------*/
T_void MouseFinish(T_void)
{
    DebugRoutine("MouseFinish") ;
    DebugCheck(F_MouseIsInitialized == TRUE) ;
    DebugCheck(G_mouseShowLevel < 2) ;

    DebugCheck(G_eventStack != DOUBLE_LINK_LIST_BAD) ;
    DoubleLinkListDestroy(G_eventStack) ;

    /* Hide the mouse. */
    MouseHide() ;

    /* Turn off the event handler. */
    MouseSetEventHandler(NULL) ;

    /* Set the default options. */
    MouseSetEventOptions(MOUSE_EVENT_DEFAULT_OPTIONS) ;

    /* Allow the mouse to move all over the screen. */
    MouseReleaseBounds() ;

    /* Note that the mouse module is no longer in use. */
    F_MouseIsInitialized = FALSE ;

    /* Free up the mouse background screen. */
    GrScreenFree(G_mouseScreen) ;
#ifdef DOS32
    IMouseUninstallCallback() ;
#endif
    DebugEnd() ;
}
예제 #2
0
/**
 *  MousePushEventHandler removes the old handler by placing it on
 *  a stack and sets up the new event handler.  The old event handler
 *  will be restored when a call to MousePopEventHandler is called.
 *
 *  @param mouseEventHandler -- function to call on events, or NULL
 *      for none.
 *
 *<!-----------------------------------------------------------------------*/
T_void MousePushEventHandler(T_mouseEventHandler mouseEventHandler)
{
    DebugRoutine("MousePushEventHandler") ;

    /* Store the old event handler. */
    DoubleLinkListAddElementAtFront(
        G_eventStack,
        (T_void *)MouseGetEventHandler) ;

    /* set up the new handler. */
    MouseSetEventHandler(mouseEventHandler) ;

    DebugEnd() ;
}
예제 #3
0
/**
 *  MousePopEventHandler restores the last handler on the stack
 *  (if there is one).
 *
 *<!-----------------------------------------------------------------------*/
T_void MousePopEventHandler(T_void)
{
    T_doubleLinkListElement first ;
    T_mouseEventHandler handler ;

    DebugRoutine("MousePopEventHandler") ;

    /* Get the old event handler. */
    first = DoubleLinkListGetFirst(G_eventStack) ;
    DebugCheck(first != DOUBLE_LINK_LIST_ELEMENT_BAD) ;

    if (first != DOUBLE_LINK_LIST_ELEMENT_BAD)  {
        handler = (T_mouseEventHandler)
                      DoubleLinkListElementGetData(first) ;

        MouseSetEventHandler(handler) ;
        DoubleLinkListRemoveElement(first) ;
    }

    DebugEnd() ;
}
예제 #4
0
파일: FORM.C 프로젝트: LesInk/Test
T_void FormGenericControl(E_Boolean *exitflag)
{
    static T_word32 delta = 0, lastupdate = 0;
    T_keyboardEventHandler keyhandl;
    T_mouseEventHandler mousehandl;
    T_bitmap *p_bitmap;
    T_resource r_bitmap;
    T_bitmap *p_oldBitmap;
    T_word16 hotX, hotY;

    DebugRoutine("FormGenericControl");

    lastupdate = TickerGet();
    *exitflag = FALSE;

    /** Initialize the mouse. **/
    MouseGetBitmap(&hotX, &hotY, &p_oldBitmap);
    p_bitmap = (T_bitmap *)PictureLock("UI/MOUSE/DEFAULT", &r_bitmap);
    DebugCheck(p_bitmap != NULL);
    MouseSetDefaultBitmap(0, 0, p_bitmap);
    MouseUseDefaultBitmap();

    /* show the mouse and set the keyboard/mouse event handlers */
    keyhandl = KeyboardGetEventHandler();
    mousehandl = MouseGetEventHandler();
    /* flush the keyboard */
    KeyboardDebounce();
    MouseSetEventHandler(FormHandleMouse);
    KeyboardSetEventHandler(FormHandleKey);
//    MouseShow();

    do {
        delta = TickerGet();
        /* update color every 4 ticks */
        if ((delta - lastupdate) > 0) {
            lastupdate = delta;
            ColorUpdate(delta - lastupdate);
        }

        /* update events */
        GraphicUpdateAllGraphics();
//        MouseHide();
        MouseUpdateEvents();
        KeyboardUpdateEvents();
        SoundUpdate();
//        MouseShow();
//        delay (20);
    } while (*exitflag == FALSE
            && KeyboardGetScanCode(KEY_SCAN_CODE_ESC) == FALSE);

    /* clean up */
//    MouseHide();
    FormCleanUp();
    MouseSetEventHandler(mousehandl);
    KeyboardSetEventHandler(keyhandl);
    KeyboardDebounce();

    /** free up the mouse pointer resource. **/
    ResourceUnlock(r_bitmap);
    ResourceUnfind(r_bitmap);

    /* Turn off the mouse */
    MouseSetDefaultBitmap(hotX, hotY, p_oldBitmap);
    MouseUseDefaultBitmap();

    DebugEnd();
}