g_error panelbar_install(struct widget *self) { /* Divtree set up almost exactly like the box widget */ g_error e; WIDGET_ALLOC_DATA(panelbardata); e = newdiv(&self->in,self); errorcheck; self->in->flags |= PG_S_BOTTOM; self->in->flags &= ~DIVNODE_SIZE_AUTOSPLIT; e = newdiv(&self->in->div,self); errorcheck; self->in->div->flags |= DIVNODE_SPLIT_BORDER; self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT; self->in->div->build = &build_bgfill_only; self->in->div->state = PGTH_O_PANELBAR_H; DATA->panelbar = self->in->div; self->out = &self->in->next; self->sub = &self->in->div->div; self->trigger_mask = PG_TRIGGER_ENTER | PG_TRIGGER_LEAVE | PG_TRIGGER_DOWN | PG_TRIGGER_UP | PG_TRIGGER_RELEASE | PG_TRIGGER_DRAG | PG_TRIGGER_MOVE; /* Panelbars use auto-orientation by default */ self->auto_orientation = PG_AUTO_SIDE | PG_AUTO_DIRECTION; #ifdef CONFIG_DRAGSOLID DATA->solid = get_param_int("pgserver","dragsolid",0); #endif return success; }
/* 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; }
/* 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; }
float newdiv(int u, int l) // this function returns Newton Divided Difference value for given boundries { float result =0.0; int lb = l, ub = u; if( (ub - lb) == 1 ){ result = ((fx[ub] - fx[lb])/(x[ub] - x[lb])); }else { result = ((newdiv(ub,lb+1) - newdiv(ub-1,lb))/(x[ub] - x[lb])); } return result; } // end function newdiv
float newdiv(int u, int l) // gives the divided difference for given boundries { float result =0.0; int lb = l, ub = u; if( (ub - lb) == 1 ){ result = ((fx[ub] - fx[lb])/(x[ub] - x[lb])); }else { result = ((newdiv(ub,lb+1) - newdiv(ub-1,lb))/(x[ub] - x[lb])); } return result; }
/* 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); }
float delJfI(int j, int i, float h) // gives jth order divided difference for ith function { float result; result = (fact(j)*pow(h,j)*newdiv((i+j),i)); return result; }
int main() { int i, j, n = sizeof(x)/4; // n is number of points available float reqd_x = 2.5; // value of x for wihich we need f(x) value float px = fx[0]; for( i = 1; i < n; i++ ) { px += (newdiv(i,0) * multiple(i,reqd_x)); } printf("\nValue of f(%.2f) at p%d(%.2f) = %f\n",reqd_x, n-1, reqd_x, px); getch(); return 0; } //end main
g_error panel_install(struct widget *self) { struct widget *bar, *title; g_error e; WIDGET_ALLOC_DATA(paneldata); /* This split determines the size of the main panel area */ e = newdiv(&self->in,self); errorcheck; self->in->flags &= ~(DIVNODE_SIZE_AUTOSPLIT | DIVNODE_SIZE_RECURSIVE); self->in->flags |= PG_S_TOP; /* An optional border inside that main panel area */ e = newdiv(&self->in->div,self); errorcheck; self->in->div->flags &= ~(DIVNODE_SIZE_AUTOSPLIT | DIVNODE_SIZE_RECURSIVE); self->in->div->flags |= DIVNODE_SPLIT_BORDER; self->in->div->build = &build_panel_border; /* Create the panelbar widget */ e = widget_create(&bar,&DATA->hbar,PG_WIDGET_PANELBAR, self->dt,self->container,self->owner); errorcheck; e = widget_attach(bar,self->dt,&self->in->div->div,0); errorcheck; e = widget_set(bar,PG_WP_BIND,self->h); errorcheck; /* This draws the panel background */ e = newdiv(bar->out,self); errorcheck; DATA->bg = *bar->out; DATA->bg->flags |= DIVNODE_SPLIT_BORDER; DATA->bg->flags &= ~DIVNODE_SIZE_AUTOSPLIT; DATA->bg->build = &build_bgfill_only; DATA->bg->state = PGTH_O_PANEL; /* Set up us the container! */ self->out = &self->in->next; self->sub = &DATA->bg->div; /* Firstly, create a label widget in the panelbar to present the title */ title = NULL; e = widget_derive(&title,&DATA->hlabel,PG_WIDGET_LABEL,bar,DATA->hbar, PG_DERIVE_INSIDE,self->owner); errorcheck; widget_set(title,PG_WP_SIDE,PG_S_ALL); widget_set(title,PG_WP_THOBJ,PGTH_O_PANELBAR); /* Nextly, create the standard buttons for a panel app */ e = panel_std_button(&DATA->hzoom, self, PGTH_O_ZOOMBTN, PGTH_O_ZOOMBTN_ON, PGTH_O_ZOOMBTN_HILIGHT, PG_EXEV_TOGGLE, &panel_zoom_callback); errorcheck; e = panel_std_button(&DATA->hrotate, self, PGTH_O_ROTATEBTN, PGTH_O_ROTATEBTN_ON, PGTH_O_ROTATEBTN_HILIGHT, 0, &panel_rotate_callback); errorcheck; e = panel_std_button(&DATA->hclose, self, PGTH_O_CLOSEBTN, PGTH_O_CLOSEBTN_ON, PGTH_O_CLOSEBTN_HILIGHT, 0, &panel_close_callback); errorcheck; /* Make sure we default to our minimum rolled-up size */ widget_set(self, PG_WP_SIZE, 0); return success; }