Thread: Hello World
View Single Post
Old 02-09-2006, 05:18 AM  
PussyTeenies
Confirmed User
 
Join Date: Feb 2005
Location: Haarlem and Amsterdam, capital of the porn world ;-)
Posts: 6,496
and for you designers with a mac

Code:
program macosHelloWorld;

var
    theWindow: WindowPtr;
    wBoundsRect: rect;
    gDone: boolean;
    myEvent: EventRecord;
    gotEvent: Boolean;                    {is returned event for me?}


procedure initToolbox;
    begin
        InitGraf(@thePort);               {initialize QuickDraw}
        InitFonts;                        {initialize Font Manager}
        InitWindows;                      {initialize Window Manager}
        TEInit;                           {initialize TextEdit}

        FlushEvents(everyEvent, 0);       {clear event queue}
        InitCursor;                       {initialize cursor to arrow}
    end; {initToolbox}


procedure drawTheText (w: WindowPtr);     {Draw the text on the window}
    const
        s = 'Hello, World!';
    var
        textLength, textHeight: integer;
        x, y: integer;
        info: fontInfo;
    begin
        setPort(w);                       {sets up the drawing port}
        TextFont(applFont);               {geneva}
        TextFace([]);                     {plain text}
        TextSize(72);                     {72 pts}

        GetFontInfo(info);                {get info on font height}

        textLength := StringWidth(s);     {save width and height}
        textHeight := info.ascent + info.leading;

                                          {center text on screen}

        x := (w^.portRect.right) - (w^.portRect.left);
        x := round(x / 2);

        x := round(x - (textLength / 2));

        y := (w^.portRect.bottom) - (w^.portRect.top);
        y := round(y / 2);

        y := round(y - (textHeight / 2));

        MoveTo(x, y);                     {draw the stuff}
        DrawString(s);

    end; {drawTheText}

begin {macosHelloWorld}
    initToolbox;
    gDone := false;

    with screenBits.bounds do             {set the window size based on
the screen size}
        setRect(wBoundsRect, left + 4, top + 40, right - 4, bottom - 4);
                                          {create a new window}
    theWindow := newWindow(nil, wBoundsRect, '', true, documentProc,
pointer(-1), false, 0);

    drawTheText(theWindow);

    repeat                                {wait until the user clicks
the mouse}
        gotEvent := WaitNextEvent(everyEvent, myEvent, 15, nil);
        if gotEvent then
            case myEvent.what of
                mouseDown: 
                    gDone := true;
                otherwise
                    ;
            end; {case}
    until gDone;

    DisposeWindow(theWindow);             {clear up window memory}

end. {macosHelloWorld}
__________________
Need adult hosting?

Contact us!
WARM Hosting

Need an IT solution? or someone to check your site and security? Nossie - IT Professional
PussyTeenies is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook