LONG variable as MUIA_Text_Content attribute. How?
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 306 from 2005/3/27
    From: Poland, Zdzies...
    I need to put MUIA_Clock_Hour attribute value, which is of LONG type, into a MUIA_Text_Contents attribute.
    MUIA_Text_Contents attiribute takes only STRPTR value type. Puting it in a straight way gives strange results.
    I tried to convert that value but I finally gave up.
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »24.09.13 - 07:58
    Profile
  • MorphOS Developer
    geit
    Posts: 1055 from 2004/9/23
    You could use MUIA_String_Integer, MUIV_TriggerValue as destination of your notification.

    Geit
  • »24.09.13 - 08:07
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 306 from 2005/3/27
    From: Poland, Zdzies...
    Didn't know I can use StringObject attribute as a TextObject attribute (?)
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »24.09.13 - 08:26
    Profile
  • MorphOS Developer
    geit
    Posts: 1055 from 2004/9/23
    Quote:

    r-tea wrote:
    Didn't know I can use StringObject attribute as a TextObject attribute (?)


    Well, you could simply create a non editable string gadget with text object look.

    Geit
  • »24.09.13 - 08:42
    Profile
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    Another solution, not involving trickery is to convert LONG to text and set it. As Text object creates internal copy of string passed, we can use a local variable for conversion. Assuming 'x' is a variable containing the value:

    Code:
    char buffer[12];    // LONG gives no more than 11 characters, so always fits

    NewRawDoFmt("%ld", RAWFMTFUNC_STRING, buffer, x);
    SetAttrs(obj, MUIA_Text_Contents, buffer, TAG_END);
  • »24.09.13 - 09:12
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 306 from 2005/3/27
    From: Poland, Zdzies...
    Quote:

    Krashan wrote:
    Code:
    NewRawDoFmt("%ld", RAWFMTFUNC_STRING, buffer, x);



    Where to find this function? Is it from standard C library? Should I include somethin extra?

    In the meanwhile I found that there is nice mui class called Numeric.mui, but I didn't managed to include it. Couldn't find where is the header of it to include. Found only NumericString_mcc.h and NumericList_mcc.h
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »24.09.13 - 09:29
    Profile
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    @r-tea:

    Where to find this function? Is it from standard C library? Should I include somethin extra?

    It is in exec.library, so you include <proto/exec.h> (which you probably already have in the code) and <exec/rawfmt.h> (for RAWFMTFUNC_STRING definition).

    In the meanwhile I found that there is nice mui class called Numeric.mui, but I didn't managed to include it.

    This is a built-in class. No need to include anything extra. By the way, Numeric class is an abstract class, it means one cannot create an instance of it, only of derived classes. Derived classes include Slider and NumericButton.
  • »24.09.13 - 10:11
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 306 from 2005/3/27
    From: Poland, Zdzies...
    Quote:

    Krashan wrote:
    @r-tea:

    Where to find this function? Is it from standard C library? Should I include somethin extra?

    It is in exec.library, so you include <proto/exec.h> (which you probably already have in the code) and <exec/rawfmt.h> (for RAWFMTFUNC_STRING definition).



    I had some problems to compile with this function, and I found another, and a way easiest solution.
    I use MUIM_SetAsString :-)
    Code:
    DoMethod(muiclock, MUIM_Notify, MUIA_Clock_Second, MUIV_EveryTime, tx_clock, 4, MUIM_SetAsString, MUIA_Text_Contents, "Secs: %ld", MUIV_TriggerValue);
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »24.09.13 - 14:25
    Profile