def cb(self, pobj, data): self.cols[data] = xfl.fl_get_dial_value(pobj) xfl.fl_mapcolor(xfl.FL_FREE_COL1, self.cols[0], self.cols[1], \ self.cols[2]) xfl.fl_redraw_object(self.presult) strng = "%d" % self.cols[data] xfl.fl_set_object_label(self.ptexts[data], strng)
def change_color(pobj, which): global cur_fig cur_fig.c[which] = xfl.fl_get_slider_value(pobj) * 255.01 xfl.fl_mapcolor(cur_fig.col, cur_fig.c[0], cur_fig.c[1], cur_fig.c[2]) xfl.fl_mapcolor(xfl.FL_FREE_COL1, cur_fig.c[0], cur_fig.c[1], \ cur_fig.c[2]) xfl.fl_redraw_object(drawui.colorobj)
def color_callback(self, pobj, pvdata): ldata = xfl.fls_convert_ptrvoid_to_ptrlongc(pvdata).contents.value self.r = int(255 * xfl.fl_get_slider_value(self.predsl)) self.g = int(255 * xfl.fl_get_slider_value(self.pgreensl)) self.b = int(255 * xfl.fl_get_slider_value(self.pbluesl)) xfl.fl_mapcolor(xfl.FL_FREE_COL1, self.r, self.g, self.b) xfl.fl_redraw_object(self.pcolorobj)
def dial_callback(self, pobj, arg): clr = [0, 1, 2] for i in range(RED, BLUE + 1): clr[i] = xfl.fl_get_dial_value(self.pdial[i]) strng = "%d" % clr[arg] xfl.fl_set_object_label(self.ptext[arg], strng) xfl.fl_mapcolor(xfl.FL_FREE_COL1, clr[0], clr[1], clr[2]) xfl.fl_redraw_object(self.presult)
def init_colorpart(self): self.create_colorform() xfl.fl_set_form_callback(self.pcolorform, self.color_callback, 0) xfl.fl_set_form_position(self.pcolorform, 20, \ -300 - self.pcolorform.contents.h) xfl.fl_show_form(self.pcolorform, xfl.FL_PLACE_GEOMETRY, \ xfl.FL_TRANSIENT, "Color") xfl.fl_mapcolor(xfl.FL_FREE_COL1, self.r, self.g, self.b) xfl.fl_redraw_object(self.pcolorobj)
def handle_free1(self, pobj, event, mx, my, key, ev): if event == xfl.FL_DRAW: xfl.fl_rectf(pobj.contents.x, pobj.contents.y, pobj.contents.w, \ pobj.contents.h, pobj.contents.u_ldata) elif event == xfl.FL_RELEASE: self.on = not self.on elif event == xfl.FL_STEP: if self.on: if pobj.contents.u_ldata >= self.cole: self.dcol = -1 elif pobj.contents.u_ldata <= xfl.FL_FREE_COL1: self.dcol = 1 pobj.contents.u_ldata += self.dcol xfl.fl_redraw_object(pobj) return 0
def freeobject_handler(pobj, event, mx, my, key, pxev): #DrawFigure *dr; if event == xfl.FL_DRAW: if cur_fig.newfig == 1: cur_fig.drawit(cur_fig.fill, cur_fig.x + pobj.contents.x, \ cur_fig.y + pobj.contents.y, cur_fig.w, cur_fig.h, \ cur_fig.col) else: xfl.fl_drw_box(pobj.contents.boxtype, pobj.contents.x, \ pobj.contents.y, pobj.contents.w, pobj.contents.h, \ pobj.contents.col1, pobj.contents.bw) #for ( dr = saved_figure; dr < cur_fig; dr++ ) ndr = 0 for ndr in range(0, len(saved_figure)): if saved_figure[ndr] < cur_fig: saved_figure[ndr].drawit(saved_figure[ndr].fill, \ saved_figure[ndr].x + pobj.contents.x, \ saved_figure[ndr].y + pobj.contents.y, \ saved_figure[ndr].w, saved_figure[ndr].h, \ saved_figure[ndr].col) cur_fig.newfig = 0 elif event == xfl.FL_PUSH: if key != 2: cur_fig.x = mx - cur_fig.w / 2 cur_fig.y = my - cur_fig.h / 2 # convert position to relative to the free object cur_fig.x -= pobj.contents.x cur_fig.y -= pobj.contents.y cur_fig.newfig = 1 xfl.fl_redraw_object(pobj) #*(cur_fig+1) = *cur_fig; xfl.fl_mapcolor(cur_fig.col + 1, cur_fig.c[0], cur_fig.c[1], \ cur_fig.c[2]) #cur_fig++ #cur_fig.col++ #cur_fig.col += 1 ?? return 0
def color_change(self, pobj, data): c = [0] * 3 for i in range(0, 3): c[i] = xfl.fl_get_counter_value(self.pco[i]) xfl.fl_mapcolor(xfl.FL_FREE_COL1, c[0], c[1], c[2]) xfl.fl_redraw_object(self.presult)
def clear_cb(pobj, notused): global cur_fig #saved_figure[ 0 ] = *cur_fig; saved_figure[0] = cur_fig cur_fig = saved_figure[0] xfl.fl_redraw_object(drawui.freeobj)
def refresh_cb(pobj, which): xfl.fl_redraw_object(drawui.freeobj)