home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / laylayer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.1 KB  |  263 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.  
  20. /*
  21.  * Layer-specific data structures and declarations for HTML layout library.
  22.  */
  23. #ifndef _LAYLAYER_H
  24. #define _LAYLAYER_H
  25.  
  26. #define LO_IGNORE_TAG_MARKER 0xFFFF
  27.  
  28. typedef struct lo_Block lo_Block; /* Forward declaration */
  29.  
  30. /*
  31.  * This struct represents the layout side of a layer created with
  32.  * a <(I)LAYER> tag. It holds onto the contents of the layer (in a cell)
  33.  * along with lists of elements that are part of the layer's
  34.  * "document".
  35.  */
  36. struct lo_LayerDocState 
  37. {
  38.     int32 id;
  39.     LO_CellStruct *cell;        /* Contents of layer */
  40.     int32 height;               /* Value of layer's HEIGHT attribute, or zero */
  41.  
  42.     PRPackedBool is_constructed_layer; /* Created with JS new operator ? */
  43.     PRPackedBool overrideScrollWidth; /* Only used for _DOCUMENT layer */
  44.     PRPackedBool overrideScrollHeight;
  45.     int32 contentWidth;         /* Dimensions of content, not including
  46.                                    child layers. */
  47.     int32 contentHeight;
  48.     
  49.     XP_Rect viewRect;           /* Non-scrolling clip rectangle */
  50.     
  51.     CL_Layer *layer;
  52.     void *mocha_object;
  53.     lo_DocLists *doc_lists;      /* Layout element lists, e.g. embeds, forms */
  54.     lo_Block *temp_block;       /* Data used only during HTML layer layout */
  55. };
  56.  
  57. struct lo_LayerStack {
  58.     lo_LayerDocState *layer_state;
  59.     lo_LayerStack *next;
  60. };
  61.  
  62. /* A layer closure is the piece of layout-specific data that gets
  63.    attached as client-data to a CL_Layer.  They come in all different
  64.    flavors, depending on the purpose of the layer. */
  65.  
  66. /* Cheap inheritance: Struct members common to all types of layer closures */
  67. #define LO_LAYER_CLOSURE_STRUCT_MEMBERS                                       \
  68.     LO_LayerType type;                                                        \
  69.     MWContext *context
  70.  
  71. typedef struct lo_BlinkLayerClosure {
  72.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  73.     LO_TextStruct *text;   /* The text element that's blinking */
  74. } lo_BlinkLayerClosure;
  75.  
  76. typedef struct lo_ImageLayerClosure {
  77.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  78.     LO_ImageStruct *image;   /* The layout image element */
  79. } lo_ImageLayerClosure;
  80.  
  81. typedef struct lo_CellBGLayerClosure {
  82.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  83.     LO_CellStruct *cell;    /* The cell that we're the background for */
  84. } lo_CellBGLayerClosure;
  85.  
  86. typedef struct lo_HTMLBlockClosure {
  87.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  88.     int32 x_offset;         /* Layout imposed offset for in-flow layers */
  89.     int32 y_offset;
  90.     lo_DocState *state;     /* The layout document state */
  91.     lo_LayerDocState *layer_state; /* The layer doc state */
  92.     PRBool is_inflow;
  93. } lo_HTMLBlockClosure;
  94.  
  95. typedef struct lo_HTMLBodyClosure {
  96.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  97.     CL_Layer *layer;
  98. } lo_HTMLBodyClosure;
  99.  
  100. typedef struct lo_EmbeddedObjectClosure {
  101.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  102.     LO_Element *element;    /* Plugin, Java applet, or form element */
  103.     PRPackedBool is_windowed;
  104. } lo_EmbeddedObjectClosure;
  105.  
  106. /* This struct belongs to the main container layer for a group of
  107.    related layers, i.e. the layer that is reflected by the <LAYER> or
  108.    <ILAYER> tags.  It has child layers that represent the layer's
  109.    background, HTML contents, table cell backdrop layers, etc. */
  110. typedef struct lo_GroupLayerClosure {
  111.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  112.     int32 x_offset;              /* Layout imposed offset for in-flow layers */
  113.     int32 y_offset;
  114.     CL_Layer *content_layer;     /* The child content layer    */
  115.     CL_Layer *background_layer;  /* The child background layer */
  116.     int32 wrap_width;            /* Pixel position at which text wraps   */
  117.     int clip_expansion_policy;
  118.     PRBool is_inflow;
  119.     lo_LayerDocState *layer_state; /* The layer doc state */
  120. } lo_GroupLayerClosure;
  121.  
  122. /* A background layer encompasses either the entire canvas (document),
  123.    a single layer, or a single background cell. */
  124. typedef enum {
  125.     BG_DOCUMENT,
  126.     BG_LAYER,
  127.     BG_CELL
  128. } lo_BackgroundType;
  129.  
  130. typedef struct lo_BackgroundLayerClosure {
  131.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  132.     LO_Color *bg_color;
  133.     LO_ImageStruct *backdrop_image;
  134.     lo_TileMode tile_mode;
  135.     lo_BackgroundType bg_type;
  136.     LO_CellStruct *cell;
  137. } lo_BackgroundLayerClosure;
  138.  
  139. typedef struct lo_AnyLayerClosure {
  140.     LO_LAYER_CLOSURE_STRUCT_MEMBERS;
  141. } lo_AnyLayerClosure;
  142.  
  143. typedef union lo_LayerClosure {
  144.     lo_AnyLayerClosure any_closure;
  145.     lo_BlinkLayerClosure blink_closure;
  146.     lo_ImageLayerClosure image_closure;
  147.     lo_CellBGLayerClosure cellbg_closure;
  148.     lo_HTMLBlockClosure block_closure;
  149.     lo_HTMLBodyClosure body_closure;
  150.     lo_GroupLayerClosure group_closure;
  151.     lo_BackgroundLayerClosure background_closure;
  152.     lo_EmbeddedObjectClosure object_closure; /* plugin, java, form */
  153. } lo_LayerClosure;
  154.  
  155.  
  156. extern void
  157. lo_CreateBlinkLayer (MWContext *context, LO_TextStruct *text, 
  158.                      CL_Layer *parent);
  159. extern void
  160. lo_DestroyBlinkers(MWContext *context);
  161. extern void
  162. lo_UpdateBlinkLayers(MWContext *context);
  163.  
  164. extern CL_Layer *
  165. lo_CreateBlockLayer(MWContext *context, 
  166.                     char *name,
  167.                     PRBool is_inflow,
  168.                     int32 x_offset, int32 y_offset,
  169.                     int32 wrap_width,
  170.                     lo_LayerDocState *layer_state, 
  171.                     lo_DocState *state);
  172. extern void
  173. lo_CreateDefaultLayers(MWContext *context,
  174.                        CL_Layer **doc_layer, CL_Layer **body_layer);
  175.  
  176. extern void
  177. lo_AttachHTMLLayer(MWContext *context, CL_Layer *layer, CL_Layer *parent,
  178.                    char *above, char *below, int32 z_order);
  179.  
  180. extern PRBool lo_InsideLayer(lo_DocState *state);
  181. extern PRBool lo_InsideInflowLayer(lo_DocState *state);
  182.  
  183. extern lo_LayerDocState * lo_NewLayerState(MWContext *context);
  184. extern void lo_DeleteLayerState(MWContext *context, lo_DocState *state,
  185.                                 lo_LayerDocState *layer_state);
  186. extern void lo_AddLineListToLayer(MWContext *, lo_DocState *, LO_Element *);
  187.  
  188. extern CL_Layer *
  189. lo_CreateCellBackgroundLayer(MWContext *context, LO_CellStruct *cell,
  190.                              CL_Layer *parent_layer);
  191. extern CL_Layer *
  192. lo_CreateEmbedLayer(MWContext *context, CL_Layer *parent,
  193.                     int32 x, int32 y, int32 width, int32 height,
  194.                     LO_EmbedStruct *embed, lo_DocState *state);
  195. extern CL_Layer *
  196. lo_CreateEmbeddedObjectLayer(MWContext *context, lo_DocState *state,
  197.                  LO_Element *tptr);
  198. extern CL_Layer *
  199. lo_CreateImageLayer (MWContext *context, LO_ImageStruct *text, 
  200.                      CL_Layer *parent);
  201. extern void lo_ActivateImageLayer(MWContext *context, LO_ImageStruct *image);
  202.  
  203. extern void
  204. lo_PushLayerState(lo_TopState *top_state, lo_LayerDocState *layer_state);
  205. extern lo_LayerDocState *
  206. lo_PopLayerState(lo_DocState *state);
  207. extern lo_LayerDocState *
  208. lo_CurrentLayerState(lo_DocState *state);
  209. extern void
  210. lo_DeleteLayerStack(lo_DocState *state);
  211.  
  212. extern int32
  213. lo_CurrentLayerId(lo_DocState *state);
  214. extern CL_Layer *
  215. lo_CurrentLayer(lo_DocState *state);
  216. extern PRBool
  217. lo_IsCurrentLayerDynamic(lo_DocState *state);
  218. extern PRBool
  219. lo_IsTagInSourcedLayer(lo_DocState *state, PA_Tag *tag);
  220. extern PRBool
  221. lo_IsAnyCurrentAncestorSourced(lo_DocState *state);
  222. extern PRBool
  223. lo_IsAnyCurrentAncestorDynamic(lo_DocState *state);
  224.  
  225. extern lo_LayerDocState *
  226. lo_GetLayerState(CL_Layer *layer);
  227.  
  228. extern int32
  229. lo_GetEnclosingLayerHeight(lo_DocState *state);
  230.  
  231. extern int32
  232. lo_GetEnclosingLayerWidth(lo_DocState *state);
  233.  
  234. LO_CellStruct *
  235. lo_GetCellFromLayer(MWContext *context, CL_Layer *layer);
  236.  
  237. extern void
  238. lo_OffsetInflowLayer(CL_Layer *layer, int32 dx, int32 dy);
  239.  
  240. extern void
  241. lo_BlockLayerTag(MWContext *context, lo_DocState *state, PA_Tag *tag);
  242. extern void
  243. lo_UnblockLayerTag(lo_DocState *state);
  244. extern void
  245. lo_FinishLayerLayout(MWContext *context, lo_DocState *state, int mocha_event);
  246.  
  247. extern void
  248. lo_GetLayerXYShift(CL_Layer *layer, int32 *xp, int32 *yp);
  249.  
  250. extern void
  251. lo_DestroyLayers(MWContext *context);
  252.  
  253. extern lo_LayerDocState *
  254. lo_append_to_layer_array(MWContext *context, lo_TopState *top_state,
  255.                          lo_DocState *state, 
  256.                          lo_LayerDocState *layer_state);
  257.  
  258. extern void
  259. lo_SetLayerBackdropTileMode(CL_Layer *layer, lo_TileMode tile_mode);
  260. extern void lo_EndLayerTag(MWContext *, lo_DocState *, PA_Tag *tag);
  261.  
  262. #endif /* _LAYLAYER_H */
  263.