def main(lsysargv, sysargv): sc = 1.0 xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) ui = create_form_form() strng = "%.2f" % sc xfl.fl_set_input(ui.pscaleobj, strng) xfl.fl_show_form(ui.pform, xfl.FL_PLACE_CENTER | xfl.FL_FREE_SIZE, xfl.FL_FULLBORDER, "Scaling") while True: oldsc = sc pobj = xfl.fl_do_forms() if xfl.fl_is_same_object(pobj, ui.pexitobj): sys.exit(0) elif xfl.fl_is_same_object(pobj, ui.psmallerobj): sc = sc * 0.8 elif xfl.fl_is_same_object(pobj, ui.plargerobj): sc = sc / 0.8 elif xfl.fl_is_same_object(pobj, ui.pscaleobj): sc = float(xfl.fl_get_input(ui.pscaleobj)) if sc < 0.50: sc = 0.50 elif sc > 3: sc = 3 if sc != oldsc: xfl.fl_scale_form(ui.pform, sc / oldsc, sc / oldsc) xfl.fl_redraw_form(ui.pform) # to avoid garbage on screen strng = "%.2f" % sc xfl.fl_set_input(ui.pscaleobj, strng)
def setbitmapcursor_cb(self, pobj, data): if not self.pbitmapcur: self.pbitmapcur = xfl.fl_create_bitmap_cursor(bm1_bits, \ bm2_bits, bm1_width, bm1_height, bm1_width / 2, \ bm1_height / 2) xfl.fl_reset_cursor(xfl.FL_ObjWin(pobj)) # back to default xfl.fl_set_cursor(xfl.FL_ObjWin(pobj), self.pbitmapcur) xfl.fl_redraw_form(self.fd_cursor.cursor)
def boxtype_cb(self, pobj, arg): req_bt = (xfl.fl_get_select_item(pobj)).contents.val lastbt = -1 if lastbt != req_bt: xfl.fl_freeze_form(self.pform) xfl.fl_redraw_form(self.pform) for i in range(0, len(tobj)): xfl.fl_set_object_boxtype(tobj[i], btypes[req_bt]["val"]) xfl.fl_unfreeze_form(self.pform) lastbt = req_bt
def inside_cb(self, pobj, data): if xfl.fl_get_button(pobj): newalign = xfl.fl_get_object_lalign(self.fd_form0.box) newalign |= xfl.FL_ALIGN_INSIDE xfl.fl_set_object_lalign(self.fd_form0.box, newalign) else: newalign = xfl.fl_get_object_lalign(self.fd_form0.box) newalign &= ~xfl.FL_ALIGN_INSIDE xfl.fl_set_object_lalign(self.fd_form0.box, newalign) if TEST_PIXMAP_ALIGN: xfl.fl_set_pixmap_align(self.fd_form0.box, xfl.fl_get_object_lalign(self.fd_form0.box), 3, 3) else: xfl.fl_redraw_form(self.fd_form0.form0)
def inside_cb(self, pobj, data): align = xfl.fl_get_object_lalign(self.fd_form0.box) if xfl.fl_get_button(pobj): xfl.fl_set_object_lalign(self.fd_form0.box, \ xfl.fl_to_inside_lalign(align)) else: xfl.fl_set_object_lalign(self.fd_form0.box, \ xfl.fl_to_outside_lalign(align)) if TEST_PIXMAP_ALIGN: xfl.fl_set_pixmap_align(self.fd_form0.box, \ xfl.fl_get_object_lalign(self.fd_form0.box), 3, 3) else: xfl.fl_redraw_form(self.fd_form0.form0)
def fill_values_in_table(self): firstcellposx = initx + wcell firstcellposy = inity + hcell fontsize = xfl.FL_NORMAL_SIZE for row in range (0, len(row_headers)): for coln in range(0, len(coln_headers)): # set the size to fit text in cellvalue = table_values[row][coln] rightwidth = len(cellvalue)*10 if rightwidth < wcell: #mincellwidth[coln] cellwidth[coln] = wcell #mincellwidth[coln] fontsize = xfl.FL_NORMAL_SIZE elif rightwidth >= wcell: #mincellwidth[coln] cellwidth[coln] = rightwidth fontsize = xfl.FL_TINY_SIZE # fill cell with text ptxtcell = xfl.fl_add_text(xfl.FL_NORMAL_TEXT, \ (wcell*coln) + firstcellposx, \ (hcell*row) + firstcellposy, \ cellwidth[coln], hcell, cellvalue) #ptxtcell = xfl.fl_add_text(xfl.FL_NORMAL_TEXT, \ # table_relpos[row][coln][0] + firstcellposx, \ # table_relpos[row][coln][1] + firstcellposy, \ # cellwidth[coln], 25, table_values[row][coln]) xfl.fl_set_object_lcol(ptxtcell, xfl.FL_GREENYELLOW) xfl.fl_set_object_lstyle(ptxtcell, xfl.FL_FIXED_STYLE) xfl.fl_set_object_lsize(ptxtcell, fontsize) xfl.fl_set_object_resize(ptxtcell, xfl.FL_RESIZE_ALL) if cellvalue.isdigit(): xfl.fl_set_object_lalign(ptxtcell, xfl.FL_ALIGN_RIGHT) else: xfl.fl_set_object_lalign(ptxtcell, xfl.FL_ALIGN_LEFT) xfl.fl_adjust_form_size(self.pform) xfl.fl_redraw_form(self.pform)
def redrawit(self): xfl.fl_redraw_form(self.pcontrolform) for i in range(0, self.onumb): self.drawit(self.structob + i)