Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsWindow.h File Reference
#include "nsWidgetDefs.h"
#include "nsBaseWidget.h"
#include "nsToolkit.h"
#include "nsSwitchToUIThread.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nsWindow
 Native BeOS window wrapper. More...

Defines

#define DEBUGFOCUS(what)
#define nsWindowState_ePrecreate   0x00000001
#define nsWindowState_eInCreate   0x00000002
#define nsWindowState_eLive   0x00000004
#define nsWindowState_eClosing   0x00000008
#define nsWindowState_eDoingDelete   0x00000010
#define nsWindowState_eDead   0x00000100
#define PM2NS_PARENT   NS2PM_PARENT
#define PM2NS   NS2PM
#define PMSCAN_PADMULT   0x37
#define PMSCAN_PAD7   0x47
#define PMSCAN_PAD8   0x48
#define PMSCAN_PAD9   0x49
#define PMSCAN_PADMINUS   0x4A
#define PMSCAN_PAD4   0x4B
#define PMSCAN_PAD5   0x4C
#define PMSCAN_PAD6   0x4D
#define PMSCAN_PADPLUS   0x4E
#define PMSCAN_PAD1   0x4F
#define PMSCAN_PAD2   0x50
#define PMSCAN_PAD3   0x51
#define PMSCAN_PAD0   0x52
#define PMSCAN_PADPERIOD   0x53
#define PMSCAN_PADDIV   0x5c
#define isNumPadScanCode(scanCode)
#define isNumlockOn   (BOOL)WinGetKeyState(HWND_DESKTOP, VK_NUMLOCK) & 0x0001
#define NSCANVASCLASS   "WarpzillaCanvas"

Functions

MRESULT EXPENTRY fnwpNSWindow (HWND, ULONG, MPARAM, MPARAM)
MRESULT EXPENTRY fnwpFrame (HWND, ULONG, MPARAM, MPARAM)
PRUint32 WMChar2KeyCode (MPARAM mp1, MPARAM mp2)
nsWindowNS_HWNDToWindow (HWND hwnd)

Define Documentation

#define DEBUGFOCUS (   what)

Definition at line 69 of file nsWindow.h.

#define isNumlockOn   (BOOL)WinGetKeyState(HWND_DESKTOP, VK_NUMLOCK) & 0x0001

Definition at line 384 of file nsWindow.h.

#define isNumPadScanCode (   scanCode)
Value:
!( (scanCode < PMSCAN_PAD7) ||      \
                                      (scanCode > PMSCAN_PADPERIOD) || \
                                      (scanCode == PMSCAN_PADMULT) ||  \
                                      (scanCode == PMSCAN_PADDIV) ||   \
                                      (scanCode == PMSCAN_PADMINUS) || \
                                      (scanCode == PMSCAN_PADPLUS) )

Definition at line 378 of file nsWindow.h.

#define NSCANVASCLASS   "WarpzillaCanvas"

Definition at line 390 of file nsWindow.h.

#define nsWindowState_eClosing   0x00000008

Definition at line 90 of file nsWindow.h.

#define nsWindowState_eDead   0x00000100

Definition at line 94 of file nsWindow.h.

Definition at line 92 of file nsWindow.h.

#define nsWindowState_eInCreate   0x00000002

Definition at line 86 of file nsWindow.h.

#define nsWindowState_eLive   0x00000004

Definition at line 88 of file nsWindow.h.

#define nsWindowState_ePrecreate   0x00000001

Definition at line 84 of file nsWindow.h.

#define PM2NS   NS2PM

Definition at line 360 of file nsWindow.h.

#define PM2NS_PARENT   NS2PM_PARENT

Definition at line 359 of file nsWindow.h.

#define PMSCAN_PAD0   0x52

Definition at line 374 of file nsWindow.h.

#define PMSCAN_PAD1   0x4F

Definition at line 371 of file nsWindow.h.

#define PMSCAN_PAD2   0x50

Definition at line 372 of file nsWindow.h.

#define PMSCAN_PAD3   0x51

Definition at line 373 of file nsWindow.h.

#define PMSCAN_PAD4   0x4B

Definition at line 367 of file nsWindow.h.

#define PMSCAN_PAD5   0x4C

Definition at line 368 of file nsWindow.h.

#define PMSCAN_PAD6   0x4D

Definition at line 369 of file nsWindow.h.

#define PMSCAN_PAD7   0x47

Definition at line 363 of file nsWindow.h.

#define PMSCAN_PAD8   0x48

Definition at line 364 of file nsWindow.h.

#define PMSCAN_PAD9   0x49

Definition at line 365 of file nsWindow.h.

#define PMSCAN_PADDIV   0x5c

Definition at line 376 of file nsWindow.h.

#define PMSCAN_PADMINUS   0x4A

Definition at line 366 of file nsWindow.h.

#define PMSCAN_PADMULT   0x37

Definition at line 362 of file nsWindow.h.

Definition at line 375 of file nsWindow.h.

#define PMSCAN_PADPLUS   0x4E

Definition at line 370 of file nsWindow.h.


Function Documentation

MRESULT EXPENTRY fnwpFrame ( HWND  ,
ULONG  ,
MPARAM  ,
MPARAM   
)

Definition at line 330 of file nsFrameWindow.cpp.

{
   // check to see if we have a rollup listener registered
   if (nsnull != gRollupListener && nsnull != gRollupWidget) {
      if (msg == WM_TRACKFRAME || msg == WM_MINMAXFRAME ||
          msg == WM_BUTTON1DOWN || msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) {
         // Rollup if the event is outside the popup
         if (PR_FALSE == nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) {
            gRollupListener->Rollup();

            // if we are supposed to be consuming events and it is
            // a Mouse Button down, let it go through
//            if (gRollupConsumeRollupEvent && msg != WM_BUTTON1DOWN) {
//               return FALSE;
//            }
         } 
      }
   }

   nsFrameWindow *pFrame = (nsFrameWindow*) WinQueryWindowPtr( hwnd, QWL_USER);
   return pFrame->FrameMessage( msg, mp1, mp2);
}

Here is the call graph for this function:

MRESULT EXPENTRY fnwpNSWindow ( HWND  ,
ULONG  ,
MPARAM  ,
MPARAM   
)

Definition at line 750 of file nsWindow.cpp.

{
   MRESULT popupHandlingResult;
   if( nsWindow::DealWithPopups(msg, &popupHandlingResult) )
      return popupHandlingResult;

   // Get the nsWindow for this hwnd
   nsWindow *wnd = nsWindow::GetNSWindowPtr(hwnd);

   // check to see if we have a rollup listener registered
   if( nsnull != gRollupListener && nsnull != gRollupWidget) {
      if( msg == WM_ACTIVATE || msg == WM_BUTTON1DOWN ||
          msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) {
      // Rollup if the event is outside the popup.
      PRBool rollup = !nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget);
      
      // If we're dealing with menus, we probably have submenus and we don't
      // want to rollup if the click is in a parent menu of the current submenu.
      if (rollup) {
        nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
        if ( menuRollup ) {
          nsCOMPtr<nsISupportsArray> widgetChain;
          menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) );
          if ( widgetChain ) {
            PRUint32 count = 0;
            widgetChain->Count(&count);
            for ( PRUint32 i = 0; i < count; ++i ) {
              nsCOMPtr<nsISupports> genericWidget;
              widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) );
              nsCOMPtr<nsIWidget> widget ( do_QueryInterface(genericWidget) );
              if ( widget ) {
                nsIWidget* temp = widget.get();
                if ( nsWindow::EventIsInsideWindow((nsWindow*)temp) ) {
                  rollup = PR_FALSE;
                  break;
                }
              }
            } // foreach parent menu widget
          }
        } // if rollup listener knows about menus
      }
      }
      else if( msg == WM_SETFOCUS) {
         if( !mp2 && 
             !bothFromSameWindow( ((nsWindow*)gRollupWidget)->GetMainWindow(), 
                                  (HWND)mp1) ) {
            gRollupListener->Rollup();
         }
      }
   }

   // Messages which get re-routed if their source was an nsWindow
   // (it's very bad to reroute messages whose source isn't an nsWindow,
   // listboxes with scrollbars for example would break)
   switch( msg)
   {
      case WM_CONTROL:
      case WM_HSCROLL:
      case WM_VSCROLL: // !! potential problems here if canvas children
      {
         // assume parent == owner, true for our creations
         HWND hwndChild = WinWindowFromID( hwnd, SHORT1FROMMP( mp1));
         if( hwndChild)
         {
            nsWindow *w = nsWindow::GetNSWindowPtr(hwndChild);
            if( w)
               wnd = w;
         }
         break;
      }
   }

    // hold on to the window for the life of this method, in case it gets
    // deleted during processing. yes, it's a double hack, since someWindow
    // is not really an interface.
    nsCOMPtr<nsISupports> kungFuDeathGrip;
    if (!wnd->mIsDestroying) // not if we're in the destructor!
      kungFuDeathGrip = do_QueryInterface((nsBaseWidget*)wnd);

   MRESULT mresult = 0;

   if (wnd)
   {
      if( PR_FALSE == wnd->ProcessMessage( msg, mp1, mp2, mresult) &&
          WinIsWindow( (HAB)0, hwnd) && wnd->GetPrevWP())
      {
         mresult = (wnd->GetPrevWP())( hwnd, msg, mp1, mp2);

      }
   }
   else
      /* erm */ mresult = WinDefWindowProc( hwnd, msg, mp1, mp2);

   return mresult;
}

Here is the call graph for this function:

PRUint32 WMChar2KeyCode ( MPARAM  mp1,
MPARAM  mp2 
)

Definition at line 4046 of file nsWindow.cpp.

{
  PRUint32 rc = SHORT1FROMMP(mp2);  // character code
  PRUint32 rcmask = rc & 0x00FF;    // masked character code for key up events
  USHORT sc = CHAR4FROMMP(mp1);     // scan code
  USHORT flags = SHORT1FROMMP(mp1); // flag word

  // First check for characters.
  // This is complicated by keystrokes such as Ctrl+K not having the KC_CHAR
  // bit set, but thankfully they do have the character actually there.
  //
  // Assume that `if not vkey or deadkey or valid number then char'
  if (!(flags & (KC_VIRTUALKEY | KC_DEADKEY)) ||
      (rcmask >= '0' && rcmask <= '9' &&             // handle keys on Numpad, too,
       (isNumPadScanCode(sc) ? isNumlockOn : 1)) ) { // if NumLock is on
    if (flags & KC_KEYUP) { // On OS/2 the scancode is in the upper byte of
                            // usChar when KC_KEYUP is set so mask it off
      rc = rcmask;
    } else { // not KC_KEYUP
      if (! (flags & KC_CHAR)) {
        if ((flags & KC_ALT) || (flags & KC_CTRL))
          rc = rcmask;
        else
          rc = 0;
      }
    }

    if (rc < 0xFF) {
      if (rc >= 'a' && rc <= 'z') { // The DOM_VK are for upper case only so
                                    // if rc is lower case upper case it.
        rc = rc - 'a' + NS_VK_A;
      } else if (rc >= 'A' && rc <= 'Z') { // Upper case
        rc = rc - 'A' + NS_VK_A;
      } else if (rc >= '0' && rc <= '9') {
        // Number keys, including Numpad if NumLock is not set
        rc = rc - '0' + NS_VK_0;
      } else {
        /* For some characters, map the scan code to the NS_VK value */
        /* This only happens in the char case NOT the VK case! */
        switch (sc) {
          case 0x02: rc = NS_VK_1;             break;
          case 0x03: rc = NS_VK_2;             break;
          case 0x04: rc = NS_VK_3;             break;
          case 0x05: rc = NS_VK_4;             break;
          case 0x06: rc = NS_VK_5;             break;
          case 0x07: rc = NS_VK_6;             break;
          case 0x08: rc = NS_VK_7;             break;
          case 0x09: rc = NS_VK_8;             break;
          case 0x0A: rc = NS_VK_9;             break;
          case 0x0B: rc = NS_VK_0;             break;
          case 0x0D: rc = NS_VK_EQUALS;        break;
          case 0x1A: rc = NS_VK_OPEN_BRACKET;  break;
          case 0x1B: rc = NS_VK_CLOSE_BRACKET; break;
          case 0x27: rc = NS_VK_SEMICOLON;     break;
          case 0x28: rc = NS_VK_QUOTE;         break;
          case 0x29: rc = NS_VK_BACK_QUOTE;    break;
          case 0x2B: rc = NS_VK_BACK_SLASH;    break;
          case 0x33: rc = NS_VK_COMMA;         break;
          case 0x34: rc = NS_VK_PERIOD;        break;
          case 0x35: rc = NS_VK_SLASH;         break;
          case 0x37: rc = NS_VK_MULTIPLY;      break;
          case 0x4A: rc = NS_VK_SUBTRACT;      break;
          case 0x4C: rc = NS_VK_CLEAR;         break; // numeric case is handled above
          case 0x4E: rc = NS_VK_ADD;           break;
          case 0x5C: rc = NS_VK_DIVIDE;        break;
          default: break;
        } // switch
      } // else
    } // if (rc < 0xFF)
  } else if (flags & KC_VIRTUALKEY) {
    USHORT vk = SHORT2FROMMP(mp2);
    if (flags & KC_KEYUP) { // On OS/2 there are extraneous bits in the upper byte of
                            // usChar when KC_KEYUP is set so mask them off
      rc = rcmask;
    }
    if (isNumPadScanCode(sc) &&
        (((flags & KC_ALT) && (sc != PMSCAN_PADPERIOD)) ||
          ((flags & (KC_CHAR | KC_SHIFT)) == KC_CHAR)  ||
          ((flags & KC_KEYUP) && rc != 0) )) {
      CHAR numpadMap[] = {NS_VK_NUMPAD7, NS_VK_NUMPAD8, NS_VK_NUMPAD9, 0,
                          NS_VK_NUMPAD4, NS_VK_NUMPAD5, NS_VK_NUMPAD6, 0,
                          NS_VK_NUMPAD1, NS_VK_NUMPAD2, NS_VK_NUMPAD3,
                          NS_VK_NUMPAD0, NS_VK_DECIMAL};
      // If this is the Numpad must not return VK for ALT+Numpad or ALT+NumLock+Numpad
      // NumLock+Numpad is OK
      if (numpadMap[sc - PMSCAN_PAD7] != 0) { // not plus or minus on Numpad
        if (flags & KC_ALT ) // do not react on Alt plus ASCII-code sequences
          rc = 0;
        else
          rc = numpadMap[sc - PMSCAN_PAD7];
      } else {                                // plus or minus of Numpad
        rc = 0; // No virtual key for Alt+Numpad or NumLock+Numpad
      }
    } else if (!(flags & KC_CHAR) || isNumPadScanCode(sc) ||
               (vk == VK_BACKSPACE) || (vk == VK_TAB) || (vk == VK_BACKTAB) ||
               (vk == VK_ENTER) || (vk == VK_NEWLINE) || (vk == VK_SPACE)) {
      if (vk >= VK_F1 && vk <= VK_F24)
        rc = NS_VK_F1 + (vk - VK_F1);
      else switch (vk) {
        case VK_NUMLOCK:   rc = NS_VK_NUM_LOCK;    break;
        case VK_SCRLLOCK:  rc = NS_VK_SCROLL_LOCK; break;
        case VK_ESC:       rc = NS_VK_ESCAPE;      break; // NS_VK_CANCEL
        case VK_BACKSPACE: rc = NS_VK_BACK;        break;
        case VK_TAB:       rc = NS_VK_TAB;         break;
        case VK_BACKTAB:   rc = NS_VK_TAB;         break; // layout tests for isShift
        case VK_CLEAR:     rc = NS_VK_CLEAR;       break;
        case VK_NEWLINE:   rc = NS_VK_RETURN;      break;
        case VK_ENTER:     rc = NS_VK_RETURN;      break;
        case VK_SHIFT:     rc = NS_VK_SHIFT;       break;
        case VK_CTRL:      rc = NS_VK_CONTROL;     break;
        case VK_ALT:       rc = NS_VK_ALT;         break;
        case VK_PAUSE:     rc = NS_VK_PAUSE;       break;
        case VK_CAPSLOCK:  rc = NS_VK_CAPS_LOCK;   break;
        case VK_SPACE:     rc = NS_VK_SPACE;       break;
        case VK_PAGEUP:    rc = NS_VK_PAGE_UP;     break;
        case VK_PAGEDOWN:  rc = NS_VK_PAGE_DOWN;   break;
        case VK_END:       rc = NS_VK_END;         break;
        case VK_HOME:      rc = NS_VK_HOME;        break;
        case VK_LEFT:      rc = NS_VK_LEFT;        break;
        case VK_UP:        rc = NS_VK_UP;          break;
        case VK_RIGHT:     rc = NS_VK_RIGHT;       break;
        case VK_DOWN:      rc = NS_VK_DOWN;        break;
        case VK_PRINTSCRN: rc = NS_VK_PRINTSCREEN; break;
        case VK_INSERT:    rc = NS_VK_INSERT;      break;
        case VK_DELETE:    rc = NS_VK_DELETE;      break;
      } // switch
    }
  }

  return rc;
}

Here is the caller graph for this function: