/* * Copyright (c) 2014-2015, Claudio Lapilli and the newRPL Team * All rights reserved. * This file is released under the 3-clause BSD license. * See the file LICENSE.txt that shipped with this distribution. */ #include #include "libraries.h" #include void uiRepaintForm(DRAWSURFACE *scr) { // REPAINT VISIBLE PART OF A FORM UNUSED_ARGUMENT(scr); } // COMPUTE THE TOTAL DIMENSIONS OF A FORM // USED TO ALLOCATE THE FORM BITMAP void uiFormGetDimensions(WORDPTR form,BINT *width,BINT *height) { BINT w=0,h=0; BINT roww,rowh; WORDPTR item,end; if(!ISLIST(*form)) { if(width) *width=0; if(height) *height=0; return; } end=rplSkipOb(form); item=form+1; while(itemBitmapHeight; } if(ISLIST(*item)) { // A LIST OF COLUMNS int ncols=0,forced=0; roww=0; WORDPTR col=item+1,endcol=rplSkipOb(item); while(colw) w=roww; item=rplSkipOb(item); } if(width) *width=w; if(height) *height=h; } void uiUpdateForm(WORDPTR form) { // THE FORM IS A LIST OF ELEMENTS IN ROW ORDER // AN ELEMENT CAN BE ONLY 3 THINGS: TEXT, AN IDENT OR A LIST. ANY OF THESE ELEMENTS MIGHT BE PRECEDED BY AN INTEGER WITH THE ROW HEIGHT // ELEMENTS: // INTEGERS: AN INTEGER PROVIDES THE HEIGHT OF THE CURRENT ROW, THEN IT'S IGNORED // A ROW WITHOUT AN INTEGER NUMBER DEFAULTS TO THE FONT HEIGHT OF THE FORM (1 LINE) // TEXT: WILL BE OUTPUT LITERALLY ON THE FORM // IDENT: THE IDENTIFIER IS TREATED AS A FIELD NAME. SEVERAL RELATED IDENTIFIERS DEFINE A FIELD. // LIST: IF THE ROW IS A LIST, THEN ELEMENTS ARE LAID OUT IN COLUMNS FROM LEFT TO RIGHT // COLUMN ELEMENTS ARE THE SAME WAY, WHERE INTEGERS OPTIONALLY DEFINE THE WIDTH OF THE ITEM (DEFAULT TO EQUALLY SPACED) // PASS 1: COMPUTE TOTAL WIDTH AND HEIGHT if(!ISLIST(*form)) return; BINT formw,formh; uiFormGetDimensions(form,&formw,&formh); // ALLOCATE NEW BITMAP ScratchPointer1=form; WORDPTR newbmp=rplBmpCreate(DEFAULTBITMAPMODE,formw,formh,1); // ALLOCATE A NEW BITMAP AND CLEAR IT if(!newbmp) return; form=ScratchPointer1; // PASS 2: REDRAW EACH ELEMENT ONTO THE NEW BITMAP DRAWSURFACE backgnd; backgnd.addr=(int *)(newbmp+3); backgnd.width=formw; backgnd.x=0; backgnd.y=0; BINT ycoord=0; BINT roww,rowh,rowid=0; WORDPTR item,end; end=rplSkipOb(form); item=form+1; while(itemBitmapHeight; if(ISLIST(*item)) { // A LIST OF COLUMNS int ncols=0,forced=0; roww=0; WORDPTR col=item+1,endcol=rplSkipOb(item); BINT def_itemw,itemw; while(col