コード例 #1
0
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
コード例 #2
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
コード例 #3
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