Example #1
0
/* Construct a horizontal rule divnode, and insert it on a line by itself */
g_error html_tag_hr(struct html_parse *hp, struct html_tag_params *tag) {
  g_error e;
  struct divnode *div;
  struct gropctxt gc;

  /* Simple horizontal line divnode.
   * FIXME: Make this more configurable via themes, process the
   *        parameters to <hr>
   *
   * This creates a new divnode with a preferred height of 3 pixels,
   * and draws a line through the middle pixel of that
   */
  e = newdiv(&div,hp->c->widget);
  errorcheck;
  div->ph = 3;
  gropctxt_init(&gc,div);
  addgropsz(&gc,PG_GROP_SLAB,0,1,0x7FFF,1);
  
  /* This resets our blankness counter, but
   * text_insert_line_div() counts as a blank line 
   */
  hp->blank_lines = 1;

  return text_insert_line_div(hp->c,div);
}
Example #2
0
/* Set up divnodes */
g_error textedit_install(struct widget *self) {
    g_error e;

    WIDGET_ALLOC_DATA(texteditdata);

    /* main split */
    e = newdiv(&self->in, self);  
    errorcheck;
    
    self->in->flags |= PG_S_ALL;

    /* Visible node */
    e = newdiv(&self->in->div, self);  
    errorcheck;
    
    self->in->div->build = &textedit_build; 
    self->in->div->state = PGTH_O_TEXTEDIT;
    self->in->div->flags = DIVNODE_SPLIT_EXPAND | DIVNODE_SIZE_AUTOSPLIT | 
        DIVNODE_SIZE_RECURSIVE | DIVNODE_HOTSPOT; 
    self->trigger_mask = PG_TRIGGER_ACTIVATE |
        PG_TRIGGER_DEACTIVATE | PG_TRIGGER_DRAG |
        PG_TRIGGER_DOWN | PG_TRIGGER_RELEASE | 
        PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | 
        PG_TRIGGER_TIMER |  PG_TRIGGER_NONTOOLBAR;
 
    self->out = &self->in->next;
    gropctxt_init(CTX,self->in->div);

    self->in->div->flags |= PG_S_RIGHT;
    self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT;

    DATA->fg =        VID(color_pgtohwr) (TEXT_FG);
    DATA->bg =        VID(color_pgtohwr) (TEXT_BG);
    DATA->highlight = VID(color_pgtohwr) (TEXT_HIGHLIGHT);           
    DATA->bit = NULL;
    DATA->thumb_size = 0;
    DATA->thumb_top = 0;
    DATA->thumb_drag_start = 0;
    DATA->scroll_lock = 0;

    e = text_backend_init(DATA);
    errorcheck;

    self->in->div->flags |= PG_S_RIGHT;
    self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT;

    e = newdiv(&self->in->div->div,self);
    errorcheck;
    self->in->div->div->build = &textedit_build_scroll;
    self->in->div->div->state = PGTH_O_SCROLL;
    self->out = &self->in->div->next;

    DATA->self = self;
    return success;
}
Example #3
0
/* Create a paragraph and divnode tied to each other */
g_error textbox_new_par_div(struct paragraph **par, struct divnode **div,
			    struct divnode *background) {
  g_error e;
  handle hpar;
  struct gropctxt c;
  struct paragraph *old_par = *par;
  struct divnode *old_div = *div;

  /* Top-level divnode for this paragraph is used for formatting, it's
   * child is where the paragraph renders to.
   */
  e = newdiv(div,background->owner);
  errorcheck;
  (*div)->flags |= DIVNODE_SPLIT_TOP;
  (*div)->flags &= ~DIVNODE_UNDERCONSTRUCTION;

  /* We want to prevent the normal groplist clearing in div_rebuild
   * because the only way our build function has to know the
   * paragraph handle is by reading the previous groplist.
   */
  e = newdiv(&(*div)->div,background->owner);
  errorcheck;
  (*div)->div->build = &textbox_build_par_div;
  (*div)->div->flags |= DIVNODE_RAW_BUILD;
  (*div)->div->flags &= ~DIVNODE_UNDERCONSTRUCTION;

  /* New paragraph with associated handle */
  e = paragraph_new(par, *div);
  errorcheck;
  e = mkhandle(&hpar, PG_TYPE_PARAGRAPH, -1, *par);
  errorcheck;
  (*par)->background = background;

  /* build the initial groplist-
   * one incremental paragraph divnode, one normal one.
   * The size and theme related params will be filled in later.
   */
  gropctxt_init(&c,(*div)->div);
  addgrop(&c,PG_GROP_SETCOLOR);
  addgrop(&c,PG_GROP_PARAGRAPH);
  c.current->param[0] = hpar;
  addgrop(&c,PG_GROP_PARAGRAPH_INC);
  c.current->param[0] = hpar;
  c.current->flags |= PG_GROPF_INCREMENTAL;

  /* Relink the portion of the paragraph and divnode lists after this node */
  (*par)->next = old_par;
  (*div)->next = old_div;

  return success;
}