def __init__(self, lsysargv, sysargv):
     self.dcol = 1
     self.on = 1
     xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0)
     pform = xfl.fl_bgn_form(xfl.FL_UP_BOX, 400, 400)
     pobj1 = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 320, 20, 40, 30, \
             "Exit")
     xfl.fl_set_object_callback(pobj1, self.done, 0)
     pobj2 = xfl.fl_add_free(xfl.FL_CONTINUOUS_FREE, 40, 80, 320, 280, \
             "", self.handle_free1)
     xfl.fl_end_form()
     depth  = xfl.fl_get_visual_depth()
     if depth < 4:   # Can't do it if less than 4 bit deep...
         print("This Demo requires a depth of at least 4 bits\n")
         xfl.fl_finish()
         sys.exit(1)
     elif depth > 7:     # ...but too large a depth also won't do
         depth = 7
     self.cole = (1 << depth) - 1
     if self.cole > 64:
         self.cole = 64
     pobj2.contents.u_ldata = col = xfl.FL_FREE_COL1
     self.cole += col
     for i in range(col, self.cole + 1):
         j =  255 * (i - col) / (self.cole - col)
         xfl.fl_mapcolor(i, j, j, j)
     xfl.fl_show_form(pform, xfl.FL_PLACE_CENTER, xfl.FL_NOBORDER, \
             "Free Object")
     xfl.fl_do_forms()
def main(lsysargv, sysargv):
    msg = "Fractal processing in progress (it will take some time before " \
            "you can close the window) ..."
    print(msg)
    xfl.fl_initialize(lsysargv, sysargv, "Fractals", None, 0)
    pform = xfl.fl_bgn_form(xfl.FL_DOWN_BOX, 635, 655)
    pbut = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 0, 0, 50, 25, "Close")
    xfl.fl_set_object_callback(pbut, close_cb, 0)
    pfree = xfl.fl_add_free(xfl.FL_NORMAL_FREE, 5, 35, 600, 600, "myfree", \
            drawing_cb)
    xfl.fl_end_form()
    xfl.fl_show_form(pform, xfl.FL_PLACE_CENTER, xfl.FL_FULLBORDER, \
            "Sierpinski's Triangle")
    xfl.fl_set_object_focus(pform, pbut)
    while xfl.fl_do_forms():
        pass
    sys.exit(0)
def create_form_drawfree():
    #gctx = xfl.fl_gc()       #xfl.fl_state[xfl.fl_get_vclass()].gc[0]
    #xfl.fl_set_background(gctx, xfl.FL_BLACK)
    fdui = FD_drawfree()
    fdui.drawfree = xfl.fl_bgn_form(xfl.FL_NO_BOX, 530, 490)
    pobj = xfl.fl_add_box(xfl.FL_UP_BOX, 0, 0, 530, 490, "")
    pobj = xfl.fl_add_frame(xfl.FL_DOWN_FRAME, 145, 30, 370, 405, "")
    xfl.fl_set_object_gravity(pobj, xfl.FL_NorthWest, xfl.FL_SouthEast)
    fdui.freeobj = xfl.fl_add_free(xfl.FL_NORMAL_FREE, 145, 30, \
            370, 405, "", freeobject_handler)
    xfl.fl_set_object_gravity(fdui.freeobj, xfl.FL_NorthWest, \
            xfl.FL_SouthEast)
    xfl.fl_set_object_color(fdui.freeobj, xfl.FL_WHITE, xfl.FL_BLACK)
    pobj = xfl.fl_add_checkbutton(xfl.FL_PUSH_BUTTON, 15, 25, 100, 35, \
            "Outline")
    xfl.fl_set_object_color(pobj, xfl.FL_MCOL, xfl.FL_BLUE)
    xfl.fl_set_object_gravity(pobj, xfl.FL_NorthWest, xfl.FL_NorthWest)
    xfl.fl_set_object_callback(pobj, fill_cb, 0)
    fdui.figgrp = xfl.fl_bgn_group()
    fdui.drobj[0] = xfl.fl_add_button(xfl.FL_RADIO_BUTTON, 10, 60, 40, \
            40, "@#circle")
    xfl.fl_set_object_lcol(fdui.drobj[0], xfl.FL_YELLOW)
    xfl.fl_set_object_callback(fdui.drobj[0], switch_object, 0)
    fdui.drobj[1] = xfl.fl_add_button(xfl.FL_RADIO_BUTTON, 50, 60, 40, \
            40, "@#square")
    xfl.fl_set_object_lcol(fdui.drobj[1], xfl.FL_YELLOW)
    xfl.fl_set_object_callback(fdui.drobj[1], switch_object, 1)
    fdui.drobj[2] = xfl.fl_add_button(xfl.FL_RADIO_BUTTON, 90, 60, 40, \
            40, "@#8>")
    xfl.fl_set_object_lcol(fdui.drobj[2], xfl.FL_YELLOW)
    xfl.fl_set_object_callback(fdui.drobj[2], switch_object, 2)
    xfl.fl_end_group()
    fdui.colgrp = xfl.fl_bgn_group()
    fdui.colorobj = xfl.fl_add_box(xfl.FL_BORDER_BOX, 25, 140, 90, 25, "")
    fdui.rsli = xfl.fl_add_slider(xfl.FL_VERT_FILL_SLIDER, 25, 170, \
            30, 125, "")
    xfl.fl_set_object_color(fdui.rsli, xfl.FL_COL1, xfl.FL_RED)
    xfl.fl_set_object_callback(fdui.rsli, change_color, 0)
    xfl.fl_set_object_return(fdui.rsli, xfl.FL_RETURN_CHANGED)
    fdui.gsli = xfl.fl_add_slider(xfl.FL_VERT_FILL_SLIDER, 55, 170, \
            30, 125, "")
    xfl.fl_set_object_color(fdui.gsli, xfl.FL_COL1, xfl.FL_GREEN)
    xfl.fl_set_object_callback(fdui.gsli, change_color, 1)
    xfl.fl_set_object_return(fdui.gsli, xfl.FL_RETURN_CHANGED)
    fdui.bsli = xfl.fl_add_slider(xfl.FL_VERT_FILL_SLIDER, 85, 170, \
            30, 125, "")
    xfl.fl_set_object_color(fdui.bsli, xfl.FL_COL1, xfl.FL_BLUE)
    xfl.fl_set_object_callback(fdui.bsli, change_color, 2)
    xfl.fl_set_object_return(fdui.bsli, xfl.FL_RETURN_CHANGED)
    xfl.fl_end_group()
    fdui.miscgrp = xfl.fl_bgn_group()
    pobj = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 420, 455, 105, 30, "Quit")
    xfl.fl_set_button_shortcut(pobj, "Qq#q", 1)
    pobj = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 280, 445, 105, \
            30, "Refresh")
    xfl.fl_set_object_callback(pobj, refresh_cb, 0)
    pobj = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 165, 445, 105, \
            30, "Clear")
    xfl.fl_set_object_callback(pobj, clear_cb, 0)
    xfl.fl_end_group()
    fdui.sizegrp = xfl.fl_bgn_group()
    fdui.hsli = xfl.fl_add_valslider(xfl.FL_HOR_SLIDER, 15, 410, 120, 25, \
            "Height")
    xfl.fl_set_object_lalign(fdui.hsli, xfl.FL_ALIGN_TOP)
    xfl.fl_set_object_callback(fdui.hsli, change_size, 1)
    xfl.fl_set_object_return(fdui.hsli, xfl.FL_RETURN_CHANGED)
    fdui.wsli = xfl.fl_add_valslider(xfl.FL_HOR_SLIDER, 15, 370, \
            120, 25, "Width")
    xfl.fl_set_object_lalign(fdui.wsli, xfl.FL_ALIGN_TOP)
    xfl.fl_set_object_callback(fdui.wsli, change_size, 0)
    xfl.fl_set_object_return(fdui.wsli, xfl.FL_RETURN_CHANGED)
    xfl.fl_end_group()
    xfl.fl_end_form()
    return fdui