dnl ######################################################################## dnl dnl $Id: primitives.m4,v 1.16 2010/03/20 20:59:15 sauer Exp $ dnl dnl ######################################################################## dnl "dnl" is the preferred comment convention for m4 files. dnl Using the other comment conventions of m4 is hazardous because of the dnl need for changecom(). Using HTML comment conventions is hazardous because dnl of commas and other m4 syntactic elements that may be recognized by m4. dnl This file defines macros that are expected to be appearance independent. dnl appearance.m4 is intended to be processed immediately after this file, dnl so appearance.m4 may redefine some of these macros, if appropriate. dnl Note that literal commas and apostrophe's may be interpreted syntactically dnl by m4, as parameter separators and quote terminators, respectively. It is dnl better to use , for comma and ' for apostrophe where literals are dnl needed. dnl A minimal file using these macros would be structured as follows: dnl dnl FILENAME.m4 $Id: primitives.m4,v 1.16 2010/03/20 20:59:15 sauer Exp $ dnl dnl define(m4_page_name, `index') dnl define(m4_page_title, `My home page') dnl dnl include(`primitives.m4') dnl include(`appearance.m4') dnl dnl m4_page( dnl m4_table( dnl m4_row( dnl dnl , dnl {begin row primary content} dnl dnl ) dnl end m4_row primary content dnl ) dnl end m4_table dnl ) dnl end m4_page dnl Look for `m4_primitives' to test if this file has already been processed: ifdef(`m4_primitives',, define(`m4_primitives') dnl Undefine `format' so word can be used as text undefine(`format') define(`m4_null',) define(`m4_space', ) define(`m4_two_spaces',   ) define(`m4_clear_dot', ) dnl The following is used to generate CGI tags for "hidden" variables dnl define(`m4_hidden_input',) dnl dnl If redefined, as follows, preferably in appearance.m4, it will also dnl display diagnostic information. dnl Note that the third parameter is for additional diagnostic information dnl and is not referenced in the default case dnl define(`m4_hidden_input', dnl
Hidden Input NAME=$1; set to VALUE=$2; $3) define(`m4_margin_table_begin', `
') define(`m4_margin_table_end', `
') dnl A typical page will have a table column defining the left margin. dnl Provide a way to have left and right sub-margins in that column: define(`m4_left_margin_margin_table_begin', `
') define(`m4_left_margin_margin_table_end', `m4_left_margin_margin_table_width_clear_img
') define(`m4_left_margin_margin_table_width_clear_img',) define(`m4_column_margin_table_width_clear_img',) dnl Similarly, provide a margin table for the main column: define(`m4_column_margin_table_begin',
) define(`m4_column_margin_table_end', m4_column_margin_table_width_clear_img
) define(`m4_column_margin_table', m4_column_margin_table_begin$1m4_column_margin_table_end) define(`m4_column_hanging_indent_table_begin',` ') define(`m4_column_hanging_indent_table_end',`
') define(`m4_column_hanging_indent_table', m4_column_hanging_indent_table_begin$1m4_column_hanging_indent_table_end) define(`m4_column_hanging_indent_row_begin',` ') define(`m4_column_hanging_indent_row_middle',`
') define(`m4_column_hanging_indent_row_end',` ') define(`m4_column_hanging_indent_row', dnl $1 is indent width dnl $2 will be "label" content dnl $3 will be "main" content ` m4_column_hanging_indent_row_begin($1)$2m4_column_hanging_indent_row_middle($1)$3m4_column_hanging_indent_row_end($1) ' ) define(`m4_column_hanging_indent2_table_begin',` ') define(`m4_column_hanging_indent2_table_end',`
') define(`m4_column_hanging_indent2_table', m4_column_hanging_indent2_table_begin$1m4_column_hanging_indent2_table_end) define(`m4_column_hanging_indent2_row_begin',` ') define(`m4_column_hanging_indent2_row_middle',`
') define(`m4_column_hanging_indent2_row_end',` ') define(`m4_column_hanging_indent2_row', dnl $1 is indent width dnl $2 will be "label" content dnl $3 will be "main" content ` m4_column_hanging_indent2_row_begin($1)$2m4_column_hanging_indent2_row_middle($1)$3m4_column_hanging_indent2_row_end($1) ' ) dnl The next three will be used to define a "row" of the "root" table. define(`m4_row_begin',` m4_left_border ') define(`m4_row_middle',` m4_left_margin_line ') define(`m4_row_column_end', m4_right_margin_line ) define(`m4_row_end', m4_right_border ) define(`m4_label_content_format', ifdef(m4_center_labels,
)$1ifdef(`m4_enable_margin_links',,
)ifdef(m4_center_labels,
) ) dnl Following is logically what we want. However, evaluation order says that dnl m4_enable_margin_links will never be defined at the point the ifdef is dnl evaluated, so if m4_enable_margin_links is defined, m4_row should be dnl defined again (in appearance.m4, after m4_enable_margin_links is defined). ifdef(`m4_enable_margin_links', ` define(`m4_row', dnl $1 will be "label" content; dnl $2 will be "main" content dnl $3 will be "tertiary" content m4_row_beginm4_margin_table_begin$1m4_margin_table_endm4_row_middlem4_margin_table_begin$2m4_margin_table_endm4_row_column_end$3m4_row_end ) define(`m4_center_labels') dnl "normal" with margin links define(`m4_label_content_format', dnl redefine to reflect center_labels ifdef(m4_center_labels,
)$1ifdef(`m4_enable_margin_links',,
)ifdef(m4_center_labels,
) ) ' , ` define(`m4_row', dnl $1 will be "label" content; dnl $2 will be "main" content dnl $3 will be "tertiary" content m4_row_beginm4_clear_dotm4_row_middle
ifelse($1,,m4_clear_dot,$1)$2$3
m4_row_column_endm4_clear_dotm4_row_end ) ' ) dnl A typical row should have margin spaces define(`m4_row_with_margins', dnl $1 will be "label" content; dnl $2 will be "main" content dnl $3 will be "tertiary" content ` m4_row_beginm4_left_margin_margin_table_begin$1m4_left_margin_margin_table_endm4_row_middlem4_column_margin_table_begin$2m4_column_margin_table_endm4_row_column_end$3m4_row_end ' ) dnl A wide row spans the label and tertiary columns define(`m4_wide_row',` m4_left_border $1 m4_right_border ' ) define(`m4_wide_row_with_margins',` m4_left_border
$1
m4_right_border ' ) define(`m4_wide_2col_row_with_margins',` m4_left_border
$1$2
m4_right_border ' ) dnl We need to surround
and
with since some dnl browsers add a break. define(`m4_nobreak',$1) define(`m4_end_form_row', ` m4_row(m4_nobreak()m4_clear_dot, m4_clear_dot, m4_clear_dot) ' ) dnl This defines the "root" table: define(`m4_table', ` dnl ifelse(m4_page_name,nindex,,m4_top_row) dnl
dnl $1 ifelse(m4_page_name,nindex,,m4_bottom_row) dnl
' ) dnl This defines the page as a whole: define(`m4_page', ` ifdef(`m4_css',) m4_head_definition ifdef(`m4_css',,) ifdef(`m4_css',,
) m4_top_bar m4_header $1 m4_footer m4_bottom_bar ' ) ) dnl ifdef m4_primitives else case