Difference between revisions of "Mac OS X Implementing HIView"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Handlers)
(Handlers)
Line 49: Line 49:
 
OSStatus HandleHIViewEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData)
 
OSStatus HandleHIViewEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData)
 
{  
 
{  
 +
    //lock
 
     ImplSalYieldMutexAcquire();
 
     ImplSalYieldMutexAcquire();
 +
   
 +
   
 
     OSStatus status = noErr;
 
     OSStatus status = noErr;
 +
   
 +
    // we use mrContext, global and seen from everywhere
 
     CGContextRef mrContext;  
 
     CGContextRef mrContext;  
     HIRect bounds;  // 1
+
   
 +
    // create HIRect, contianing the control bounds ( in local coordinates)
 +
     HIRect bounds;   
 +
 
 
     status = GetEventParameter (inEvent,  
 
     status = GetEventParameter (inEvent,  
 
                                 kEventParamCGContextRef,  
 
                                 kEventParamCGContextRef,  
Line 60: Line 68:
 
                                 NULL,  
 
                                 NULL,  
 
                                 &mrContext);  
 
                                 &mrContext);  
      
+
 
 +
     // not used, but usefull
 
     //require_noerr(status, CantGetGraphicsContext); // 2
 
     //require_noerr(status, CantGetGraphicsContext); // 2
 +
   
 +
 
 +
    // We need to know the bounds containing the current control
 
     HIViewGetBounds ((HIViewRef) inUserData, &bounds);  
 
     HIViewGetBounds ((HIViewRef) inUserData, &bounds);  
 +
 +
    // not used, but usefull
 
     //require_noerr(status, CantGetBoundingRectangle);
 
     //require_noerr(status, CantGetBoundingRectangle);
 +
 +
    // unlock
 
     ImplSalYieldMutexRelease();
 
     ImplSalYieldMutexRelease();
 
      
 
      

Revision as of 16:08, 12 March 2007

Contributors

Eric Bachard[ericb]

Sébastien Plisson [plipli]

Introduction

This page is part of [Native Controls Implementation] and the objective is to use HIView for HIComboboxes or other HI* controls.

Current code implementation

Events

Two sorts of events are needed:

  • for objects (ClasskEventClassHIObject )  :
kEventHIObjectConstruct

kEventHIObjectInitialize

kEventHIObjectDestruct
  • for controls themselves ( Class kEventClassControl ) :
kEventControlDraw 

kEventControlInitialize

kEventControlHitTest

kEventControlGetPartRegion

kEventControlBoundsChanged

Current implementation : see vcl/aqua/aquavclevents.hxx for more informations about the syntax.

Handlers

The Handler is OSStatus type, and is used when events are detected.

e.g.  : we created HandleHIViewEvent()

using GetEventParameter, itself using the parameters described in Apple documentation.

Code sample :

OSStatus HandleHIViewEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData)
{ 
    //lock
    ImplSalYieldMutexAcquire();
    
    
    OSStatus status = noErr;
    
    // we use mrContext, global and seen from everywhere 
    CGContextRef mrContext; 
    
    // create HIRect, contianing the control bounds ( in local coordinates) 
    HIRect bounds;  

    status = GetEventParameter (inEvent, 
                                kEventParamCGContextRef, 
                                typeCGContextRef, 
                                NULL, 
                                sizeof (CGContextRef), 
                                NULL, 
                                &mrContext); 

    // not used, but usefull
    //require_noerr(status, CantGetGraphicsContext); // 2
    
   
    // We need to know the bounds containing the current control 
    HIViewGetBounds ((HIViewRef) inUserData, &bounds); 

    // not used, but usefull
    //require_noerr(status, CantGetBoundingRectangle);

    // unlock 
    ImplSalYieldMutexRelease();
    
    return status;  
} 

Controls

[FIXME]

Usefull Links

Reference

HIVIew  : [reference]

or : [same in .pdf format]

Code sample

Personal tools