Go to the FreeLists Home Page Home Signup Help Login
 



[open-beos-printing] || [Date Prev] [04-2002 Date Index] [Date Next] || [Thread Prev] [04-2002 Thread Index] [Thread Next]

[open-beos-printing] Re: Further PDF Writer Progress

  • From: "Simon Gauvin" <gauvins@xxxxxxxxx>
  • To: open-beos-printing@xxxxxxxxxxxxx
  • Date: Thu, 04 Apr 2002 09:12:40 EST (-0500)
> 
> >void DocInfoText::KeyDown(const char *bytes, int32 numBytes)
> >{
> 
> What if DocInfoText does not handle tab, shift tab, ctrl tab, ... 
> itself
> but calls KeyDown of the parent class BView instead=3F
 
Michael,

Yes, you can do that, and the navigation behavior in the BView will do 
everything for you, except make the new focus item visible. This you 
have to do yourself but the right place is not within the control that 
just got the focus shift, but rather inside the BView that has all the 
children and the scroll bar as a parent. 

This means creating another View subclass that has this logic. But 
rather than messing around with new BView types and having the 
DocInfoText control know about this new BView we use BMessages and send 
a notification to the new View. Here is what I mean:

1)  pass the target view into the constructor of the DocInfoText

        new DocInfoText( fTable, ... )

2) then in the KeyDown() we send the message to the target View.

        void DocInfoText::KeyDown(const char *bytes, int32 numBytes)
        {
            // test for tab
            if (bytes[0] =3D=3D '\t')
            {
                        // move the focus               
                        target->KeyDown(bytes, numBytes);
                        
                        // send the message
                        BMessage *msg =3D new BMessage('tab=5F');
                        Window()->PostMessage(msg, target);
            }
        }

3) THen the new view handles the message 

        void ActiveView::MessageReceived(BMessage *msg)
        {
            switch (msg->what){
                case TAB=5FMSG:
                    ShowItem();
                    break;
            }
        }

4) Move the view to show the item:

        void ActiveView::ShowItem()
        {
            BRegion region;
            BRect r;
            BScrollView *sv;
            BView *child;
        
            child =3D Window()->CurrentFocus();
            if (child =3D=3D NULL) return;
        
            sv =3D dynamic=5Fcast<BScrollView*>(Parent());
            sv->GetClippingRegion(&region);
            r =3D region.Frame();
            if (!r.IsValid())
                return;
        
            if (!r.Contains(child->Frame().LeftTop()) && FindView(child->
Name()))
            {
                BScrollBar *sb;
                sb =3D sv->ScrollBar(B=5FVERTICAL);
                sb->SetValue(sb->Value() + child->Frame().top);
            }
        }

If you want the code I used to test this theory I can send it to you.

Cheers :)

        Simon







[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.