home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 34.8 KB | 1,043 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEvent.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWMAPING_H
- #include "FWMaping.h"
- #endif
-
- #ifndef FWFCTINF_H
- #include "FWFctInf.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwevents
- #endif
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- const short FW_CSystemEvent::kEmpty = 0;
- const short FW_CSystemEvent::kExtend = 1; // Mac: shift Windows:
- const short FW_CSystemEvent::kItem = 2; // Mac: shift Windows:
- const short FW_CSystemEvent::kCopy = 4; // Mac: shift Windows:
- const short FW_CSystemEvent::kControl = 8; // Mac: shift Windows:
-
- //========================================================================================
- // CLASS FW_CSystemEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time)
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::SetMemory(&fEvent, sizeof(ODEventData), 0);
- fEvent.when = time;
- fPlatformWindow = theWindow;
- #endif
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::SetMemory(&fEvent, sizeof(MSG), 0);
- FW_ASSERT(theWindow != NULL);
- fEvent.hwnd = theWindow;
- fEvent.time = time;
- fPlatformWindow = theWindow;
- #endif
- fPropagated = FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, ODEventData* theEvent, FW_Boolean propagated)
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::CopyMemory(theEvent, &fEvent, sizeof(ODEventData));
- fPlatformWindow = NULL;
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::CopyMemory(theEvent, &fEvent, sizeof(MSG));
- fPlatformWindow = (HWND)fEvent.hwnd;
- #endif
- fPropagated = propagated;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, const FW_CSystemEvent& other)
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::CopyMemory(((FW_CSystemEvent&)other).GetPlatformEvent(), &fEvent, sizeof(ODEventData));
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::CopyMemory(((FW_CSystemEvent&)other).GetPlatformEvent(), &fEvent, sizeof(MSG));
- #endif
-
- fPlatformWindow = other.GetPlatformWindow();
- fPropagated = other.fPropagated;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::~FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::~FW_CSystemEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetModifiers
- //----------------------------------------------------------------------------------------
-
- unsigned short FW_CSystemEvent::GetModifiers(Environment* ev) const
- {
- unsigned short modifiers = kEmpty;
-
- if (this->IsExtendModifier(ev))
- modifiers |= kExtend;
- if (this->IsItemModifier(ev))
- modifiers |= kItem;
- if (this->IsCopyModifier(ev))
- modifiers |= kCopy;
- if (this->IsControlKeyModifier(ev))
- modifiers |= kControl;
-
- return modifiers;
- }
-
- //========================================================================================
- // CLASS FW_CNullEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, ODEventData* theEvent, FW_Boolean propagated) :
- FW_CSystemEvent(ev, theEvent, propagated)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time) :
- FW_CSystemEvent(ev, theWindow, time)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, const FW_CNullEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = nullEvent;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_NULL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::~FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::~FW_CNullEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CMacWindowEvent
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMacWindowEvent::FW_CMacWindowEvent
- //----------------------------------------------------------------------------------------
- FW_CMacWindowEvent::FW_CMacWindowEvent(Environment* ev, ODEventData* theEvent, FW_Boolean propagated) :
- FW_CSystemEvent(ev, theEvent, propagated)
- {
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMacWindowEvent::~FW_CMacWindowEvent
- //----------------------------------------------------------------------------------------
- FW_CMacWindowEvent::~FW_CMacWindowEvent()
- {
- }
- #endif
-
- //========================================================================================
- // CLASS FW_CMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev,
- ODEventData* theEvent,
- ODFacet* theFacet,
- EButtonState theState,
- FW_Boolean propagated,
- short numOfClicks) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fFacet(theFacet),
- fButtonState(theState),
- fNumberOfClicks(numOfClicks)
- {
- #ifdef FW_BUILD_MAC
- fWhichButton = kLeftMouseButton;
- #endif
- #ifdef FW_BUILD_WIN
- if (theEvent->message == WM_LBUTTONDOWN || theEvent->message == WM_LBUTTONUP)
- fWhichButton = kLeftMouseButton;
- else if (theEvent->message == WM_MBUTTONDOWN || theEvent->message == WM_RBUTTONUP)
- fWhichButton = kMiddleMouseButton;
- else
- fWhichButton = kRightMouseButton;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev,
- ODFacet* theFacet,
- EButtonState theState,
- EWhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CSystemEvent(ev, theWindow, when),
- fFacet(theFacet),
- fButtonState(theState),
- fWhichButton(initialButton),
- fNumberOfClicks(numOfClicks)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = mouseDown;
- else
- fEvent.what = mouseUp;
-
- fEvent.where = where.AsPlatformPoint();
-
- if (modifiers & kExtend)
- fEvent.modifiers += shiftKey;
- if (modifiers & kItem)
- fEvent.modifiers += cmdKey;
- if (modifiers & kCopy)
- fEvent.modifiers += optionKey;
- if (modifiers & kControl)
- fEvent.modifiers += controlKey;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- {
- if (initialButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONDOWN;
- else if (initialButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONDOWN;
- else
- fEvent.message = WM_RBUTTONDOWN;
- }
- else
- {
- if (initialButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONUP;
- else if (initialButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONUP;
- else
- fEvent.message = WM_RBUTTONUP;
- }
-
- fEvent.pt = where.AsPlatformPoint();
- fEvent.lParam = MAKELONG(fEvent.pt.x, fEvent.pt.y);
-
- if (modifiers & kExtend)
- fEvent.wParam += MK_SHIFT;
- if ((modifiers & kItem) || (modifiers & kCopy) || (modifiers & kControl))
- fEvent.wParam += MK_CONTROL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& embeddedEvent) :
- FW_CSystemEvent(ev, embeddedEvent)
- {
- fFacet = embeddedEvent.GetFacet(ev);
- fButtonState = embeddedEvent.GetButtonState(ev);
- fWhichButton = embeddedEvent.GetInitialButtonPressed(ev);
- fNumberOfClicks = embeddedEvent.GetNumberOfClicks(ev);
-
- #ifdef FW_BUILD_MAC
- if (fButtonState == kMouseButtonDown)
- fEvent.what = mouseDown;
- else
- fEvent.what = mouseUp;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (fButtonState == kMouseButtonDown)
- {
- if (fWhichButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONDOWN;
- else if (fWhichButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONDOWN;
- else
- fEvent.message = WM_RBUTTONDOWN;
- }
- else
- {
- if (fWhichButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONUP;
- else if (fWhichButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONUP;
- else
- fEvent.message = WM_RBUTTONUP;
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev, const FW_CMouseEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fFacet = other.GetFacet(ev);
- fButtonState = other.GetButtonState(ev);
- fWhichButton = other.GetInitialButtonPressed(ev);
- fNumberOfClicks = other.GetNumberOfClicks(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::~FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::~FW_CMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetLogicalMousePosition
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CMouseEvent::GetLogicalMousePosition(Environment* ev,
- const FW_CMapping& mapping) const
- {
- // [LSD] use kFrame for now: to fix later
- FW_CPoint position = FW_CMouseEvent::GetMousePosition(ev, kFrame);
-
- // Note: I am calling DeviceToLogical and not LogicalToDevice because at this point position
- // is in "OpenDoc" coordinate (72 dpi on both platform) and I want it in logical coordinate
- FW_CPlatformPoint plfmPoint = position;
- mapping.DeviceToLogical(ev, plfmPoint, position, FW_GetFacetGraphicDevice(ev, fFacet), NULL);
-
- return position;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetMousePosition
- //----------------------------------------------------------------------------------------
- // [LSD] This cannot return a position in Content coordinates because the ContentView may
- // not be at the frame's origin. Get Frame coordinates and convert to Content afterward.
-
- FW_CPoint FW_CMouseEvent::GetMousePosition(Environment* ev, ECoordinates coordinate) const
- {
- #ifdef FW_BUILD_MAC
- FW_CPlatformPoint mousePos(fEvent.where);
- #endif
- #ifdef FW_BUILD_WIN
- FW_CPlatformPoint mousePos(fEvent.pt);
- #endif
-
- // ----- Convert into window coordinates -----
- if (coordinate != kScreen)
- {
- #ifdef FW_BUILD_MAC
- ODWindow* aqWindow = fFacet->GetWindow(ev);
- GrafPtr svGrafPtr;
- ::GetPort(&svGrafPtr);
- GrafPtr grafPtr = aqWindow->GetPlatformWindow(ev);
- ::SetPort(grafPtr);
- FW_CPlatformPoint svOrigin(grafPtr->portRect.left, grafPtr->portRect.top);
- ::SetOrigin(0,0);
- ::GlobalToLocal(&mousePos);
- ::SetOrigin(svOrigin.h, svOrigin.v);
- ::SetPort(svGrafPtr);
- #endif
-
- #ifdef FW_BUILD_WIN
- // Use the global coordinate because the lParam field gets replaced if the event
- // is an embedded mouse event
- // !!! May need to worry about scrolling here
- ::ScreenToClient((HWND)fEvent.hwnd, &mousePos);
- // [WIN_PORT] fEvent.hwnd is a void* not an HWND!
- #endif
- }
-
- FW_CPoint position = mousePos;
- if (coordinate == kFrame)
- FW_WindowToFrame(ev, fFacet, position);
-
- return position;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsLeftButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsLeftButtonPressed(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return TRUE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kLeftMouseButton) ? TRUE : (fEvent.wParam & MK_LBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsMiddleButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsMiddleButtonPressed(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return FALSE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kMiddleMouseButton) ? TRUE : (fEvent.wParam & MK_MBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsRightButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsRightButtonPressed(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return FALSE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kRightMouseButton) ? TRUE : (fEvent.wParam & MK_RBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::WaitMouseMoved
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::WaitUntilMouseMoved(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return ::WaitMouseMoved(fEvent.where);
- #endif
- #ifdef FW_BUILD_WIN
- MSG event;
- BOOL bMoved = FALSE;
- DWORD InitialTick = ::GetTickCount();
- HWND hwnd = fFacet->GetWindow(ev)->GetPlatformWindow(ev);
- /* Don't capture the mouse if we're minimized!
- */
- if(IsIconic(hwnd))
- return FALSE;
-
- ::SetCapture(hwnd);
- do
- {
- ::GetMessage(&event,NULL,NULL,NULL);
- ::TranslateMessage(&event); // Translates virtual key codes
- ::DispatchMessage(&event); // Dispatches message to window
-
- if ( (event.message == WM_LBUTTONUP)
- || (event.message == WM_RBUTTONUP)
- || (event.message == WM_LBUTTONDOWN)
- || (event.message == WM_RBUTTONDOWN)
- || (event.message == WM_CHAR)
- || (::GetTickCount() < InitialTick)
- || (::GetTickCount() > InitialTick+300)
- )
- break;
- else if (event.message == WM_MOUSEMOVE)
- {
- int deltax = fEvent.pt.x - event.pt.x;
- if (deltax<0) deltax *= -1;
- int deltay = fEvent.pt.y - event.pt.y;
- if (deltay<0) deltay *= -1;
- bMoved = ((deltay >= 3) || (deltax >= 3));
- }
- } while(!bMoved);
- ::ReleaseCapture();
-
- return bMoved;
- #endif
-
- }
-
- //========================================================================================
- // CLASS FW_CEmbeddedMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- EButtonState theState,
- FW_Boolean propagated,
- short numOfClicks) :
- FW_CMouseEvent(ev, theEvent, theFacet, theState, propagated, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- EButtonState theState,
- EWhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CMouseEvent(ev, theFacet, theState, initialButton, theWindow, when, where, modifiers, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = kODEvtMouseDownEmbedded;
- else
- fEvent.what = kODEvtMouseUpEmbedded;
- #endif
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- fEvent.message = kODEvtMouseDownEmbedded;
- else
- fEvent.message = kODEvtMouseUpEmbedded;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& other) :
- FW_CMouseEvent(ev, other)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::~FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::~FW_CEmbeddedMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::GetEmbeddedFrame
- //----------------------------------------------------------------------------------------
- ODFrame* FW_CEmbeddedMouseEvent::GetEmbeddedFrame(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fEmbeddedFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::GetEmbeddedFacet
- //----------------------------------------------------------------------------------------
- ODFacet* FW_CEmbeddedMouseEvent::GetEmbeddedFacet(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fEmbeddedFacet;
- }
-
- //========================================================================================
- // CLASS FW_CBorderMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev,
- ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- EButtonState theState,
- FW_Boolean propagated,
- short numOfClicks) :
- FW_CMouseEvent(ev, theEvent, theFacet, theState, propagated, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- EButtonState theState,
- EWhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CMouseEvent(ev, theFacet, theState, initialButton, theWindow, when, where, modifiers, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = kODEvtMouseDownBorder;
- else
- fEvent.what = kODEvtMouseUpBorder;
- #endif
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- fEvent.message = kODEvtMouseDownBorder;
- else
- fEvent.message = kODEvtMouseUpBorder;
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev, const FW_CBorderMouseEvent& other) :
- FW_CMouseEvent(ev, other)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::~FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::~FW_CBorderMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::GetEmbeddedFrame
- //----------------------------------------------------------------------------------------
- ODFrame* FW_CBorderMouseEvent::GetEmbeddedFrame(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fEmbeddedFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::GetEmbeddedFacet
- //----------------------------------------------------------------------------------------
- ODFacet* FW_CBorderMouseEvent::GetEmbeddedFacet(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fEmbeddedFacet;
- }
-
-
- //========================================================================================
- // CLASS FW_CVirtualKeyEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev,
- ODEventData* theEvent,
- KeyboardState theKeyboardState,
- FW_Boolean propagated,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fKeyboardState(theKeyboardState),
- fRepeatCount(repeatCount)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev,
- KeyboardState theKeyboardState,
- short keyCode,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theWindow, when),
- fKeyboardState(theKeyboardState),
- fRepeatCount(repeatCount)
- {
- #ifdef FW_BUILD_MAC
- if (theKeyboardState == kKeyDown)
- {
- if (repeatCount > 0)
- fEvent.what = autoKey;
- else
- fEvent.what = keyDown;
- }
- else
- fEvent.what = keyUp;
-
- fEvent.message = keyCode << 8;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (theKeyboardState == kKeyDown)
- fEvent.message = WM_KEYDOWN;
- else
- fEvent.message = WM_KEYUP;
-
- fEvent.wParam = keyCode;
- fEvent.lParam = repeatCount;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev, const FW_CVirtualKeyEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fKeyboardState = other.GetKeyboardState(ev);
- fRepeatCount = other.GetRepeatCount(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::~FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::~FW_CVirtualKeyEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::GetKeyCode
- //----------------------------------------------------------------------------------------
- short FW_CVirtualKeyEvent::GetKeyCode(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return (fEvent.message & keyCodeMask) >> 8;
- #endif
- #ifdef FW_BUILD_WIN
- return LOWORD(fEvent.wParam);
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::IsCommandPeriod
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CVirtualKeyEvent::IsCommandPeriod(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- FW_Boolean isCommandPeriod = FALSE;
-
- if (fEvent.modifiers & cmdKey) {
-
- long virtualKey = (fEvent.message & keyCodeMask) >> 8;
- short keyCode = (fEvent.modifiers & 0xFE00) | virtualKey;
-
- Ptr theKCHR = (Ptr) ::GetScriptManagerVariable(smKCHRCache);
- unsigned long state = 0;
- long keyInfo = ::KeyTranslate(theKCHR, keyCode, &state);
- long char1 = keyInfo & 0x000000FF;
- long char2 = (keyInfo & 0x00FF0000) >> 16;
-
- isCommandPeriod = (char1 == 0x2E) || (char2 == 0x2E);
- }
-
- return isCommandPeriod;
- #endif
-
- #ifdef FW_BUILD_WIN
- return FALSE;
- #endif
- }
-
- //========================================================================================
- // CLASS FW_CCharKeyEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev, ODEventData* theEvent, FW_Boolean propagated, unsigned short repeatCount) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fRepeatCount(repeatCount)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev,
- char keyChar,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theWindow, when),
- fRepeatCount(repeatCount)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = keyDown;
- fEvent.message = keyChar;
- #endif
-
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_CHAR;
- fEvent.wParam = keyChar;
- fEvent.lParam = repeatCount;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev, const FW_CCharKeyEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fRepeatCount = other.GetRepeatCount(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::~FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::~FW_CCharKeyEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::GetChar
- //----------------------------------------------------------------------------------------
- char FW_CCharKeyEvent::GetChar(Environment* ev) const
- {
- FW_UNUSED(ev);
- #ifdef FW_BUILD_MAC
- return (char)fEvent.message & charCodeMask;
- #endif
- #ifdef FW_BUILD_WIN
- return (char)fEvent.wParam;
- #endif
- }
-
- //========================================================================================
- // CLASS FW_CActivateEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev,
- ODEventData* theEvent,
- ODFacet* facet,
- FW_Boolean theState,
- FW_Boolean propagated) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fActivationState(theState),
- fFacet(facet)
- {
- #ifdef FW_BUILD_MAC
- fPlatformWindow = (ODPlatformWindow)fEvent.message;
- #endif
- #ifdef FW_BUILD_WIN
- fPlatformWindow = (ODPlatformWindow)LOWORD(fEvent.lParam);
- // [WIN_PORT] Messge param cracking for Win32/Win16 -- different!
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev,
- ODFacet* facet,
- FW_Boolean theState,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when) :
- FW_CSystemEvent(ev, theWindow, when),
- fActivationState(theState),
- fFacet(facet)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = activateEvt;
- fEvent.message = (long)theWindow;
- if (theState)
- fEvent.modifiers = activeFlag;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_ACTIVATE;
- if (theState)
- fEvent.wParam = WA_ACTIVE;
- else
- fEvent.wParam = WA_INACTIVE;
- fEvent.lParam = (LPARAM) theWindow;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev, const FW_CActivateEvent& other) :
- FW_CSystemEvent(ev, other),
- fActivationState(other.fActivationState),
- fFacet(other.fFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::~FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::~FW_CActivateEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CSuspendResumeEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::FW_CSuspendResumeEvent(Environment* ev,
- ODEventData* theEvent,
- ODFacet* facet,
- FW_Boolean isGoingToBackground,
- FW_Boolean propagated) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fIsGoingToBackground(isGoingToBackground),
- fFacet(facet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::FW_CSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& other) :
- FW_CSystemEvent(ev, other),
- fIsGoingToBackground(other.fIsGoingToBackground)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::~FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::~FW_CSuspendResumeEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CMenuEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev, ODEventData* theEvent, ODCommandID theCommandID, FW_Boolean propagated) :
- FW_CSystemEvent(ev, theEvent, propagated),
- fCommandID(theCommandID)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev,
- ODCommandID theCommandID,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when) :
- FW_CSystemEvent(ev, theWindow, when),
- fCommandID(theCommandID)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = kODEvtMenu;
- fEvent.message = theCommandID; // !!! this is wrong. should be menu item and id
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = kODEvtMenu;
- fEvent.wParam = theCommandID;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev, const FW_CMenuEvent& other) :
- FW_CSystemEvent(other)
- {
- fCommandID = other.GetCommandID(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::~FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::~FW_CMenuEvent()
- {
- }
-