Aros/Developer/Zune/Examples/Texteditor

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A short example program using TextEditor Zune (=MUI) Custom Class. It will present a ready to use Texteditor in a window.

Sourcecode[edit | edit source]

#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <libraries/mui.h>

#include <mui/TextEditor_mcc.h>

int main (int argc, char **argv) {

    struct Library *MUIMasterBase   = NULL;
    Object *mui_app         = NULL;
    Object *mui_win         = NULL;

    if (MUIMasterBase = (struct Library *) OpenLibrary("muimaster.library", 0)) {

        mui_app = ApplicationObject,
            SubWindow, mui_win = WindowObject,
                MUIA_Window_Title, "texteditor",
                WindowContents, TextEditorObject, End,
            End,
        End;

        if (mui_app) {

            // open window:
            SetAttrs(mui_win, MUIA_Window_Open, TRUE, TAG_DONE);
            IPTR open;
            GetAttr(MUIA_Window_Open, mui_win, &open);
            if (open) {

                // *** INSERT LOOP CODE ASKING FOR WINDOW CLOSE EVENT HERE ***

                // ... and close again:
                SetAttrs(mui_win, MUIA_Window_Open, FALSE, TAG_DONE);
            }

            DisposeObject(mui_app);
        }
        CloseLibrary(MUIMasterBase);
    }
    return 1;
}

AROS native compiler command line[edit | edit source]

gcc [sourcefile] -lmui

Screenshot[edit | edit source]

AROS version[edit | edit source]