Good day,

Attached is an example program that shows its own source code in a textbox. Also attached is a screenshot of the program output. I am using Agar SVN on Linux with SDL. I expected a vertical scrollbar, but there is none. The horizontal scrollbar is visible. I expected the text to scroll horizontally, but it remains fixed when I move the horizontal scrollbar. Do you know of a working example that uses the scrollbars in a textbox widget?

Thank you,

-Ben
/*
cc $(agar-config --cflags) -I/home/ben/local/include -L/home/ben/local/lib 
-Wl,-R/home/ben/local/lib $(agar-config --libs) problem.c
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <agar/core.h>
#include <agar/gui.h>

void quitter(AG_Event *event) {
    AG_QuitGUI();
    return;
}

int main(int argc, char *argv[]) {
    int result;
    AG_Box *box,
        *box2;
    AG_Button *exitbutton;
    AG_Textbox *tb;
    AG_Window *win;
    FILE *fp;
    char buffer[4096];

    result = AG_InitCore("problem", 0);
    if (result == -1) {
        puts(AG_GetError());
        exit(1);
    }

    result = AG_InitGraphics("sdlfb(width=800:height=600:depth=32)");
    if (result == -1) {
        puts(AG_GetError());
        exit(1);
    }
    win = AG_WindowNew(AG_WINDOW_PLAIN);
    AG_WindowSetCaptionS(win, "Example window caption");
    AG_WindowSetPosition(win, AG_WINDOW_MC, 1);
    AG_WindowSetGeometryMax(win);

    box = AG_BoxNew(win, AG_BOX_VERT, AG_BOX_EXPAND);
    AG_BoxSetLabelS(box, "Example box title");

    memset(buffer, 0, 4096);
    fp = fopen("problem.c", "r");
    fread(buffer, 1, 4096, fp);
    fclose(fp);
    buffer[4095] = '\000';
     
    tb = AG_TextboxNewS(box, AG_TEXTBOX_EXCL | AG_TEXTBOX_MULTILINE, buffer);
    AG_EditableSizeHint(
        tb->ed,
        "                                        "
        "                                        "
        "                                        "
        "                                        "
    );
    AG_EditableSizeHintLines(tb->ed, 24);

    box2 = AG_BoxNew(box, AG_BOX_HORIZ, AG_BOX_EXPAND);
    AG_BoxSetHorizAlign(box2, AG_BOX_CENTER);

    exitbutton = AG_ButtonNewS(box2, 0, "Exit");
    AG_AddEvent(exitbutton, "button-pushed", quitter, NULL);

    AG_WindowShow(win);
    AG_EventLoop();
    AG_QuitGUI();
    exit(0);
}

<<attachment: problem.jpg>>

_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html

Reply via email to