Exemplo n.º 1
0
def fl_stuff_clipboard(ptr_flobject, clipbdtype, datablock, size, \
        pyfn_LoseSelectionCb):
    """fl_stuff_clipboard(ptr_flobject, clipbdtype, datablock, size,
    pyfn_LoseSelectionCb) -> size

    Stores data in clipboard, read-write buffer shared by all applications
    running on the X server.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            clipboard flobject
        clipbdtype : long
            type of clipboard (not used)
        datablock : pointer to void?
            data contents to be stored (in str?) *todo*
        size : long
            size (in bytes) of the contents pointed to by datablock.
        pyfn_LoseSelectionCb : python function callback, returned unused value
            name referring to function(ptr_flobject, [long]type) -> [int]num.
            Function to be invoked if selection is lost; type is unused. For
            textual content the application that loses the clipboard should
            typically undo the visual cues about the selection.

    Returns
    -------
        size : int
            size of stuffed data?, or 0 (on failure)

    Examples
    --------
            >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_LOSE_SELECTION_CB = cty.CFUNCTYPE(cty.c_int, cty.POINTER( \
    #                       xfdata.FL_OBJECT), cty.c_long)
    _fl_stuff_clipboard = library.cfuncproto(
        library.load_so_libforms(), "fl_stuff_clipboard",
        cty.c_int, [cty.POINTER(xfdata.FL_OBJECT), cty.c_long, cty.c_void_p,
        cty.c_long, xfdata.FL_LOSE_SELECTION_CB],
        """int fl_stuff_clipboard(FL_OBJECT * ob, long int type,
           const char * data, long int size,
           FL_LOSE_SELECTION_CB lose_callback)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    l_clipbdtype = library.convert_to_longc(clipbdtype)
    ptr_vdata = cty.cast(datablock, cty.c_void_p)
    l_size = library.convert_to_longc(size)
    library.verify_function_type(pyfn_LoseSelectionCb)
    cfn_LoseSelectionCb = xfdata.FL_LOSE_SELECTION_CB(pyfn_LoseSelectionCb)
    library.keep_cfunc_refs(cfn_LoseSelectionCb, pyfn_LoseSelectionCb)
    library.keep_elem_refs(ptr_flobject, clipbdtype, datablock, size, \
            l_clipbdtype, ptr_vdata, l_size)
    retval = _fl_stuff_clipboard(ptr_flobject, l_clipbdtype, ptr_vdata, \
            l_size, cfn_LoseSelectionCb)
    return retval
def fl_add_canvas_handler(ptr_flobject, evtnum, pyfn_HandleCanvas, userdata):
    """fl_add_canvas_handler(ptr_flobject, evtnum, pyfn_HandleCanvas,
    userdata) -> HandleCnavas

    Defines a callback to be invoked in a canvas flobject for a specific
    X event.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            canvas flobject
        evtnum : int
            X event number. Values (from xfdata.py): Expose, KeyPress,
            KeyRelease, ButtonRelease, etc..
        pyfn_HandleCanvas : python function to handle canvas, returned value
            name referring to function(ptr_flobject, [long_pos]win,
            [int]width, [int]height, ptr_xevent, [pointer to void]pvdata)
            -> [int]num
        userdata : any type (e.g. None, int, str, etc..)
            user data to be passed to function; invoked callback has to take
            care of type check and re-cast from ptr_void to chosen type using
            appropriate xfstruct.fls_convert_ptrvoid_to_*() function

    Returns
    -------
        HandleCanvas : xfdata.FL_HANDLE_CANVAS
            old canvas handler function

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + Demo = OK

    """
    #FL_HANDLE_CANVAS = cty.CFUNCTYPE(cty.c_int, cty.POINTER(xfdata.FL_OBJECT),
    #       xfdata.Window, cty.c_int, cty.c_int, cty.POINTER(xfdata.XEvent),
    #       cty.c_void_p)
    _fl_add_canvas_handler = library.cfuncproto(
        library.load_so_libforms(), "fl_add_canvas_handler",
        xfdata.FL_HANDLE_CANVAS, [cty.POINTER(xfdata.FL_OBJECT), cty.c_int,
        xfdata.FL_HANDLE_CANVAS, cty.c_void_p],
        """FL_HANDLE_CANVAS fl_add_canvas_handler(FL_OBJECT * ob, int ev,
           FL_HANDLE_CANVAS h, void * udata)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    i_evtnum = library.convert_to_intc(evtnum)
    library.verify_function_type(pyfn_HandleCanvas)
    cfn_HandleCanvas = xfdata.FL_HANDLE_CANVAS(pyfn_HandleCanvas)
    ptr_vdata = library.convert_userdata_to_ptrvoid(userdata)
    library.keep_cfunc_refs(cfn_HandleCanvas, pyfn_HandleCanvas)
    library.keep_elem_refs(ptr_flobject, evtnum, userdata, i_evtnum, \
            ptr_vdata)
    retval = _fl_add_canvas_handler(ptr_flobject, i_evtnum, \
            cfn_HandleCanvas, ptr_vdata)
    return retval
Exemplo n.º 3
0
def fl_request_clipboard(ptr_flobject, clipbdtype, pyfn_SelectionCb):
    """fl_request_clipboard(ptr_flobject, clipbdtype, pyfn_SelectionCb)
    -> result

    Retrieves data previously stuffed into the clipboard. Contents is
    available in invoked callback function.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            clipboard flobject
        clipbdtype : long
            type of clipboard (not used)
        pyfn_SelectionCb : python function callback, returned value
            name referring to function(ptr_flobject, [long]type,
            [pointer to void]datablock, [long]size) -> [int]num.
            Function to be invoked when the clipboard content is obtained;
            type is unused. The content data passed to the callback
            function should not be modified.

    Returns
    -------
        result : int
            positive number (if the requesting flobject owns the selection,
            i.e. the callback could be invoked before the function returned),
            or 0 (if it does not own the selection), or -1 (if there is no
            selection)

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_SELECTION_CB = cty.CFUNCTYPE(cty.c_int, cty.POINTER(xfdata.FL_OBJECT),
    #                                cty.c_long, cty.c_void_p, cty.c_long)
    _fl_request_clipboard = library.cfuncproto(
        library.load_so_libforms(), "fl_request_clipboard",
        cty.c_int, [cty.POINTER(xfdata.FL_OBJECT), cty.c_long,
        xfdata.FL_SELECTION_CB],
        """int fl_request_clipboard(FL_OBJECT * ob, long int type,
           FL_SELECTION_CB got_it_callback)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    l_clipbdtype = library.convert_to_longc(clipbdtype)
    library.verify_function_type(pyfn_SelectionCb)
    cfn_SelectionCb = xfdata.FL_SELECTION_CB(pyfn_SelectionCb)
    library.keep_cfunc_refs(cfn_SelectionCb, pyfn_SelectionCb)
    library.keep_elem_refs(ptr_flobject, clipbdtype, l_clipbdtype)
    retval = _fl_request_clipboard(ptr_flobject, l_clipbdtype, \
            cfn_SelectionCb)
    return retval
Exemplo n.º 4
0
def fl_set_timer_filter(ptr_flobject, pyfn_TimerFilter):
    """fl_set_timer_filter(ptr_flobject, pyfn_TimerFilter) -> TimerFilter

    Defines a function to change the way the time is presented in
    xfdata.FL_VALUE_TIMER. By default, it gives the time in a
    hour:minutes:seconds.fraction format

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            timer flobject
        pyfn_TimerFilter : python callback function, returned value
            name referring to function(ptr_flobject, [float]totalsecs)
            -> [str]time
            Param totalsecs is time left for count-down timers and the
            elapsed time for up-counting timers (in units of seconds).
            It gives textual formatted representation of time.

    Returns
    -------
        TimerFilter : pointer to xfdata.FL_TIMER_FILTER
            old timer filter function

    Examples
    --------
        >>> def timefiltcb(pobj, elapsedsecs):
        >>> ... <something>
        >>> ... return fmtnewstr
        >>> oldtimerfunc = fl_set_timer_filter(ptimerobj, timefiltcb)

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_TIMER_FILTER = cty.CFUNCTYPE(xfdata.STRING,
    #           cty.POINTER(xfdata.FL_OBJECT), cty.c_double)
    _fl_set_timer_filter = library.cfuncproto(
        library.load_so_libforms(), "fl_set_timer_filter",
        xfdata.FL_TIMER_FILTER, [cty.POINTER(xfdata.FL_OBJECT),
        xfdata.FL_TIMER_FILTER],
        """FL_TIMER_FILTER fl_set_timer_filter(FL_OBJECT * ob,
           FL_TIMER_FILTER filter)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_function_type(pyfn_TimerFilter)
    cfn_TimerFilter = xfdata.FL_TIMER_FILTER(pyfn_TimerFilter)
    library.keep_cfunc_refs(cfn_TimerFilter, pyfn_TimerFilter)
    library.keep_elem_refs(ptr_flobject)
    retval = _fl_set_timer_filter(ptr_flobject, cfn_TimerFilter)
    return retval
def fl_add_button_class(btnclass, pyfn_DrawButton, pyfn_CleanupButton):
    """fl_add_button_class(btnclass, pyfn_DrawButton, pyfn_CleanupButton)

    Associates a button class with a drawing function.

    Parameters
    ----------
        btnclass : int
            value of a new button class
        pyfn_DrawButton : python function, no return
            name referring to function(ptr_flobject)
            function to handle drawing of button
        pyfn_CleanupButton : python function, no return
            name referring to function(ptr_buttonspec)
            function to cleanup button. The param is an instance of
            xfdata.FL_BUTTON_SPEC class

    Examples
    --------
        >>> def drawbtn(pobj):
        >>> ... <something>
        >>> def cleanbtn(pbuttonspec):
        >>> ... <something>
        >>> fl_add_button_class(1001, drawbtn, cleanbtn)

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_DrawButton = cty.CFUNCTYPE(None, cty.POINTER(xfdata.FL_OBJECT))
    #FL_CleanupButton = cty.CFUNCTYPE(None, cty.POINTER(xfdata.FL_BUTTON_SPEC))
    _fl_add_button_class = library.cfuncproto(
        library.load_so_libforms(), "fl_add_button_class",
        None, [cty.c_int, xfdata.FL_DrawButton, xfdata.FL_CleanupButton],
        """void fl_add_button_class(int bclass, FL_DrawButton drawit,
           FL_CleanupButton cleanup)""")
    library.check_if_flinitialized()
    i_btnclass = library.convert_to_intc(btnclass)
    library.verify_function_type(pyfn_DrawButton)
    cfn_DrawButton = xfdata.FL_DrawButton(pyfn_DrawButton)
    library.verify_function_type(pyfn_CleanupButton)
    cfn_CleanupButton = xfdata.FL_CleanupButton(pyfn_CleanupButton)
    library.keep_cfunc_refs(cfn_DrawButton, pyfn_DrawButton, \
            cfn_CleanupButton, pyfn_CleanupButton)
    library.keep_elem_refs(btnclass, i_btnclass)
    _fl_add_button_class(i_btnclass, cfn_DrawButton, cfn_CleanupButton)
def fl_remove_canvas_handler(ptr_flobject, evtnum, pyfn_HandleCanvas):
    """fl_remove_canvas_handler(ptr_flobject, evtnum, pyfn_HandleCanvas)

    Removes a particular handler for a specified X event, previously
    created with fl_add_canvas_handler().

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            canvas flobject
        evtnum : int
            X event number. Values (from xfdata.py): Expose, KeyPress,
            KeyRelease, ButtonRelease, etc.. If it is invalid, removes all
            handlers and their corresponding event mask.
        pyfn_HandleCanvas : python function to handle canvas, returned value
            name referring to function(ptr_flobject, [long_pos]win,
            [int]width, [int]height, ptr_xevent, [pointer to void]vdata)
            -> [int]num

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + Demo = OK

    """
    #FL_HANDLE_CANVAS = cty.CFUNCTYPE(cty.c_int, cty.POINTER(xfdata.FL_OBJECT),
    #                             xfdata.Window, cty.c_int, cty.c_int,
    #                             cty.POINTER(xfdata.XEvent), cty.c_void_p)
    _fl_remove_canvas_handler = library.cfuncproto(
        library.load_so_libforms(), "fl_remove_canvas_handler",
        None, [cty.POINTER(xfdata.FL_OBJECT), cty.c_int,
        xfdata.FL_HANDLE_CANVAS],
        """void fl_remove_canvas_handler(FL_OBJECT * ob, int ev,
           FL_HANDLE_CANVAS h)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    i_evtnum = library.convert_to_intc(evtnum)
    library.verify_function_type(pyfn_HandleCanvas)
    cfn_HandleCanvas = xfdata.FL_HANDLE_CANVAS(pyfn_HandleCanvas)
    library.keep_cfunc_refs(cfn_HandleCanvas, pyfn_HandleCanvas)
    library.keep_elem_refs(ptr_flobject, evtnum, i_evtnum)
    _fl_remove_canvas_handler(ptr_flobject, i_evtnum, cfn_HandleCanvas)
def fl_set_dirlist_filter(pyfn_DirFilter):
    """fl_set_dirlist_filter(pyfn_DirFilter) -> DirFilter

    Changes the default filter by which file types are returned.
    By default not all types of files are returned (only directories,
    normal files and link files).

    Parameters
    ----------
        pyfn_DirFilter : python function, returned value
            name referring to function ([str]name, [int]type) -> (non-zero if
            is to be included, 0 otherwise)
            Function used to filter types

    Returns
    -------
        DirFilter : xfdata.FL_DIRLIST_FILTER class instance
            old dirlist filter function

    Examples
    --------
        >>> def dirfiltercb(fname, ftype):
        >>> ... return (ftype == xfdata.FT_DIR || ftype == xfdata.FT_FILE ||
        >>>     ftype == xfdata.FT_SOCK || ftype == xfdata.FT_FIFO ||
        >>>     ftype == xfdata.FT_LINK || ftype == xfdata.FT_BLK ||
        >>>     ftype == xfdata.FT_CHR || type == xfdata.FT_OTHER)
        >>> olddirfiltfunc = fl_set_dirlist_filter(dirfiltercb)

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_DIRLIST_FILTER = cty.CFUNCTYPE(cty.c_int, xfdata.STRING, cty.c_int)
    _fl_set_dirlist_filter = library.cfuncproto(
        library.load_so_libforms(), "fl_set_dirlist_filter",
        xfdata.FL_DIRLIST_FILTER, [xfdata.FL_DIRLIST_FILTER],
        """FL_DIRLIST_FILTER fl_set_dirlist_filter( \
           FL_DIRLIST_FILTER filter)""")
    library.check_if_flinitialized()
    library.verify_function_type(pyfn_DirFilter)
    cfn_DirFilter = xfdata.FL_DIRLIST_FILTER(pyfn_DirFilter)
    library.keep_cfunc_refs(cfn_DirFilter, pyfn_DirFilter)
    retval = _fl_set_dirlist_filter(cfn_DirFilter)
    return retval
def fl_set_counter_filter(ptr_flobject, pyfn_ValFilter):
    """fl_set_counter_filter(ptr_flobject, pyfn_ValFilter)

    Overrides the format and value shown by the counter. By default the
    value is shown in floating point format.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            counter flobject
        pyfn_ValFilter : python callback function, returned value
            name referring to function(ptr_flobject, [float]value, [int]precis)
            -> str

    Examples
    --------
        >>> def cvalfiltcb(pobj, fvalue, prec):
        >>> ... <something>
        >>> ... return string
        >>> fl_set_counter_filter(ctrobj, cvalfiltcb)

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_VAL_FILTER = cty.CFUNCTYPE(xfdata.STRING, \
    #           cty.POINTER(xfdata.FL_OBJECT), cty.c_double, cty.c_int)
    _fl_set_counter_filter = library.cfuncproto(
        library.load_so_libforms(), "fl_set_counter_filter",
        None, [cty.POINTER(xfdata.FL_OBJECT), xfdata.FL_VAL_FILTER],
        """void fl_set_counter_filter(FL_OBJECT * ob,
           FL_VAL_FILTER filter)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_function_type(pyfn_ValFilter)
    cfn_ValFilter = xfdata.FL_VAL_FILTER(pyfn_ValFilter)
    library.keep_cfunc_refs(cfn_ValFilter, pyfn_ValFilter)
    library.keep_elem_refs(ptr_flobject)
    _fl_set_counter_filter(ptr_flobject, cfn_ValFilter)
def fl_set_slider_filter(ptr_flobject, pyfn_ValFilter):
    """fl_set_slider_filter(ptr_flobject, pyfn_ValFilter)

    Registers a filter function to show values in a slider flobject. By
    default, slider value shown in floating point format.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            slider flobject
        pyfn_ValFilter : python function, returned value
            name referring to function(ptr_flobject, [float]value,
            [int]precis) -> [str]text
            function to show values in slider, text is what will be shown

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    # FL_VAL_FILTER = cty.CFUNCTYPE(xfdata.STRING, cty.POINTER(FL_OBJECT),
    #            cty.c_double, cty.c_int)
    _fl_set_slider_filter = library.cfuncproto(
        library.load_so_libforms(), "fl_set_slider_filter",
        None, [cty.POINTER(xfdata.FL_OBJECT), xfdata.FL_VAL_FILTER],
        """void fl_set_slider_filter(FL_OBJECT * ob, FL_VAL_FILTER filter)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_function_type(pyfn_ValFilter)
    cfn_ValFilter = xfdata.FL_VAL_FILTER(pyfn_ValFilter)
    library.keep_cfunc_refs(cfn_ValFilter, pyfn_ValFilter)
    library.keep_elem_refs(ptr_flobject)
    _fl_set_slider_filter(ptr_flobject, cfn_ValFilter)
Exemplo n.º 10
0
def fl_modify_canvas_prop(ptr_flobject, pyfn_initModifyCanvasProp,
            pyfn_activateModifyCanvasProp, pyfn_cleanupModifyCanvasProp):
    """fl_modify_canvas_prop(ptr_flobject, pyfn_initModifyCanvasProp,
    pyfn_activateModifyCanvasProp, pyfn_cleanupModifyCanvasProp)

    Modifies init, activate and cleanup handler properties of a canvas
    flobject.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            canvas flobject
        pyfn_initModifyCanvasProp : python function callback, returned value
            name referring to function(ptr_flobject) -> [int]num
        pyfn_activateModifyCanvasProp : python func. callback, returned value
            name referring to function(ptr_flobject) -> [int]num.
        pyfn_cleanupModifyCanvasProp : python func. callback, returned value
            name referring to function(ptr_flobject) -> [int]num.

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    #FL_MODIFY_CANVAS_PROP = cty.CFUNCTYPE(cty.c_int,
    #                              cty.POINTER(xfdata.FL_OBJECT))
    _fl_modify_canvas_prop = library.cfuncproto(
        library.load_so_libforms(), "fl_modify_canvas_prop",
        None, [cty.POINTER(xfdata.FL_OBJECT), xfdata.FL_MODIFY_CANVAS_PROP,
        xfdata.FL_MODIFY_CANVAS_PROP, xfdata.FL_MODIFY_CANVAS_PROP],
        """void fl_modify_canvas_prop(FL_OBJECT * obj,
           FL_MODIFY_CANVAS_PROP init, FL_MODIFY_CANVAS_PROP activate,
           FL_MODIFY_CANVAS_PROP cleanup)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_function_type(pyfn_initModifyCanvasProp)
    cfn_initModifyCanvasProp = xfdata.FL_MODIFY_CANVAS_PROP( \
            pyfn_initModifyCanvasProp)
    library.verify_function_type(pyfn_activateModifyCanvasProp)
    cfn_activateModifyCanvasProp = xfdata.FL_MODIFY_CANVAS_PROP( \
                pyfn_activateModifyCanvasProp)
    library.verify_function_type(pyfn_cleanupModifyCanvasProp)
    cfn_cleanupModifyCanvasProp = xfdata.FL_MODIFY_CANVAS_PROP( \
                pyfn_cleanupModifyCanvasProp)
    library.keep_cfunc_refs(cfn_initModifyCanvasProp, \
            pyfn_initModifyCanvasProp, cfn_activateModifyCanvasProp, \
            pyfn_activateModifyCanvasProp, cfn_cleanupModifyCanvasProp, \
            pyfn_cleanupModifyCanvasProp)
    library.keep_elem_refs(ptr_flobject)
    _fl_modify_canvas_prop(ptr_flobject, cfn_initModifyCanvasProp,
            cfn_activateModifyCanvasProp, cfn_cleanupModifyCanvasProp)
Exemplo n.º 11
0
def fl_replace_nmenu_item(ptr_flobject, ptr_flpopupentry, entryitemstxt,
            x=None, u=None, f=None, E=None, L=None, m=None, Rr=None, s=None):
    """fl_replace_nmenu_item(ptr_flobject, ptr_flpopupentry, entryitemstxt,
    x=None, u=None, f=None, E=None, L=None, m=None, Rr=None, s=None)
    -> ptr_flpopupentry

    Replaces an existing item of a nmenu flobject with another. If additional
    separated arguments are required by in-text special sequences, user must
    respect the same sequences' order.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            nmenu flobject
        ptr_flpopupentry : pointer to xfdata.FL_POPUP_ENTRY
            old popup entry to be replaced
        entryitemstxt : str
            text of the entry to be replaced and in-text special sequences
            with or without not separated additional arguments (if required).
            Text may contain "|" for more than one entry newline character
            which allows to create entries that span more than a single line.
            Special sequences who are allowed are: %x, %u, %f, %E, %L, %m or
            %T or %t, %R or %r or %l, %d, %h, %S, %s, %%. Special sequences of
            same type cannot be repeated in xforms-python.
        x : long
            numeric data to be passed to callbacks for entry (separated
            additional argument corresponding to %x in-text special sequence)
        u : pointer to any type
            user data to be passed to callbacks for entry; invoked callback
            has to take care of type check and re-cast ptr_void to chosen type
            using appropriate xfstruct.fls_convert_ptrvoid_to_* function (separated
            additional argument corresponding to %u in-text special sequence)
        f : python callback function, returned value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on set (separated additional argument
            corresponding to %f in-text special sequence)
        E : python callback function, returned unused value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on enter (separated additional argument
            corresponding to %E in-text special sequence)
        L : python callback function, returned unused value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on leave (separated additional argument
            corresponding to %L in-text special sequence)
        m : pointer to xfdata.FL_POPUP
            popup class to be used as sub-popup (separated additional argument
            corresponding to %m in-text special sequence)
        Rr : int
            group number of a radio entry type (separated additional argument
            corresponding to %R or %r in-text special sequence)
        s : str
            shortcut text for the entry (separated additional argument
            corresponding to %s in-text special sequence)

    Returns
    -------
        ptr_flpopupentry : pointer to xfdata.FL_POPUP_ENTRY
            popup entry

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + Demo = OK
        See: Special sequences in entry text documentation in xfdata.py.

    """
    # managing additional separate parameters
    l_x = ptr_u = cfn_f = cfn_E = cfn_L = i_Rr = s_s = None
    cparam_argstypelist = []
    specseqargslist = []
    if x:       # long x additional arg
        l_x = library.convert_to_longc(x)
        cparam_argstypelist.append(cty.c_long)
        specseqargslist.append(l_x)
    if u:       # pointer to void u additional arg
        ptr_u = library.convert_userdata_to_ptrvoid(u)
        cparam_argstypelist.append(cty.c_void_p)
        specseqargslist.append(ptr_u)
    if f:       # xfdata.FL_POPUP_CB f additional arg
        library.verify_function_type(f)
        cfn_f = xfdata.FL_POPUP_CB(f)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_f)
    if E:       # xfdata.FL_POPUP_CB E additional arg
        library.verify_function_type(E)
        cfn_E = xfdata.FL_POPUP_CB(E)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_E)
    if L:       # xfdata.FL_POPUP_CB L additional arg
        library.verify_function_type(L)
        cfn_L = xfdata.FL_POPUP_CB(L)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_L)
    if m:       # pointer to xfdata.FL_POPUP m additional arg
        library.verify_flpopupptr_type(m)
        # passed as is
        cparam_argstypelist.append(cty.POINTER(xfdata.FL_POPUP))
        specseqargslist.append(m)
    if Rr:      # int R or r additional arg
        i_Rr = library.convert_to_intc(Rr)
        cparam_argstypelist.append(cty.c_int)
        specseqargslist.append(i_Rr)
    if s:      # str s additional arg
        s_s = library.convert_to_bytestrc(s)
        cparam_argstypelist.append(cty.c_char_p)
        specseqargslist.append(s_s)

    if not cparam_argstypelist:     # no additional separate params
        cparam_argstypelist = [cty.c_char_p, cty.c_char_p]
        specseqargslist = [b"", b""]
    elif len(cparam_argstypelist) < 2:  # just 1 param, add another
        cparam_argstypelist.append(cty.c_char_p)
        specseqargslist.append(b"")

    _fl_replace_nmenu_item = library.cfuncproto(
        library.load_so_libforms(), "fl_replace_nmenu_item",
        cty.POINTER(xfdata.FL_POPUP_ENTRY), [cty.POINTER(xfdata.FL_OBJECT),
        cty.POINTER(xfdata.FL_POPUP_ENTRY), xfdata.STRING, \
        cparam_argstypelist],
        """FL_POPUP_ENTRY * fl_replace_nmenu_item(FL_OBJECT * p1,
           FL_POPUP_ENTRY * p2, const char * p3, ...)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_flpopupentryptr_type(ptr_flpopupentry)
    s_entryitemstxt = library.convert_to_bytestrc(entryitemstxt)
    library.keep_elem_refs(ptr_flobject, ptr_flpopupentry, entryitemstxt, \
            s_entryitemstxt, specseqargslist, cparam_argstypelist, x, u, f, \
            E, L, m, Rr, s, l_x, ptr_u, cfn_f, cfn_E, cfn_L, i_Rr, s_s)
    retval = _fl_replace_nmenu_item(ptr_flobject, ptr_flpopupentry, \
            s_entryitemstxt, *specseqargslist)
    return retval
Exemplo n.º 12
0
def fl_add_free(freetype, xpos, ypos, width, height, label, pyfn_HandlePtr):
    """fl_add_free(freetype, xpos, ypos, width, height, label, pyfn_HandlePtr)
    -> ptr_flobject

    Adds a free object.

    Parameters
    ----------
        freetype : int
            type of free to be added. Value (from xfdata.py)
            - FL_NORMAL_FREE (The flobject will receive the events FL_DRAW,
              FL_ENTER, FL_LEAVE, FL_MOTION, FL_PUSH, FL_RELEASE and FL_MOUSE),
            - FL_INACTIVE_FREE or FL_SLEEPING_FREE (The flobject only receives
              FL_DRAW events. This should be used for flobjects without
              interaction, e.g. a picture),
            - FL_INPUT_FREE (Same as FL_NORMAL_FREE but the flobject also
              receives FL_FOCUS, FL_UNFOCUS and FL_KEYBOARD events. The
              ptr_flobject.contents.wantkey is by default set to FL_KEY_NORMAL,
              i.e., the free flobject will receive all normal keys (0-255)
              except <Tab> and <Return> key. If you are interested in <Tab> or
              <Return> key, you need to change ptr_flobject.contents.wantkey
              to FL_KEY_TAB or FL_KEY_ALL),
            - FL_CONTINUOUS_FREE (Same as FL_NORMAL_FREE but the flobject also
              receives FL_STEP events. This should be used for flobjects that
              change themselves continuously),
            - FL_ALL_FREE (The flobject receives all types of events).
        xpos : int
            horizontal position (upper-left corner)
        ypos : int
            vertical position (upper-left corner)
        width : int
            width in coord units
        height : int
            height in coord units
        label : str
            text label of free
        pyfn_HandlePtr : python function, returned value
            name referring to function(ptr_flobject, [int]event, [int]xpos,
            [int]ypos, [int]key, [pointer to void]ptr_xevent) -> [int]num
            Function does the redrawing and handles the interaction with the
            free flobject. First param is the flobject to which the event
            applies; event indicates what has to happen to the object; xpos
            and ypos indicate the position of the mouse (only meaningful with
            mouse related events) relative to the form origin; key is the
            KeySym of the key typed in by the user (only for xfdata.FL_KEYPRESS
            events). ptr_xevent is pointer to X Event that causes the
            invocation of this handler. event and ptr_xevent.contents.type can
            both be used to obtain the event types. The routine should return
            whether the status of the object has changed, i.e., whether
            flbasic.fl_do_forms() or flbasic.fl_check_forms() should return
            this flobject.

    Returns
    -------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            free flobject added

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + Demo = OK

    """
    #FL_HANDLEPTR = cty.CFUNCTYPE(cty.c_int, cty.POINTER(FL_OBJECT), \
    #   cty.c_int, FL_Coord, FL_Coord, cty.c_int, cty.c_void_p)
    _fl_add_free = library.cfuncproto(
        library.load_so_libforms(), "fl_add_free",
        cty.POINTER(xfdata.FL_OBJECT), [cty.c_int, xfdata.FL_Coord,
        xfdata.FL_Coord, xfdata.FL_Coord, xfdata.FL_Coord, xfdata.STRING,
        xfdata.FL_HANDLEPTR],
        """FL_OBJECT * fl_add_free(int type, FL_Coord x, FL_Coord y,
           FL_Coord w, FL_Coord h, const char * label, FL_HANDLEPTR handle)""")
    library.check_if_flinitialized()
    library.checkfatal_allowed_value_in_list(freetype, xfdata.FREETYPE_list)
    i_freetype = library.convert_to_intc(freetype)
    i_xpos = library.convert_to_FL_Coord(xpos)
    i_ypos = library.convert_to_FL_Coord(ypos)
    i_width = library.convert_to_FL_Coord(width)
    i_height = library.convert_to_FL_Coord(height)
    s_label = library.convert_to_bytestrc(label)
    library.verify_function_type(pyfn_HandlePtr)
    cfn_HandlePtr = xfdata.FL_HANDLEPTR(pyfn_HandlePtr)
    library.keep_cfunc_refs(cfn_HandlePtr, pyfn_HandlePtr)
    library.keep_elem_refs(freetype, xpos, ypos, width, height, label, \
            i_freetype, i_xpos, i_ypos, i_width,i_height, s_label)
    retval = _fl_add_free(i_freetype, i_xpos, i_ypos, i_width, i_height, \
            s_label, cfn_HandlePtr)
    return retval
Exemplo n.º 13
0
def fl_insert_select_items(ptr_flobject, ptr_flpopupentry, entryitemstxt, \
        x=None, u=None, f=None, E=None, L=None, s=None):
    """fl_insert_select_items(ptr_flobject, ptr_flpopupentry, entryitemstxt,
    x=None, u=None, f=None, E=None, L=None, s=None)
    -> ptr_flpopupentry

    Inserts a new item somewhere in the middle of a list of already existing
    items (it can be used several times). If additional separated arguments
    are required by in-text special sequences, user must respect the same
    sequences' order.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            select flobject
        ptr_flpopupentry : pointer to xfdata.FL_POPUP_ENTRY
            popup entry. If it is None new items are inserted at the real start
        entryitemstxt : str
            text of the entry to be inserted and in-text special sequences
            with or without not separated additional arguments (if required).
            Text may contain "|" for more than one entry and newline character
            which allows to create entries that span more than a single line.
            Only some special sequences are allowed: %x, %u, %f, %E, %L, %d,
            %h, %S, %s, %% (other combinations do not make sense here). Special
            sequences of same type cannot be repeated in xforms-python.
        x : long
            numeric data to be passed to callbacks for entry (separated
            additional argument corresponding to %x in-text special sequence)
        u : pointer to any type
            user data to be passed to callbacks for entry; invoked callback
            has to take care of type check and re-cast ptr_void to chosen type
            using appropriate xfstruct.fls_convert_ptrvoid_to_* function (separated
            additional argument corresponding to %u in-text special sequence)
        f : python callback function, returned value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on set (separated additional argument
            corresponding to %f in-text special sequence)
        E : python callback function, returned unused value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on enter (separated additional argument
            corresponding to %E in-text special sequence)
        L : python callback function, returned unused value
            name referring to function(ptr_flpopupreturn) -> int
            function to be invoked on leave (separated additional argument
            corresponding to %L in-text special sequence)
        s : str
            shortcut text for the entry (separated additional argument
            corresponding to %s in-text special sequence)

    Returns
    -------
        ptr_flpopupentry : pointer to xfdata.FL_POPUP_ENTRY
            popup entry, or None (on failure)

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + Demo = OK
        See: Special sequences in entry text documentation in xfdata.py.

    """
    # managing additional separate parameters
    l_x = ptr_u = cfn_f = cfn_E = cfn_L = s_s = None
    cparam_argstypelist = []
    specseqargslist = []
    if x:       # long x additional arg
        l_x = library.convert_to_longc(x)
        cparam_argstypelist.append(cty.c_long)
        specseqargslist.append(l_x)
    if u:       # pointer to void u additional arg
        ptr_u = library.convert_userdata_to_ptrvoid(u)
        cparam_argstypelist.append(cty.c_void_p)
        specseqargslist.append(ptr_u)
    if f:       # xfdata.FL_POPUP_CB f additional arg
        library.verify_function_type(f)
        cfn_f = xfdata.FL_POPUP_CB(f)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_f)
    if E:       # xfdata.FL_POPUP_CB E additional arg
        library.verify_function_type(E)
        cfn_E = xfdata.FL_POPUP_CB(E)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_E)
    if L:       # xfdata.FL_POPUP_CB L additional arg
        library.verify_function_type(L)
        cfn_L = xfdata.FL_POPUP_CB(L)
        cparam_argstypelist.append(xfdata.FL_POPUP_CB)
        specseqargslist.append(cfn_L)
    if s:      # str s additional arg
        s_s = library.convert_to_bytestrc(s)
        cparam_argstypelist.append(cty.c_char_p)
        specseqargslist.append(s_s)

    if not cparam_argstypelist:     # no additional separate params
        cparam_argstypelist = [cty.c_char_p, cty.c_char_p]
        specseqargslist = [b"", b""]
    elif len(cparam_argstypelist) < 2:  # just 1 param, add another
        cparam_argstypelist.append(cty.c_char_p)
        specseqargslist.append(b"")

    _fl_insert_select_items = library.cfuncproto(
        library.load_so_libforms(), "fl_insert_select_items",
        cty.POINTER(xfdata.FL_POPUP_ENTRY), [cty.POINTER(xfdata.FL_OBJECT),
        cty.POINTER(xfdata.FL_POPUP_ENTRY), xfdata.STRING,
        cparam_argstypelist],
        """FL_POPUP_ENTRY * fl_insert_select_items(FL_OBJECT * p1,
           FL_POPUP_ENTRY * p2, const char * p3, ...)""")
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_flpopupentryptr_type(ptr_flpopupentry)
    s_entryitemstxt = library.convert_to_bytestrc(entryitemstxt)
    library.keep_elem_refs(ptr_flobject, ptr_flpopupentry, entryitemstxt, \
            s_entryitemstxt, specseqargslist, cparam_argstypelist, x, u, \
            f, E, L, s, l_x, ptr_u, cfn_f, cfn_E, cfn_L, s_s)
    retval = _fl_insert_select_items(ptr_flobject, ptr_flpopupentry, \
            s_entryitemstxt, *specseqargslist)
    return retval
Exemplo n.º 14
0
def fl_set_input_filter(ptr_flobject, pyfn_InputValidator):
    """fl_set_input_filter(ptr_flobject, pyfn_InputValidator) -> InputValidator

    Defines up a validator function, that is is called whenever a new
    (regular) character is entered.

    Parameters
    ----------
        ptr_flobject : pointer to xfdata.FL_OBJECT
            input flobject
        pyfn_InputValidator : python function, returned value
            name referring to function(ptr_flobject, [str]oldtxt, [str]curtxt,
            [int]newchar) -> [int]oldfilt
            function to set validator is called whenever a new (regular)
            character is entered. oldtxt is the str text in the input field
            before the newly typed character newchar (in ordinal form) was
            added to form the new str text curtxt. If the new character is not
            an acceptable character for the input field, the function should
            return xfdata.FL_INVALID otherwise xfdata.FL_VALID. If
            xfdata.FL_INVALID is returned, the new character is discarded and
            the input field remains unmodified. The function returns the old
            filter. While the built-in filters also sound the keyboard bell,
            this does not happen if a custom filter only returns
            xfdata.FL_INVALID; to also sound the keyboard bell you can
            logically OR it with (from xfdata.py) FL_INVALID|FL_RINGBELL. This
            still leaves the possibility that the input is valid for every
            character entered, but the string is invalid for the field because
            it is incomplete. E.g. 12.0e is valid for a float input field for
            every character typed, but the final string is not a valid floating
            point number. To guard against this, the filter function is also
            called just prior to returning the flobject with the argument
            newchar (for the newly entered character) set to zero. If the
            validator returns xfdata.FL_INVALID the flobject is not returned
            to the application program, but input focus can change to the next
            input field. If the return value is (from xfdata.py)
            FL_INVALID|FL_RINGBELL, the keyboard bell is sounded and the
            flobject is not returned to the application program and the input
            focus remains in the flobject.

    Returns
    -------
        InputValidator : xfdata.FL_INPUTVALIDATOR
            old filter function for input

    Examples
    --------
        >>> *todo*

    Notes
    -----
        Status: NA-UTest + Doc + NoDemo = Maybe

    """
    # FL_INPUTVALIDATOR = cty.CFUNCTYPE(cty.c_int, cty.POINTER( \
    #           xfdata.FL_OBJECT), xfdata.STRING, xfdata.STRING, cty.c_int)
    _fl_set_input_filter = library.cfuncproto(
        library.load_so_libforms(),
        "fl_set_input_filter",
        xfdata.FL_INPUTVALIDATOR,
        [cty.POINTER(xfdata.FL_OBJECT), xfdata.FL_INPUTVALIDATOR],
        """FL_INPUTVALIDATOR fl_set_input_filter(FL_OBJECT * ob,
            FL_INPUTVALIDATOR validate)""",
    )
    library.check_if_flinitialized()
    library.verify_flobjectptr_type(ptr_flobject)
    library.verify_function_type(pyfn_InputValidator)
    cfn_InputValidator = xfdata.FL_INPUTVALIDATOR(pyfn_InputValidator)
    library.keep_cfunc_refs(cfn_InputValidator, pyfn_InputValidator)
    library.keep_elem_refs(ptr_flobject)
    retval = _fl_set_input_filter(ptr_flobject, cfn_InputValidator)
    return retval