home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / liblayer / include / layers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  24.5 KB  |  582 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.  *  layers.h - Compositing and layer related definitions and prototypes
  20.  */
  21.  
  22.  
  23. #ifndef _LAYERS_H_
  24. #define _LAYERS_H_
  25.  
  26. #include "prtypes.h"
  27. #include "fe_rgn.h"
  28. #include "xp_rect.h"
  29. #include "cl_types.h"
  30.  
  31.  
  32. /******************Definitions and Types************/
  33.  
  34.  
  35. /* Maximum and minimum permitted values for coordinates for layer 
  36.    positions and bbox's.  
  37.    Note: We don't use the extrema values of 32-bit integers.
  38.    Instead, we deliberately leave headroom to avoid overflow of the
  39.    coordinates as a result of translating the rect.  */
  40. #define CL_MAX_COORD    ( 0x3fffffffL)
  41. #define CL_MIN_COORD    (-0x40000000L)
  42. #define CL_MAX_RECT {CL_MIN_COORD, CL_MIN_COORD, CL_MAX_COORD, CL_MAX_COORD}
  43.  
  44.  
  45. typedef struct CL_Color 
  46. {
  47.     uint8 red, green, blue;
  48. } CL_Color;
  49.     
  50. typedef enum CL_LayerPosition { 
  51.     CL_ABOVE,
  52.     CL_BELOW
  53. } CL_LayerPosition;
  54.  
  55.  
  56. /* A function that repaints a given region in a specified drawable.   */
  57. /* The region returned defines the area actually drawn. If this       */
  58. /* area is a complex region (it cannot be defined by the FE_Region    */
  59. /* primitive) and allow_transparency is FALSE (we are in the front-   */
  60. /* to-back phase of the compositor loop), this should return NULL.    */
  61. /* In this case, the painter function will be called again during     */
  62. /* the back-to-front phase.                                           */
  63. /* The update_region is specified in window coordinates. The layer    */
  64. /* is responsible for translating this into its own coordinate system */
  65. /* The region passed back must also be in the window coordinate sys.  */
  66. typedef void (*CL_PainterFunc)(CL_Drawable *drawable, 
  67.                                CL_Layer *layer, 
  68.                                FE_Region update_region);
  69.  
  70. /* 
  71.  * The painter_func returns a region that represents the area drawn.
  72.  * This function is called after the compositor uses the region.
  73.  */
  74. typedef void (*CL_RegionCleanupFunc)(CL_Layer *layer,
  75.                                      FE_Region drawn_region);
  76.  
  77. /* A function that handles events that relate directly to the layer */
  78. /* A return value of TRUE indicates that the layer has accepted and */
  79. /* dealt with the event. FALSE indicates that the event should be   */
  80. /* passed down to the next layer.                                   */
  81. typedef PRBool (*CL_EventHandlerFunc)(CL_Layer *layer,
  82.                                       CL_Event *event);
  83.  
  84. /* Function that's called when the layer is destroyed */
  85. typedef void (*CL_DestroyFunc)(CL_Layer *layer);
  86.  
  87. /* Function that's called to retrieve user-defined data from layer */
  88. typedef void *(*CL_GetClientDataFunc)(CL_Layer *layer);
  89.  
  90. /* Function that's called to set user-defined data for a layer */
  91. typedef void (*CL_SetClientDataFunc)(CL_Layer *layer, void *client_data);
  92.  
  93. /* Function that's called when a layer is moved */
  94. typedef void (*CL_PositionChangedFunc)(CL_Layer *layer, 
  95.                                        int32 x_offset, int32 y_offset);
  96.  
  97. /* Function that's called when a layer's hidden state changes */
  98. typedef void (*CL_VisibilityChangedFunc)(CL_Layer *layer, PRBool visible);
  99.  
  100. /* Function that's called when a layer's bounding box changes */
  101. typedef void (*CL_BboxChangedFunc)(CL_Layer *layer, XP_Rect *new_bbox);
  102.  
  103. /* 
  104.  * A C++-like vtable. These are virtual methods that CL_Layer
  105.  * sub-classes should override. I never thought I'd say this,
  106.  * but...I'd rather be using C++.
  107.  */
  108. typedef struct CL_LayerVTable 
  109. {
  110.     CL_PainterFunc painter_func; 
  111.     CL_RegionCleanupFunc region_cleanup_func; 
  112.     CL_EventHandlerFunc event_handler_func; 
  113.     CL_DestroyFunc destroy_func;
  114.     CL_GetClientDataFunc get_client_data_func;
  115.     CL_SetClientDataFunc set_client_data_func;
  116.     CL_PositionChangedFunc position_changed_func;
  117.     CL_VisibilityChangedFunc visibility_changed_func;
  118.     CL_BboxChangedFunc bbox_changed_func;
  119. } CL_LayerVTable;
  120.  
  121. /* Function called by CL_ForEachLayerInGroup() */
  122. typedef PRBool (*CL_LayerInGroupFunc)(CL_Layer *layer, void *closure);
  123.  
  124. /* Function called by CL_ForEachChildOfLayer() */
  125. typedef PRBool (*CL_ChildOfLayerFunc)(CL_Layer *layer, void *closure);
  126.  
  127. typedef enum 
  128. {
  129.     CL_EVENT_MOUSE_BUTTON_DOWN,
  130.     CL_EVENT_MOUSE_BUTTON_UP,
  131.     CL_EVENT_MOUSE_BUTTON_MULTI_CLICK,
  132.     CL_EVENT_MOUSE_MOVE,
  133.     CL_EVENT_KEY_DOWN,
  134.     CL_EVENT_KEY_UP,
  135.     CL_EVENT_MOUSE_ENTER,
  136.     CL_EVENT_MOUSE_LEAVE,
  137.     CL_EVENT_KEY_FOCUS_GAINED,
  138.     CL_EVENT_KEY_FOCUS_LOST
  139. } CL_EventType;
  140.    
  141. typedef enum
  142. {
  143.     CL_FOCUS_POLICY_CLICK, /* Layer gets keyboard focus when you click in it */
  144.     CL_FOCUS_POLICY_MOUSE_ENTER /* ...when you the mouse enters its bounds */
  145. } CL_KeyboardFocusPolicy;
  146.  
  147. /* 
  148.  * A generic event struct. I took the Mac toolbox model of having
  149.  * a single event structure encode all types of events. If we had
  150.  * more events (and this could happen in the near future), I'd go
  151.  * with the X model of having event-specific structures and a 
  152.  * union of them that's passed around.
  153.  */
  154. struct CL_Event {
  155.     CL_EventType type;   /* What type of event is this */
  156.     void *fe_event;      /* FE-specific event information */
  157.     int32 fe_event_size; /* Size of FE-specific event info */
  158.     int32 x, y;          /* The current position of the pointer */
  159.     uint32 which;        /* For mouse events: which button is down
  160.                             0 = none, 1 onwards starts from the left.
  161.                             For key events: code for the key pressed */
  162.     uint32 modifiers;    /* Modifiers currently in place e.g. shift key */
  163.     uint32 data;         /* Other event specific information.
  164.                             For multi-click events: the number of clicks */
  165. };
  166.  
  167. #define CL_IS_MOUSE_EVENT(evnt)                                \
  168.        (((evnt)->type == CL_EVENT_MOUSE_BUTTON_DOWN) ||        \
  169.         ((evnt)->type == CL_EVENT_MOUSE_BUTTON_MULTI_CLICK) || \
  170.         ((evnt)->type == CL_EVENT_MOUSE_BUTTON_UP) ||          \
  171.         ((evnt)->type == CL_EVENT_MOUSE_MOVE))
  172.  
  173. #define CL_IS_KEY_EVENT(evnt) \
  174.        (((evnt)->type == CL_EVENT_KEY_DOWN) ||  \
  175.         ((evnt)->type == CL_EVENT_KEY_UP))
  176.  
  177. #define CL_IS_FOCUS_EVENT(evnt) \
  178.        (((evnt)->type == CL_EVENT_MOUSE_ENTER) ||  \
  179.         ((evnt)->type == CL_EVENT_MOUSE_LEAVE) ||  \
  180.         ((evnt)->type == CL_EVENT_KEY_FOCUS_GAINED) || \
  181.         ((evnt)->type == CL_EVENT_KEY_FOCUS_LOST))
  182.  
  183. typedef enum CL_DrawableState {
  184.     CL_UNLOCK_DRAWABLE                   = 0x00,
  185.     CL_LOCK_DRAWABLE_FOR_READ            = 0x01,
  186.     CL_LOCK_DRAWABLE_FOR_WRITE           = 0x02,
  187.     CL_LOCK_DRAWABLE_FOR_READ_WRITE      = 0x03
  188. } CL_DrawableState;
  189.  
  190. /* Function that's called to insure that a drawable used as a backing
  191.    store can still be accessed and check that it has not been altered
  192.    since the last time the drawable was unlocked.  This functions
  193.    permits a compositor client to purge its backing store when unlocked. */
  194. typedef PRBool (*CL_LockDrawableFunc)(CL_Drawable *drawable,
  195.                                       CL_DrawableState state);
  196. /* Function that's called when the drawable is destroyed */
  197. typedef void (*CL_DestroyDrawableFunc)(CL_Drawable *drawable);
  198.  
  199. /* Function that's called to indicate that the drawable will be used.
  200.  * No other drawable calls will be made until we InitDrawable. */
  201. typedef void (*CL_InitDrawableFunc)(CL_Drawable *drawable);
  202.  
  203. /* Function that's called to indicate that we're temporarily done with
  204.  * the drawable. The drawable won't be used until we call InitDrawable
  205.  * again. */
  206. typedef void (*CL_RelinquishDrawableFunc)(CL_Drawable *drawable);
  207.  
  208. /* Function that's called to set coordinate origin of a drawable */
  209. typedef void (*CL_SetDrawableOriginFunc)(CL_Drawable *drawable,
  210.                                          int32 x_offset, int32 y_offset);
  211.  
  212. typedef void (*CL_GetDrawableOriginFunc)(CL_Drawable *drawable,
  213.                                          int32 *x_offset, int32 *y_offset);
  214.  
  215. /* Function that's called to set drawing clip region for a drawable */
  216. typedef void (*CL_SetDrawableClipFunc)(CL_Drawable *drawable,
  217.                                        FE_Region clip_region);
  218.  
  219. /* Function that's called to to restore drawing clip region to prior value */
  220. typedef void (*CL_RestoreDrawableClipFunc)(CL_Drawable *drawable);
  221.  
  222. /* BLIT from one drawable to another */
  223. typedef void (*CL_CopyPixelsFunc)(CL_Drawable *drawable_src, 
  224.                                   CL_Drawable *drawable_dest,
  225.                                   FE_Region region);
  226.  
  227. /* Function that's called to set drawing clip region for a drawable */
  228. typedef void (*CL_SetDrawableDimensionsFunc)(CL_Drawable *drawable,
  229.                                              uint32 width, uint32 height);
  230.  
  231. /* 
  232.  * A C++-like vtable. These are virtual methods that CL_Layer
  233.  * sub-classes should override.
  234.  */
  235. typedef struct CL_DrawableVTable
  236. {
  237.     CL_LockDrawableFunc           lock_func;
  238.     CL_InitDrawableFunc           init_func;
  239.     CL_RelinquishDrawableFunc     relinquish_func;
  240.     CL_DestroyDrawableFunc        destroy_func; 
  241.     CL_SetDrawableOriginFunc      set_origin_func;
  242.     CL_GetDrawableOriginFunc      get_origin_func;
  243.     CL_SetDrawableClipFunc        set_clip_func;
  244.     CL_RestoreDrawableClipFunc    restore_clip_func;
  245.     CL_CopyPixelsFunc             copy_pixels_func;
  246.     CL_SetDrawableDimensionsFunc  set_dimensions_func;
  247. } CL_DrawableVTable;
  248.  
  249. /* Bitmask for CL_CompositorTarget flags */
  250. #define CL_WINDOW           (0x00)
  251. #define CL_OFFSCREEN        (0x01)
  252. #define CL_BACKING_STORE    (0x02)
  253. #define CL_PRINTER          (0x03)    
  254.  
  255. typedef enum
  256. {
  257.     CL_DRAWING_METHOD_HYBRID,  /* Combination of f-t-b and b-t-f */
  258.     CL_DRAWING_METHOD_BACK_TO_FRONT_ONLY /* Back-to-front drawing only */
  259. } CL_DrawingMethod;
  260.  
  261. /*******************Prototypes**********************/
  262.  
  263. XP_BEGIN_PROTOS
  264.  
  265. /***************** LAYER METHODS *****************/
  266.  
  267. /* Values for flags argument to CL_NewLayer(), CL_SetFlags(), etc. */
  268. #define CL_NO_FLAGS                    0x0000
  269. #define CL_HIDDEN                      0x0001 /* Don't draw layer & children */
  270. #define CL_PREFER_DRAW_ONSCREEN        0x0002 /* Prefer not to use backing store */
  271. #define CL_PREFER_DRAW_OFFSCREEN       0x0004 /* Draw directly to pixmap ? */
  272. #define CL_DONT_SCROLL_WITH_DOCUMENT   0x0008 /* Should this layer not scroll ? */
  273. #define CL_CLIP_CHILD_LAYERS           0x0010 /* Clip drawing of descendents */
  274. #define CL_DONT_CLIP_SELF              0x0020 /* Clip drawing of this layer ? */
  275. #define CL_DONT_ENUMERATE              0x0040 /* Don't reflect into JavaScript*/
  276. #define CL_OPAQUE                      0x0080 /* Layer has no transparency */
  277. #define CL_CUTOUT                      0x0100 /* A layer drawn by somebody else */
  278. #define CL_OVERRIDE_INHERIT_VISIBILITY 0x0200 /* Child visibility is independent
  279.                                                  of parent's */
  280.  
  281. /* Allocate and free a layer */
  282. extern CL_Layer *CL_NewLayer(char *name, int32 x_offset, int32 y_offset,
  283.                              XP_Rect *bbox, 
  284.                              CL_LayerVTable *vtable,
  285.                              uint32 flags, void *client_data);
  286.  
  287. extern uint32 CL_GetLayerFlags(CL_Layer *layer);
  288. extern PRBool CL_ChangeLayerFlag(CL_Layer *layer, uint32 flag, PRBool value);
  289.  
  290. extern void CL_DestroyLayer(CL_Layer *layer);
  291.  
  292. /* Frees an entire sub-tree, rooted at the specified node */
  293. extern void CL_DestroyLayerTree(CL_Layer *root);
  294.  
  295. /* Insert a layer into the layer tree as a child of the parent layer.
  296.  * If sibling is NULL, the layer is added as the topmost (in z-order) child 
  297.  * if where==CL_ABOVE or the bottommost child if where==CL_BELOW.
  298.  * If sibling is non-NULL, the layer is added above or below (in z-order)
  299.  * sibling based on the value of where.
  300.  */ 
  301. extern void CL_InsertChild(CL_Layer *parent, CL_Layer *child, 
  302.                            CL_Layer *sibling, CL_LayerPosition where);
  303.  
  304. /*
  305.  * Alternate function for inserting a layer based on its relative z-order.
  306.  */
  307. extern void CL_InsertChildByZ(CL_Layer *parent, CL_Layer *child, int32 z_order);
  308.  
  309. /* Removes a layer from a parent's sub-tree */
  310. extern void CL_RemoveChild(CL_Layer *parent, CL_Layer *child);
  311.  
  312. /* Call the function for each child layer of the layer */
  313. extern PRBool CL_ForEachChildOfLayer(CL_Layer *parent, 
  314.                                      CL_ChildOfLayerFunc func,
  315.                                      void *closure);
  316.  
  317. extern int32 CL_GetLayerZIndex(CL_Layer *layer);
  318.  
  319. /* Change the physical position or dimensions of a layer */
  320. /* May trigger asynchronous drawing to update screen     */
  321. extern void CL_OffsetLayer(CL_Layer *layer, int32 x_offset, int32 y_offset);
  322. extern void CL_MoveLayer(CL_Layer *layer, int32 x, int32 y);
  323. extern void CL_ResizeLayer(CL_Layer *layer, int32 width, int32 height);
  324.  
  325. /* Setters and getters */
  326. extern void CL_GetLayerBbox(CL_Layer *layer, XP_Rect *bbox);
  327. extern void CL_SetLayerBbox(CL_Layer *layer, XP_Rect *bbox);
  328. extern void CL_GetLayerBboxAbsolute(CL_Layer *layer, XP_Rect *bbox);
  329.  
  330. extern char *CL_GetLayerName(CL_Layer *layer);
  331. extern void CL_SetLayerName(CL_Layer *layer, char *name);
  332.  
  333. /* Hide or show a layer. This may result in a redraw */
  334. extern void CL_SetLayerHidden(CL_Layer *layer, PRBool hidden);
  335. extern PRBool CL_GetLayerHidden(CL_Layer *layer);
  336.  
  337. extern void *CL_GetLayerClientData(CL_Layer *layer);
  338. extern void CL_SetLayerClientData(CL_Layer *layer, void *client_data);
  339.  
  340. extern CL_Compositor *CL_GetLayerCompositor(CL_Layer *layer);
  341. extern CL_Layer *CL_GetLayerAbove(CL_Layer *layer);
  342. extern CL_Layer *CL_GetLayerBelow(CL_Layer *layer);
  343. extern CL_Layer *CL_GetLayerSiblingAbove(CL_Layer *layer);
  344. extern CL_Layer *CL_GetLayerSiblingBelow(CL_Layer *layer);
  345. extern CL_Layer *CL_GetLayerChildByName(CL_Layer *layer, char *name);
  346. extern CL_Layer *CL_GetLayerChildByIndex(CL_Layer *layer, uint index);
  347. extern int CL_GetLayerChildCount(CL_Layer *layer);
  348.  
  349. extern int32 CL_GetLayerXOffset(CL_Layer *layer);
  350. extern int32 CL_GetLayerYOffset(CL_Layer *layer);
  351. extern int32 CL_GetLayerXOrigin(CL_Layer *layer);
  352. extern int32 CL_GetLayerYOrigin(CL_Layer *layer);
  353.  
  354. extern void CL_GetLayerVTable(CL_Layer *layer, CL_LayerVTable *vtable);
  355. extern void CL_SetLayerVTable(CL_Layer *layer, CL_LayerVTable *vtable);
  356.  
  357. extern CL_Layer *CL_GetLayerParent(CL_Layer *layer);
  358.  
  359. extern void CL_SetLayerUniformColor(CL_Layer *layer, CL_Color *color);
  360.  
  361. /***************** COMPOSITOR METHODS *****************/
  362.  
  363. /* Allocate and free a compositor */
  364. extern CL_Compositor *CL_NewCompositor(CL_Drawable *primary,
  365.                                        CL_Drawable *backingstore,
  366.                                        int32 x_offset, int32 y_offset,
  367.                                        int32 width, int32 height,
  368.                                        uint32 frame_rate);
  369. extern void CL_DestroyCompositor(CL_Compositor *compositor);
  370.  
  371. /* 
  372.  * Called to indicate that the compositor's contents have changed. This 
  373.  * is useful when we call into client code and need to confirm, on return,
  374.  * that the world hasn't changed around us.
  375.  */
  376. extern void CL_IncrementCompositorGeneration(CL_Compositor *compositor);
  377.  
  378. /* Find layer by name. This carries out a breadth-first search of the layer tree */
  379. extern CL_Layer *CL_FindLayer(CL_Compositor *compositor, char *name);
  380.  
  381. /*
  382.  * Inform the compositor that some part of the window needs to be 
  383.  * refreshed. The region to be refreshed is expressed in window
  384.  * coordinates.
  385.  */
  386. extern void CL_RefreshWindowRegion(CL_Compositor *compositor,
  387.                                    FE_Region refresh_region);
  388. extern void CL_RefreshWindowRect(CL_Compositor *compositor,
  389.                                  XP_Rect *refresh_rect);
  390.  
  391. /*
  392.  * Inform the compositor that some part of a layer has changed and
  393.  * needs to be redrawn. The region to be updated is expressed in
  394.  * the layer's coordinate system. If update_now is TRUE, the 
  395.  * composite is done synchronously. Otherwise, it is done at the
  396.  * next timer callback.
  397.  */
  398. void 
  399. CL_UpdateLayerRegion(CL_Compositor *compositor, CL_Layer *layer,
  400.                      FE_Region update_region, PRBool update_now);
  401.  
  402. /*
  403.  * Version of CL_UpdateLayerRegion where the update region is
  404.  * expressed as a rectangle in the layer's coordinate system.
  405.  * Note that the rectangle can have 32-bit coordinates, whereas
  406.  * the corresponding region cannot.
  407.  */
  408. void
  409. CL_UpdateLayerRect(CL_Compositor *compositor, CL_Layer *layer,
  410.                    XP_Rect *update_rect, PRBool update_now);
  411.  
  412. /* Redraws all regions changed since last call to CL_CompositeNow().
  413.  * This is called by the timer callback. It can be called otherwise
  414.  * to force a synchronous composite. The cutoutp parameter determines
  415.  * whether to subtract out cutout layers while drawing.
  416.  */
  417. extern void CL_CompositeNow(CL_Compositor *compositor);
  418.  
  419. /* Indicates that the window the compositor is drawing to has been resized */
  420. extern void CL_ResizeCompositorWindow(CL_Compositor *compositor, 
  421.                                       int32 width, int32 height);
  422.  
  423.  
  424. /* 
  425.  * Indicates that the window the compositor is drawing to has been scrolled.
  426.  * x_origin and y_origin are the new offsets of the top-left of the window
  427.  * relative to the top-left of the document.
  428. */
  429. extern void CL_ScrollCompositorWindow(CL_Compositor *compositor, 
  430.                                       int32 x_origin, int32 y_origin);
  431.  
  432. /* 
  433.  * Dispatch an event to the correct layer. The return value
  434.  * indicates whether the event was actually handled.
  435.  */
  436. extern PRBool CL_DispatchEvent(CL_Compositor *compositor, CL_Event *event);
  437.  
  438. /* 
  439.  * All events go to the corresponding layer. 
  440.  * A layer value of NULL releases the capture.
  441.  */
  442. extern PRBool CL_GrabMouseEvents(CL_Compositor *compositor, CL_Layer *layer);
  443. extern PRBool CL_GrabKeyEvents(CL_Compositor *compositor, CL_Layer *layer);
  444.  
  445. /* Functions to determine whether a layer has grabbed mouse or key events. */
  446. extern PRBool CL_IsMouseEventGrabber(CL_Compositor *compositor,
  447.                                      CL_Layer *layer);
  448. extern PRBool CL_IsKeyEventGrabber(CL_Compositor *compositor, CL_Layer *layer);
  449.  
  450. /* Functions to determine which layer has grabbed  key events. */
  451. extern CL_Layer *CL_GetKeyEventGrabber(CL_Compositor *compositor);
  452.  
  453. /* Setters and getters */
  454.  
  455. /* Sets whether a compositor offscreen-drawing should occur or not
  456.    If enabled is PR_TRUE, the compositor will use offscreen 
  457.    drawing if applicable.                                          */
  458. extern void CL_SetCompositorOffscreenDrawing(CL_Compositor *compositor, 
  459.                                              CL_OffscreenMode mode);
  460.  
  461. extern CL_OffscreenMode CL_GetCompositorOffscreenDrawing(CL_Compositor *compositor);
  462.  
  463. /* Sets a compositor's enabled state. Disabling a compositor will  */
  464. /* stop timed composites (but will not prevent explicit composites */
  465. /* from happening). Enabling a compositor restarts timed draws.    */
  466. extern PRBool CL_GetCompositorEnabled(CL_Compositor *compositor);
  467. extern void CL_SetCompositorEnabled(CL_Compositor *compositor, 
  468.                                     PRBool enabled);
  469.  
  470. extern CL_Drawable *CL_GetCompositorDrawable(CL_Compositor *compositor);
  471. extern void CL_SetCompositorDrawable(CL_Compositor *compositor, 
  472.                                      CL_Drawable *drawable);
  473.  
  474. extern CL_Layer *CL_GetCompositorRoot(CL_Compositor *compositor);
  475. extern void CL_SetCompositorRoot(CL_Compositor *compositor, CL_Layer *root);
  476.  
  477. extern uint32 CL_GetCompositorFrameRate(CL_Compositor *compositor);
  478. extern void CL_SetCompositorFrameRate(CL_Compositor *compositor, 
  479.                                       uint32 frame_rate);
  480.  
  481. extern int32 CL_GetCompositorXOffset(CL_Compositor *compositor);
  482. extern int32 CL_GetCompositorYOffset(CL_Compositor *compositor);
  483. extern void CL_GetCompositorWindowSize(CL_Compositor *compositor,
  484.                                        XP_Rect *window_size);
  485.  
  486. /* Sets the default keyboard focus change policy */
  487. extern void CL_SetKeyboardFocusPolicy(CL_Compositor *compositor,
  488.                                       CL_KeyboardFocusPolicy policy);
  489.  
  490. extern void CL_SetCompositorDrawingMethod(CL_Compositor *compositor,
  491.                                           CL_DrawingMethod method);
  492.  
  493. /***************** Group-related Compositor methods *****************/
  494.  
  495. /* Adds a layer to a group. Returns TRUE if a new group had to be created */
  496. extern PRBool CL_AddLayerToGroup(CL_Compositor *compositor,
  497.                                   CL_Layer *layer,
  498.                                   char *name);
  499.  
  500. /* Remove a layer from a group */
  501. extern void CL_RemoveLayerFromGroup(CL_Compositor *compositor,
  502.                                     CL_Layer *layer,
  503.                                     char *name);
  504.  
  505. /* Get rid of the layer group */
  506. extern void CL_DestroyLayerGroup(CL_Compositor *compositor,
  507.                                  char *name);
  508.  
  509. /* Hide or unhide all layers in the group */
  510. extern void CL_HideLayerGroup(CL_Compositor *compositor, char *name);
  511. extern void CL_UnhideLayerGroup(CL_Compositor *compositor, char *name);
  512.  
  513. /* Move all the layers in a group */
  514. extern void CL_OffsetLayerGroup(CL_Compositor *compositor, char *name,
  515.                                 int32 x_offset, int32 y_offset);
  516.  
  517. /* Execute function for each layer in the group */
  518. extern PRBool CL_ForEachLayerInGroup(CL_Compositor *compositor,
  519.                                      char *name,
  520.                                      CL_LayerInGroupFunc func,
  521.                                      void *closure);
  522.  
  523. /***************** Utility Compositor methods  *****************/
  524.  
  525. extern void CL_CreateDefaultLayers(CL_Compositor *compositor);
  526.  
  527. /* Convert rectangle from window to document coordinate system */
  528. extern void CL_WindowToDocumentRect(CL_Compositor *compositor, 
  529.                                     XP_Rect *rect);
  530.  
  531. /* Convert rectangle from document to window coordinate system */
  532. extern void CL_DocumentToWindowRect(CL_Compositor *compositor, 
  533.                                     XP_Rect *rect);
  534. /* 
  535.  * This is here temporarily. This is similar to CL_UpdateLayerRect,
  536.  * except the rectangle is specified in document coordinates. For
  537.  * now, it's a convenience function. In the future, the callers of
  538.  * this function should be able to provide a layer.
  539.  */
  540. extern void CL_UpdateDocumentRect(CL_Compositor *compositor,
  541.                                   XP_Rect *update_rect, PRBool update_now);
  542.  
  543. /* Convert a rect from window to layer coordinate system */
  544. extern void CL_WindowToLayerRect(CL_Compositor *compositor, CL_Layer *layer,
  545.                                  XP_Rect *rect);
  546.  
  547. /* Convert a rect from layer to window coordinate system */
  548. extern void CL_LayerToWindowRect(CL_Compositor *compositor, CL_Layer *layer,
  549.                                  XP_Rect *rect);
  550.  
  551. /* Convert a region from layer to window coordinate system */
  552. extern void CL_LayerToWindowRegion(CL_Compositor *compositor, CL_Layer *layer,
  553.                                    FE_Region region);
  554.  
  555. /* Convert a region from window to layer coordinate system */
  556. extern void CL_WindowToLayerRegion(CL_Compositor *compositor, CL_Layer *layer,
  557.                                    FE_Region region);
  558.  
  559. /***************** Drawable methods *****************/
  560.  
  561. extern CL_Drawable *CL_NewDrawable(uint width, uint height,
  562.                                    uint32 flags,
  563.                                    CL_DrawableVTable *vtable,
  564.                                    void *client_data);
  565.  
  566. extern void CL_DestroyDrawable(CL_Drawable *drawable);
  567.  
  568. extern void *CL_GetDrawableClientData(CL_Drawable *drawable);
  569.  
  570. extern CL_Color *CL_GetDrawableBgColor(CL_Drawable *drawable, XP_Rect *win_rect);
  571.  
  572.  
  573. /************* Other utility functions **************/
  574. extern float CL_RegionEntropy(FE_Region region);
  575. extern void CL_ForEachRectCoveringRegion(FE_Region region, FE_RectInRegionFunc func,
  576.                      void *closure);
  577.  
  578. XP_END_PROTOS
  579.  
  580. #endif /* _LAYERS_H_ */
  581.  
  582.