Little help? Bumpy transition to modernity...
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    I'd like to be able to present this cpu information as neatly with MUI as in the old style Intuition window.

    http://postimg.org/image/iidmyuudd/
    http://postimg.org/image/jgo2p75pn/

    The large window relies on a fixed-width font to maintain neat, evenly spaced columns and gives the appearance of column-spanning for the 'inValid eXception', 'FPRF', 'V X' and 'RN' entries. How can I replicate that orderly appearance with a MUI and proportional fonts?

    No doubt I'll come back to this and attempt a better explanation but it's late and I want to switch off...

    [ Edited by ausPPC 18.06.2013 - 00:23 ]
    PPC assembly ain't so bad... ;)
  • »17.06.13 - 14:23
    Profile Visit Website
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Intuition
    Posts: 1110 from 2013/5/24
    From: Nederland
    Escaped tab characters?
    1.67GHz 15" PowerBook G4, 1GB RAM, 128MB Radeon 9700M Pro, 64GB SSD, MorphOS 3.15

    2.7GHz DP G5, 4GB RAM, 512MB Radeon X1950 Pro, 500GB SSHD, MorphOS 3.9
  • »17.06.13 - 15:05
    Profile
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    @ausPPC:

    I'd like to be able to present this cpu information as neatly with MUI as in the old style Intuition window.

    There are a few helpful things:
    - Using separate text objects for related things.
    - Tab characters.
    - List class objects.
  • »17.06.13 - 19:44
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    How do you add tabs to strings for MUI? C style tabs ( \t ) don't do anything and \033t does not seem to be valid.

    Anyway, I experimented and came up with this -

    http://postimg.org/image/67j46xfnx/

    Code:
    /* Compile thusly: 
    > vc +morphos -o spanning_columns spanning_columns.c -lauto -lamiga
    */

    #include <clib/alib_protos.h>
    #include <proto/exec.h>
    #include <proto/intuition.h>
    #include <proto/muimaster.h>

    Object *App, *Win;

    Object* build_gui(void)
    {
    return(MUI_NewObject(MUIC_Application, MUIA_Application_Window,
    (ULONG)(Win = MUI_NewObject(MUIC_Window,
    MUIA_Window_Title, (ULONG)"spanning columns",
    MUIA_Window_RootObject, MUI_NewObject(MUIC_Group, /* defaults to vertical display of Child entries */

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Group_Horiz, TRUE, /* contains three vertical groups */
    /* each containing a MUIC_Text object & MUIC_Group object */

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Frame, MUIV_Frame_Group, /* vertical group 1 */

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla 133n", TAG_END),

    MUIA_Group_Child, MUI_NewObject(MUIC_Group,

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),

    TAG_END),

    TAG_END), /* End of vertical group 1 */

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Frame, MUIV_Frame_Group, /* vertical group 2 */

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla 233n", TAG_END),

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Group_Columns, (2),

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),

    TAG_END),

    TAG_END), /* End of vertical group 2 */

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Frame, MUIV_Frame_Group, /* vertical group 3 */

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla 333n", TAG_END),

    MUIA_Group_Child, MUI_NewObject(MUIC_Group, MUIA_Group_Columns, (3),

    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),
    MUIA_Group_Child, MUI_NewObject(MUIC_Text, MUIA_Text_Contents, (ULONG)"33cbla33n", TAG_END),

    TAG_END),

    TAG_END), /* End of vertical group 3 */

    TAG_END), /* End of the horizontal group containing the three vertical groups */

    TAG_END), /* End of the RootObject group */
    TAG_END)), /* End of NewObject(MUIC_Window) */
    TAG_END)); /* End of NewObject(MUIC_Application) & termination of the return() statement */
    }

    void notifications(void)
    {
    DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
    MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
    }

    void main_loop(void)
    {
    ULONG signals = 0;

    set(Win, MUIA_Window_Open, TRUE);

    while (DoMethod(App, MUIM_Application_NewInput, &signals)
    != MUIV_Application_ReturnID_Quit)
    {
    signals = Wait(signals | SIGBREAKF_CTRL_C);
    if (signals & SIGBREAKF_CTRL_C) break;
    }

    set(Win, MUIA_Window_Open, FALSE);
    }

    int main(void)
    {
    if(App=build_gui())
    {
    notifications();
    main_loop();
    MUI_DisposeObject(App);
    }

    return(0);
    }
    PPC assembly ain't so bad... ;)
  • »19.06.13 - 02:22
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Recently I've been studying various C sources that create MUI interfaces and writing my own experimental programs to better understand MUI. I do like that MUI takes a lot of the burden of laying out interfaces away from the programmer and that it makes such pretty output and certain aspects of object oriented programming but I don't like having to adopt an entirely object oriented programming style for the sake of an interface. I prefer the intuition style event loop and to avoid the use of hooks. Can MUI be coerced into simply providing information about user events? Also, do Intuiticks still exist within MUI? Is a MUI window object pointer the same as a window handle? If not, can I obtain a window handle from a MUI window object? Can I get Intuimessages from an MUI window containing MUI buttons / gadgets?

    btw What do the numbers following App mean? How is it decided what the number should be?

    void notifications(void)
    {
    DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
    MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

    /* Notifications on action buttons */

    DoMethod(findobj(OBJ_BUTTON_FFT, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_FastFourierTransform);

    DoMethod(findobj(OBJ_BUTTON_SOR, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_SuccessiveOverRelaxation);

    DoMethod(findobj(OBJ_BUTTON_MTC, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_MonteCarloPiCalculation);

    DoMethod(findobj(OBJ_BUTTON_SMM, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_SparseMatricesMultiplication);

    DoMethod(findobj(OBJ_BUTTON_LUD, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_LUMatrixDecomposition);

    DoMethod(findobj(OBJ_BUTTON_ALL, App), MUIM_Notify, MUIA_Pressed, FALSE,
    App, 1, APPM_AllBenchmarks);

    /* Notification on "Large Data" button. */

    DoMethod(findobj(OBJ_BUTTON_LGD, App), MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
    App, 3, MUIM_Set, APPA_LargeData, MUIV_TriggerValue);
    }

    [ Edited by ausPPC 23.06.2013 - 06:03 ]
    PPC assembly ain't so bad... ;)
  • »22.06.13 - 19:24
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 2239 from 2003/2/24
    - you don't need to use hooks to get userinput. You could generate a MUIM_Application_ReturnID call for every user input, some IDs are allready predefined (see autodoc/guide)but I would strongly advice against it. Better create (atleast) one custom class with clearly defined methods for user inputs (this would basicly be your "app" with the rest just being the GUI)

    - intuiticks (and all other IDCMP-events) can be received either by MUIM_Window_AddEventHandler or MUIM_Application_AddInputHandler

    - _window(obj) will give you the intuition window-pointer for any given MUI-object. But be aware that this will only work for objects currently placed inside an open window, and the value will change when the user iconfizes or moves the app to another screen. So don't store the value and make sure its only called between MUIM_Setup and MUIM_Cleanup of that object.

    -your example code has obviously created a subclass of MUIC_Application and a bunch of costum methods in it (pretty much what I advised in my 1st point).






    [ Edited by Kronos 23.06.2013 - 22:33 ]
  • »23.06.13 - 21:32
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you for that. I should have indicated that the previous example code is not mine, it's from the SciMark2 tutorial in the library.

    After going back to the SDK for more information on what's in your post, I found that the numbers in the DoMethod() calls refer to how many more words are being passed as arguments. eg:

    DoMethod(findobj(OBJ_BUTTON_LGD, App), MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
    App, 3, MUIM_Set, APPA_LargeData, MUIV_TriggerValue);

    the '3' indicates the number of remaining parameters.
    PPC assembly ain't so bad... ;)
  • »24.06.13 - 01:20
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    @AusPPC

    The numbers in MUIM_Notify are explained here, anyway I see you've got it right :-).

    I prefer the intuition style event loop and to avoid the use of hooks.

    Indeed hooks are old style and not recommended in general. The proper way is to subclass and use own methods, as described here and shown in the SciMark2 example. Intuition style event loop can be done with MUIA_Application_ReturnID, but it is considered bad style, for several reasons.

    Is a MUI window object pointer the same as a window handle?

    No. If you really need Intuition window handle, use macro _window(obj), where obj is MUI window object pointer. Anyway trying to bypass MUI user input handling is entering a minefield...

    Can I get Intuimessages from an MUI window containing MUI buttons / gadgets?

    It is usually done for custom gadgets derived from Area class, by implementing MUIM_HandleEvent() method. Usually when one uses only standard classes, MUI handless intuimessages by itself. If you need some timed events it may be good to use timer.device directly (depends on application).
  • »24.06.13 - 07:29
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    I'd like to create a multi column list but I'm not entirely sure how to interpret the information in the sdk. What would help is a brief example or an open source MUI application that uses that kind of list. Can anyone suggest such an application with freely available source?

    btw After taking another year long break from this little interface wrangling project, I've recently given it another go: interface mockup
    PPC assembly ain't so bad... ;)
  • »30.05.14 - 23:07
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 2239 from 2003/2/24
    I'll try to explain it based the baseclass listview in MMamM :

    Code:


    static ULONG mNew(struct IClass *cl,Object *obj,struct opSet *msg)
    {
    struct Data *data,t;
    obj = (Object*)DoSuperNew(cl,obj,
    MUIA_List_DragType, MUIV_List_DragType_Immediate,
    MUIA_List_Title,TRUE,
    MUIA_List_Format, " MINWIDTH=60 BAR,MAXWIDTH=40",
    MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
    MUIA_List_DestructHook,MUIV_List_DestructHook_String,
    TAG_MORE,msg->ops_AttrList,
    TAG_DONE);
    if(obj)
    {
    data = (struct Data*)INST_DATA(cl,obj);

    *data = t;
    doset( obj, data, msg->ops_AttrList);
    }
    return (ULONG)obj;
    }


    The MUIA_List_Format tells MUI that I want a List with to columns seperated by a bar.
    Construct/DestructHooks makes sure that the entries get copied as strings instead of just passing a pointer.
    The tricky part here is that MUI will only maintain 1 object per row, be it a string or anything else and you need to decipher that into seperate strings for every column yourself.
    I decided here to merge both into 1 string, which will be seperated at display, allowing me to use MUIV_List_ConstructHook_String. If you use your own data object you'll need to do your own housekeeping.
    Code:


    static ULONG mDisplay(struct IClass *cl,Object *obj,struct MUIP_List_Display *msg)
    {
    struct TagItem *tstate, *tag;
    struct Data *data = (struct Data*)INST_DATA(cl,obj);
    if(msg->entry == 0)
    {
    *msg->array++ = "Method";
    *msg->array = "Class";
    }

    If msg->entry is 0 MUI want the strings for title of each column. (I did set MUIA_List_Title to true, remember)
    Code:

    else
    {
    static char classname[100];
    char *clend = classname;
    char *methodname = (char*) msg->entry;
    ULONG i = 0;
    while((!isspace(*methodname)&&(*methodname)))
    {
    *clend = *methodname;
    clend++;
    methodname++;
    }
    methodname++;
    *clend = 0;
    *msg->array++ = methodname;
    *msg->array = classname;
    }
    return 0;
    }



    Otherwise I sperate the stored string into 2 strings for that row.
    msg->array is a pointer to an array of STRPTRs, one for each column in your list.

    Offcourse you will need to add this to your dispather:
    Code:

    case MUIM_List_Display : return(mDisplay (cl,obj,(struct MUIP_List_Display *)msg));

  • »31.05.14 - 07:33
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you, Kronos, for your detailed reply. But I think the list approach is destined for the too-hard basket for me... I struggle with C at the best of times and this is simply too advanced. Too bad.
    PPC assembly ain't so bad... ;)
  • »31.05.14 - 08:30
    Profile Visit Website