Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Quartz-2D HIView Scrolling PROBLEM 1
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Quartz-2D HIView Scrolling PROBLEM 1



Hi Folks,
 
I am porting some X11 code over to Quartz, and am having 2 issues I'd like help on.
 
Problem 1
I have created a HIView object on a regular Document window (with Compositing), and am attempting to set up scroll bars around the HIView frame, so that the I can scroll around a larger graphic (chart) displayed in the HIView frame. Everything seems to work OK for the first chart, EXCEPT that the scroll buttons do NOT appear in the scroll bar area.
 
As far as I can tell, I have followed the documentation on this, except that I have added the step to set the Frame size bigger to handle a bigger chart. The chart I am drawing with simple path constructs, and it draws perfectly at first.
 
Here is the code snippet I'm using - minus error handling:
 
    // now find the root HIView window
   HRContentRoot = HIViewGetRoot(myWindow);
   // find the HIView content window from the nib
   OSErr = HIViewFindByID(HRContentRoot,HRContentViewID,&HRContentView);
   // get the state we need - MANUAL VERSION
   layoutInfo.version = kHILayoutInfoVersionZero;
   OSErr = HIViewGetLayoutInfo(HRContentView,&layoutInfo);
   OSErr = HIViewGetFrame(HRContentView,&theRect);
   // create the scroll view MANUALLY
   OSErr = HIScrollViewCreate(kHIScrollViewOptionsVertScroll | kHIScrollViewOptionsHorizScroll,
                              &HRScrollView);
   // put the scrolls in the view's parent
   OSErr = HIViewAddSubview(HIViewGetSuperview(HRContentView),HRScrollView);
   // set the frame to match what we originally wanted
   OSErr = HIViewSetFrame(HRScrollView,&theRect);
   // set the layout to what we originally wanted
   OSErr = HIViewSetLayoutInfo(HRScrollView,&layoutInfo);
   // remove the content view from its current owner and add it into the scroll view
   OSErr = HIViewRemoveFromSuperview(HRContentView);
   OSErr = HIViewAddSubview(HRScrollView,HRContentView);
 
   // Note - this code DOES correctly set the bounds of the embedded HIView. This can
   // be detected by checking the bounds of the event contexts.
   theRect.origin.x = 0.0
   theRect.origin.y = 0.0
   theRect.size.width = BITMAPWIDTH+1
   theRect.size.height = BITMAPHEIGHT+1
   OSErr = HIViewSetFrame(HRContentView,&theRect); 
    // request an update or the screen remains blank
   HIViewSetVisible(HRScrollView,true);
   HIViewSetNeedsDisplay(HRContentView,true);
   // now add an event handler to handle drawing into this window
   OSErr = InstallEventHandler(GetControlEventTarget(HRContentView),
                               NewEventHandlerUPP(myDrawEventHandler),
                               GetEventTypeCount(HRContentEvents),
                               HRContentEvents,
                               (void *)HRContentView,
                               NULL );
   // now add an event handler to handle scrolling
   OSErr = InstallEventHandler(GetControlEventTarget(HRScrollView),
                               NewEventHandlerUPP(myScrollEventHandler),
                               GetEventTypeCount(HRScrollEvents),
                               HRScrollEvents,
                               (void *)HRScrollView,
                               NULL );
   // Now we've changed the size of the content window, we need to send a kEventScrollableInfoChanged event
   // to the scroll bars. We'll do that after we've installed the event handler.
   HIViewRef parentView = HIViewGetSuperview(HRContentView);
   if(parentView)
   {
      EventRef theEvent;
      OSErr = CreateEvent(NULL,kEventClassScrollable,kEventScrollableInfoChanged,GetCurrentEventTime(),
                        kEventAttributeUserEvent,&theEvent); 
      OSErr = SendEventToEventTarget(theEvent,GetControlEventTarget(parentView));
      ReleaseEvent(theEvent);
   }
Many thanks,
 
Greg
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.