home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / laysub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.9 KB  |  179 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. #include "xp.h"
  20. #include "pa_parse.h"
  21. #include "layout.h"
  22.  
  23. #ifdef TEST_16BIT
  24. #define XP_WIN16
  25. #endif /* TEST_16BIT */
  26.  
  27. #define    SUBDOC_DEF_ANCHOR_BORDER        1
  28. #define    SUBDOC_DEF_VERTICAL_SPACE        5
  29. #define    SUBDOC_DEF_HORIZONTAL_SPACE        5
  30.  
  31. #define    CELL_LINE_INC        10
  32.  
  33.  
  34. void
  35. lo_InheritParentState(MWContext *context,
  36.     lo_DocState *child_state, lo_DocState *parent_state)
  37. {
  38.     /*
  39.      * Instead of the default of a new doc assuming 100 lines,
  40.      * we will start assuming a cell is 10 lines.
  41.      * This save lots of memory in table processing.
  42.      */
  43.     if ((child_state->is_a_subdoc == SUBDOC_CELL)||
  44.         (child_state->is_a_subdoc == SUBDOC_CAPTION))
  45.     {
  46.         XP_Block line_array_block;
  47.         LO_Element **line_array;
  48.  
  49.         line_array_block = XP_ALLOC_BLOCK(CELL_LINE_INC *
  50.                     sizeof(LO_Element *));
  51.         if (line_array_block != NULL)
  52.         {
  53.             XP_FREE_BLOCK(child_state->line_array);
  54.             child_state->line_array = line_array_block;
  55.             XP_LOCK_BLOCK(line_array, LO_Element **,
  56.                 child_state->line_array);
  57.             line_array[0] = NULL;
  58.             XP_UNLOCK_BLOCK(child_state->line_array);
  59.             child_state->line_array_size = CELL_LINE_INC;
  60. #ifdef XP_WIN16
  61. {
  62.             XP_Block *larray_array;
  63.  
  64.             XP_LOCK_BLOCK(larray_array, XP_Block *,
  65.                 child_state->larray_array);
  66.             larray_array[0] = child_state->line_array;
  67.             XP_UNLOCK_BLOCK(child_state->larray_array);
  68. }
  69. #endif /* XP_WIN16 */
  70.         }
  71.     }
  72.  
  73.     if (((child_state->is_a_subdoc == SUBDOC_CELL)||
  74.         (child_state->is_a_subdoc == SUBDOC_CAPTION))&&
  75.         ((parent_state->is_a_subdoc == SUBDOC_CELL)||
  76.         (parent_state->is_a_subdoc == SUBDOC_CAPTION)))
  77.     {
  78.         child_state->subdoc_tags = parent_state->subdoc_tags_end;
  79.         child_state->subdoc_tags_end = NULL;
  80.     }
  81.  
  82.     lo_InheritParentColors(context, child_state, parent_state);
  83. }
  84.  
  85. void
  86. lo_InheritParentColors(MWContext *context,
  87.     lo_DocState *child_state, lo_DocState *parent_state)
  88. {
  89.     child_state->text_fg.red = STATE_DEFAULT_FG_RED(parent_state);
  90.     child_state->text_fg.green = STATE_DEFAULT_FG_GREEN(parent_state);
  91.     child_state->text_fg.blue = STATE_DEFAULT_FG_BLUE(parent_state);
  92.  
  93.     child_state->text_bg.red = STATE_DEFAULT_BG_RED(parent_state);
  94.     child_state->text_bg.green = STATE_DEFAULT_BG_GREEN(parent_state);
  95.     child_state->text_bg.blue = STATE_DEFAULT_BG_BLUE(parent_state);
  96.     lo_ResetFontStack(context, child_state);
  97.  
  98.     child_state->anchor_color.red =
  99.         STATE_UNVISITED_ANCHOR_RED(parent_state);
  100.     child_state->anchor_color.green =
  101.         STATE_UNVISITED_ANCHOR_GREEN(parent_state);
  102.     child_state->anchor_color.blue =
  103.         STATE_UNVISITED_ANCHOR_BLUE(parent_state);
  104.  
  105.     child_state->visited_anchor_color.red =
  106.         STATE_VISITED_ANCHOR_RED(parent_state);
  107.     child_state->visited_anchor_color.green =
  108.         STATE_VISITED_ANCHOR_GREEN(parent_state);
  109.     child_state->visited_anchor_color.blue =
  110.         STATE_VISITED_ANCHOR_BLUE(parent_state);
  111.  
  112.     child_state->active_anchor_color.red =
  113.         STATE_SELECTED_ANCHOR_RED(parent_state);
  114.     child_state->active_anchor_color.green =
  115.         STATE_SELECTED_ANCHOR_GREEN(parent_state);
  116.     child_state->active_anchor_color.blue =
  117.         STATE_SELECTED_ANCHOR_BLUE(parent_state);
  118.  
  119.     child_state->hide_content = parent_state->hide_content;
  120. }
  121. int32
  122. lo_GetSubDocBaseline(LO_SubDocStruct *subdoc)
  123. {
  124.     LO_Element **line_array;
  125.     LO_Element *eptr;
  126.     lo_DocState *subdoc_state;
  127.  
  128.     subdoc_state = (lo_DocState *)subdoc->state;
  129.     if (subdoc_state == NULL)
  130.     {
  131.         return(0);
  132.     }
  133.  
  134.     /*
  135.      * Make eptr point to the start of the element chain
  136.      * for this subdoc.
  137.      */
  138. #ifdef XP_WIN16
  139. {
  140.     XP_Block *larray_array;
  141.  
  142.     if (subdoc_state->larray_array == NULL)
  143.     {
  144.         return(0);
  145.     }
  146.     XP_LOCK_BLOCK(larray_array, XP_Block *, subdoc_state->larray_array);
  147.     subdoc_state->line_array = larray_array[0];
  148.     XP_UNLOCK_BLOCK(subdoc_state->larray_array);
  149. }
  150. #endif /* XP_WIN16 */
  151.     if (subdoc_state->line_array == NULL)
  152.     {
  153.         return(0);
  154.     }
  155.     XP_LOCK_BLOCK(line_array, LO_Element **, subdoc_state->line_array);
  156.     eptr = line_array[0];
  157.     XP_UNLOCK_BLOCK(subdoc_state->line_array);
  158.  
  159.     while (eptr != NULL)
  160.     {
  161.         if (eptr->type == LO_LINEFEED)
  162.         {
  163.             break;
  164.         }
  165.         eptr = eptr->lo_any.next;
  166.     }
  167.     if (eptr == NULL)
  168.     {
  169.         return(0);
  170.     }
  171.     return(eptr->lo_linefeed.baseline);
  172. }
  173.  
  174.  
  175. #ifdef TEST_16BIT
  176. #undef XP_WIN16
  177. #endif /* TEST_16BIT */
  178.  
  179.