Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsViewBeOS Class Reference

#include <nsWindow.h>

Inheritance diagram for nsViewBeOS:
Inheritance graph
[legend]
Collaboration diagram for nsViewBeOS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsViewBeOS (nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, uint32 aResizingMode, uint32 aFlags)
virtual void Draw (BRect updateRect)
virtual void MouseDown (BPoint point)
virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *message)
virtual void MouseUp (BPoint point)
bool GetPaintRegion (BRegion *breg)
void Validate (BRegion *reg)
BPoint GetWheel ()
void KeyDown (const char *bytes, int32 numBytes)
void KeyUp (const char *bytes, int32 numBytes)
virtual void MakeFocus (bool focused)
virtual void MessageReceived (BMessage *msg)
void SetVisible (bool visible)
bool Visible ()
virtual nsIWidgetGetMozillaWidget (void)

Public Attributes

BRegion paintregion
uint32 buttons

Private Member Functions

void DoIME (BMessage *msg)

Private Attributes

BPoint mousePos
uint32 mouseMask
BPoint wheel
bool fRestoreMouseMask
bool fJustValidated
bool fWheelDispatched
bool fVisible

Detailed Description

Definition at line 288 of file nsWindow.h.


Constructor & Destructor Documentation

nsViewBeOS::nsViewBeOS ( nsIWidget aWidgetWindow,
BRect  aFrame,
const char *  aName,
uint32  aResizingMode,
uint32  aFlags 
)

Definition at line 3002 of file nsWindow.cpp.

       : BView(aFrame, aName, aResizingMode, aFlags), nsIWidgetStore(aWidgetWindow), wheel(.0,.0)
{
       SetViewColor(B_TRANSPARENT_COLOR);
       paintregion.MakeEmpty();    
       buttons = 0;
       fRestoreMouseMask = false;
       fJustValidated = true;
       fWheelDispatched = true;
       fVisible = true;
}

Member Function Documentation

void nsViewBeOS::DoIME ( BMessage *  msg) [private]

Definition at line 3409 of file nsWindow.cpp.

{
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       nsToolkit     *t;
 
       if(w && (t = w->GetToolkit()) != 0) 
       {
              ssize_t size = msg->FlattenedSize();
              int32         argc = (size+3)/4;
              uint32 *args = new uint32[argc];
              if (args) 
              {
                     msg->Flatten((char*)args, size);
                     MethodInfo *info = new MethodInfo(w, w, nsSwitchToUIThread::ONIME, argc, args);
                     if (info) 
                     {
                            t->CallMethodAsync(info);
                            NS_RELEASE(t);
                     }
                     delete[] args;
              }      
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewBeOS::Draw ( BRect  updateRect) [virtual]

Definition at line 3028 of file nsWindow.cpp.

{
       // Ignore all, we are scrolling.
       if (!fVisible)
              return;

       paintregion.Include(updateRect);

       // We have send message already, and Mozilla still didn't get it
       // so don't poke it endlessly with no reason. Also don't send message
       // if update region is empty.
       if (paintregion.CountRects() == 0 || !paintregion.Frame().IsValid() || !fJustValidated)
              return;
       uint32 args[1];
       args[0] = (uint32)this;
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       nsToolkit     *t;
       if (w && (t = w->GetToolkit()) != 0)
       {
              MethodInfo *info = nsnull;
              info = new MethodInfo(w, w, nsSwitchToUIThread::ONPAINT, 1, args);
              if (info)
              {
                     t->CallMethodAsync(info);
                     //Memorize fact of sending message
                     fJustValidated = false;
              }
              NS_RELEASE(t);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIWidget * nsIWidgetStore::GetMozillaWidget ( void  ) [virtual, inherited]

Definition at line 2838 of file nsWindow.cpp.

{
       return mWidget;
}

Here is the caller graph for this function:

bool nsViewBeOS::GetPaintRegion ( BRegion *  breg)

Definition at line 3060 of file nsWindow.cpp.

{

       // Mozilla got previous ONPAINT message,
       // ready for next event.
       fJustValidated = true;
       if (paintregion.CountRects() == 0)
              return false;
       r->Include(&paintregion);
       return true;
}

Here is the caller graph for this function:

Definition at line 3078 of file nsWindow.cpp.

{
       BPoint retvalue = wheel;
       // Mozilla got wheel event, so setting flag and cleaning delta storage
       fWheelDispatched = true;
       wheel.x = 0;
       wheel.y = 0;
       return retvalue;
}
void nsViewBeOS::KeyDown ( const char *  bytes,
int32  numBytes 
)

Definition at line 3315 of file nsWindow.cpp.

{
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       nsToolkit     *t;
       int32 keycode = 0;
       int32 rawcode = 0;

       BMessage *msg = this->Window()->CurrentMessage();
       if (msg) {
              msg->FindInt32("key", &keycode);
              msg->FindInt32("raw_char", &rawcode);
       }

       if (w && (t = w->GetToolkit()) != 0) {
              uint32 bytebuf = 0;
              uint8 *byteptr = (uint8 *)&bytebuf;
              for(int32 i = 0; i < numBytes; i++)
                     byteptr[i] = bytes[i];

              uint32 args[6];
              args[0] = NS_KEY_DOWN;
              args[1] = bytebuf;
              args[2] = numBytes;
              args[3] = modifiers();
              args[4] = keycode;
              args[5] = rawcode;
              MethodInfo *info = nsnull;
              if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONKEY, 6, args)))
                     t->CallMethodAsync(info);
              NS_RELEASE(t);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewBeOS::KeyUp ( const char *  bytes,
int32  numBytes 
)

Definition at line 3348 of file nsWindow.cpp.

{
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       nsToolkit     *t;
       int32 keycode = 0;
       int32 rawcode = 0;
       BMessage *msg = this->Window()->CurrentMessage();
       if (msg) {
              msg->FindInt32("key", &keycode);
              msg->FindInt32("raw_char", &rawcode);
       }

       if (w && (t = w->GetToolkit()) != 0) {
              uint32 bytebuf = 0;
              uint8 *byteptr = (uint8 *)&bytebuf;
              for(int32 i = 0; i < numBytes; i++)
                     byteptr[i] = bytes[i];

              uint32 args[6];
              args[0] = NS_KEY_UP;
              args[1] = (int32)bytebuf;
              args[2] = numBytes;
              args[3] = modifiers();
              args[4] = keycode;
              args[5] = rawcode;
              MethodInfo *info = nsnull;
              if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONKEY, 6, args)))
                     t->CallMethodAsync(info);
              NS_RELEASE(t);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewBeOS::MakeFocus ( bool  focused) [virtual]

Definition at line 3380 of file nsWindow.cpp.

{
       if (!IsFocus() && focused)
              BView::MakeFocus(focused);
       uint32 args[1];
       args[0] = (uint32)this;
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       nsToolkit     *t;
       if (w && (t = w->GetToolkit()) != 0)
       {
              MethodInfo *info = nsnull;
              if (!focused)
              {
                     if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::KILL_FOCUS,1,args)))
                            t->CallMethodAsync(info);
              }
#ifdef DEBUG_FOCUS
              else
              {
                     if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::GOT_FOCUS,1,args)))
                            t->CallMethodAsync(info);
              }
#endif        
              NS_RELEASE(t);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewBeOS::MessageReceived ( BMessage *  msg) [virtual]

Definition at line 3222 of file nsWindow.cpp.

{
       if(msg->WasDropped())
       {
              nsWindow      *w = (nsWindow *)GetMozillaWidget();
              if (w == NULL)
                     return;
              nsToolkit     *t = t = w->GetToolkit();
              if (t == NULL)
                     return;

              uint32 args[4];
              args[0] = NS_DRAGDROP_DROP;

              //Drop point is in screen-cordinates
              BPoint aPoint = ConvertFromScreen(msg->DropPoint()); 
       
              args[1] = (uint32) aPoint.x;
              args[2] = (uint32) aPoint.y;
              args[3] = modifiers();

              MethodInfo *info = new MethodInfo(w, w, nsSwitchToUIThread::ONDROP, 4, args);
              t->CallMethodAsync(info);
              BView::MessageReceived(msg);
              return;
       }

       switch(msg->what)
       {
       //Native drag'n'drop negotiation
       case B_COPY_TARGET:
       case B_MOVE_TARGET:
       case B_LINK_TARGET:
       case B_TRASH_TARGET:
              {
                     nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
                     nsCOMPtr<nsIDragSessionBeOS> dragSessionBeOS = do_QueryInterface(dragService);
                     dragSessionBeOS->TransmitData(new BMessage(*msg));
              }
              break;
       case B_UNMAPPED_KEY_DOWN:
              //printf("unmapped_key_down\n");
              KeyDown(NULL, 0);
              break;

       case B_UNMAPPED_KEY_UP:
              //printf("unmapped_key_up\n");
              KeyUp(NULL, 0);
              break;

       case B_MOUSE_WHEEL_CHANGED:
              {
                     float wheel_y;
                     float wheel_x;

                     msg->FindFloat ("be:wheel_delta_y", &wheel_y);
                     msg->FindFloat ("be:wheel_delta_x", &wheel_x);
                     wheel.x += wheel_x;
                     wheel.y += wheel_y;

                     if(!fWheelDispatched || (nscoord(wheel_x) == 0 && nscoord(wheel_y) == 0))
                            return;
                     uint32 args[1];
                     args[0] = (uint32)this;
                     nsWindow    *w = (nsWindow *)GetMozillaWidget();
                     nsToolkit   *t;

                     if (w && (t = w->GetToolkit()) != 0)
                     {
                                   
                            MethodInfo *info = nsnull;
                            if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONWHEEL, 1, args)))
                            {
                                   t->CallMethodAsync(info);
                                   fWheelDispatched = false;
                                   
                            }
                            NS_RELEASE(t);
                     }
              }
              break;
              
#if defined(BeIME)
       case B_INPUT_METHOD_EVENT:
              DoIME(msg);
              break;
#endif
       default :
              BView::MessageReceived(msg);
              break;
       }
}

Here is the call graph for this function:

void nsViewBeOS::MouseDown ( BPoint  point) [virtual]

Definition at line 3088 of file nsWindow.cpp.

{
       if (!fRestoreMouseMask)
              mouseMask = SetMouseEventMask(B_POINTER_EVENTS);
       fRestoreMouseMask = true;

       //To avoid generating extra mouseevents when there is no change in pos.
       mousePos = point;

       uint32 clicks = 0;
       BMessage *msg = Window()->CurrentMessage();
       msg->FindInt32("buttons", (int32 *) &buttons);
       msg->FindInt32("clicks", (int32 *) &clicks);

       if (0 == buttons)
              return;

       nsWindow *w = (nsWindow *)GetMozillaWidget();
       if (w == NULL)
              return;
              
       nsToolkit     *t = w->GetToolkit();
       if (t == NULL)
              return;

       int32 ev = (buttons & B_PRIMARY_MOUSE_BUTTON) ? NS_MOUSE_LEFT_BUTTON_DOWN :
                  ((buttons & B_SECONDARY_MOUSE_BUTTON) ? NS_MOUSE_RIGHT_BUTTON_DOWN :
                   NS_MOUSE_MIDDLE_BUTTON_DOWN);
       uint32 args[5];
       args[0] = ev;
       args[1] = (uint32) point.x;
       args[2] = (uint32) point.y;
       args[3] = clicks;
       args[4] = modifiers();
       MethodInfo *info = nsnull;
       if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::BTNCLICK, 5, args)))
              t->CallMethodAsync(info);
       NS_RELEASE(t);
}

Here is the call graph for this function:

void nsViewBeOS::MouseMoved ( BPoint  point,
uint32  transit,
const BMessage *  message 
) [virtual]

Definition at line 3128 of file nsWindow.cpp.

{
       //To avoid generating extra mouseevents when there is no change in pos.
       //and not entering exiting view.
       if (mousePos == point && (transit == B_INSIDE_VIEW || transit == B_OUTSIDE_VIEW))
              return;

       mousePos = point;

       //We didn't start the mouse down and there is no drag in progress, so ignore.
       if (NULL == msg && !fRestoreMouseMask && buttons)
              return;
              
       nsWindow      *w = (nsWindow *)GetMozillaWidget();
       if (w == NULL)
              return;
       nsToolkit     *t = t = w->GetToolkit();
       if (t == NULL)
              return;

       uint32 args[1];
/*     args[1] = (int32) point.x;
       args[2] = (int32) point.y;
       args[3] = modifiers();*/

       switch (transit)
       {
       case B_ENTERED_VIEW:
              {
                     args[0] = NULL != msg ? NS_DRAGDROP_ENTER : NS_MOUSE_ENTER;
                     if (msg == NULL)
                            break;
                     nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
                     dragService->StartDragSession();
                     //As it may have come from the outside we need to update this.
                     nsCOMPtr<nsIDragSessionBeOS> dragSessionBeOS = do_QueryInterface(dragService);
                     dragSessionBeOS->UpdateDragMessageIfNeeded(new BMessage(*msg));
              }
              break;
       case B_EXITED_VIEW:
              {
                     args[0] = NULL != msg ? NS_DRAGDROP_EXIT : NS_MOUSE_EXIT;
                     if (msg == NULL)
                            break;
                     nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
                     dragService->EndDragSession();
              }
              break;
       default:
              args[0]= msg == NULL ? NS_MOUSE_MOVE : NS_DRAGDROP_OVER;
       }
       
       MethodInfo *moveInfo = nsnull;
       if (nsnull != (moveInfo = new MethodInfo(w, w, nsSwitchToUIThread::ONMOUSE, 1, args)))
              t->CallMethodAsync(moveInfo);
       NS_RELEASE(t);
}

Here is the call graph for this function:

void nsViewBeOS::MouseUp ( BPoint  point) [virtual]

Definition at line 3186 of file nsWindow.cpp.

{
       if (fRestoreMouseMask) 
       {
              SetMouseEventMask(mouseMask);
              fRestoreMouseMask = false;
       }

       //To avoid generating extra mouseevents when there is no change in pos.
       mousePos = point;

       int32 ev = (buttons & B_PRIMARY_MOUSE_BUTTON) ? NS_MOUSE_LEFT_BUTTON_UP :
                  ((buttons & B_SECONDARY_MOUSE_BUTTON) ? NS_MOUSE_RIGHT_BUTTON_UP :
                   NS_MOUSE_MIDDLE_BUTTON_UP);
                   
       buttons = 0;
              
       nsWindow *w = (nsWindow *)GetMozillaWidget();
       if (w == NULL)
              return;
       nsToolkit     *t = t = w->GetToolkit();
       if (t == NULL)
              return;

       uint32 args[5];
       args[0] = ev;
       args[1] = (uint32) point.x;
       args[2] = (int32) point.y;
       args[3] = 0;
       args[4] = modifiers();
       MethodInfo *info = nsnull;
       if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::BTNCLICK, 5, args)))
              t->CallMethodAsync(info);
       NS_RELEASE(t);
}

Here is the call graph for this function:

Definition at line 3014 of file nsWindow.cpp.

{
       if (visible) 
              SetFlags(Flags() | B_WILL_DRAW);
       else
              SetFlags(Flags() & ~B_WILL_DRAW);
       fVisible = visible;
}

Here is the caller graph for this function:

void nsViewBeOS::Validate ( BRegion *  reg)

Definition at line 3073 of file nsWindow.cpp.

{
       paintregion.Exclude(reg);
}

Here is the caller graph for this function:

bool nsViewBeOS::Visible ( ) [inline]

Definition at line 3023 of file nsWindow.cpp.

{
       return fVisible;
}

Member Data Documentation

Definition at line 313 of file nsWindow.h.

Definition at line 324 of file nsWindow.h.

Definition at line 323 of file nsWindow.h.

Definition at line 326 of file nsWindow.h.

Definition at line 325 of file nsWindow.h.

Definition at line 320 of file nsWindow.h.

BPoint nsViewBeOS::mousePos [private]

Definition at line 319 of file nsWindow.h.

Definition at line 312 of file nsWindow.h.

BPoint nsViewBeOS::wheel [private]

Definition at line 322 of file nsWindow.h.


The documentation for this class was generated from the following files: