MOVED : New project - C128 VDC Text GUI CC65 library

Started by xlar54, May 30, 2010, 01:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xlar54

Copied from comp.sys.cbm (because Im lazy):

Hey folks,
A little contribution Id like to share...

http://sourceforge.net/projects/c128guilib/

Ive been working on a text GUI C library for the 128's VDC, using
CC65.  Its still young and has bugs, but in its current state, you can
create overlapping windows, create controls like labels, textboxes,
etc, and respond to user interaction via callback functions.  Im no
GUI expert, but its taking really good shape and I feel its at a point
where it should be opened up to the community to improve and solidify
the code.  So, if you like what you see, I welcome more developers to
help me out and really make this into something nice.  It is built to
simulate object oriented development.  The library comes with a simple
test application so you can see how it works.

The upload to sourceforge is in VC++ 2008 project (you dont need it,
but Visual Studio rocks...)  The project allows you to build and
compile CC65 projects directly inside Visual Studio.  (See Clean.bat
and Compile.bat for paths which you will need to adjust for your copy
of CC65).  After compilation, just DLOAD"OUTPUT" and run.

Anyway, if anyone is interested in joining the project, Id love the
help.  I have *no clue* how to administer sourceforge, so help there
would be good too.  Consider the source code itself to be the current
documentation :)

Thanks,

X

Below is some sample code:

#include <stdio.h>
#include <string.h>

#include "vdc_gui.h"

void txtBox1_keyPressed(TEXTBOX *textBox, BYTE c);
void txtBox1_onEnter(TEXTBOX *textBox);

WINDOW *win1, *win2;

int main (void)
{
    int x;

    TEXTBOX* txtBox1;

    fast();
   
    // Set the background color to blue
    VDC_BackColor(VDC_DBLUE);
   
    // Generate a background pattern
    for(x=0;x<2000;x++)
        VDC_Poke(x,225);
   
    // Create the windows
    win1 = CreateWindow(5,5,20,10,VDC_WIN_BORDER_LINE);
    win2 = CreateWindow(18, 12, 41,5, VDC_WIN_BORDER_LINE);
   
    // Create the controls
    CreateLabel(win2, 2, 2, "this is a demo of the vdc gui library.");
    CreateLabel(win1,2,5,"name:");
    txtBox1 = CreateTextbox(win1,8,5,10);

    //Add callback to handle key events
    txtBox1->OnKeyPress = txtBox1_keyPressed;
    txtBox1->OnEnter = txtBox1_onEnter;

    //Show the windows
    ShowWindow(win1);
    ShowWindow(win2);

    // Begin message processing
    WinMain(txtBox1->base);


    return 0;
}


A quick note about the code..
After setting up the windows and controls, the WinMain() function is
the message loop which handles the user input and message dispatch
(callbacks, etc).  This function *should* put the focus on the first
"focus-able" control.  I hadnt gotten that far yet, so for sake of the
demonstration, i just sent in the control I want to have focus.  So
thats a bug :) .

Also, adding "buttons" should be trivial given the current
structure... just havent finished it yet.  I was really excited just to
get callbacks working properly (function pointers).  Dropdown lists,
and other more complex controls should be just building on the current
structure.
 
Beyond all that, there's no reason it couldnt be modified to support
the 40 col screen either.. just havent gotten that far... the idea of
a text GUI library for the 80 col screen, and learning GUI development
in general has been my primary focus here.  Ive had fun, and you guys
have done so much for the community, that I wanted to give back a
little.  Hope you all find it as interesting and useful.

Thanks
X