From: xlar54 on
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);


int main (void)
{
int x, ok;

WINPTR myWindow1;
TEXTBOX* txtBox1;

fast();

ok = CreateWindow(5,5,20,10,VDC_WIN_BORDER_LINE, &myWindow1);

CreateLabel(&myWindow1,2,5,"name:");
txtBox1 = CreateTextbox(&myWindow1,8,5,10);

//Add event callback
txtBox1->OnKeyPress = txtBox1_keyPressed;
txtBox1->OnEnter = txtBox1_onEnter;

if (ok == 0)
{
VDC_BackColor(VDC_DBLUE);

for(x=0;x<2000;x++)
VDC_Poke(x,225);

ShowWindow(&myWindow1);

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

DestroyWindow(&myWindow1);

}
else
printf("Could not allocate RAM for windows, or dimension error!");

return 0;
}

void txtBox1_keyPressed(TEXTBOX *textBox, BYTE c)
{
VDC_Poke(0,VDC_PetsciiToScreenCode(c));
}

void txtBox1_onEnter(TEXTBOX *textBox)
{
char text[30] = "hello ";

strcat(text, textBox->text);

CreateLabel(textBox->base->parentWindow, 2,3, text);
RefreshWindow(textBox->base->parentWindow);
}
From: xlar54 on
A quick note about the code..

After setting up the windows and controls, the VDC_Main() 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 done 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.

And some general cleanup of the API itself.. Id like CreateWindow to
return a WINPTR structure pointer, but CC65 wont allow it. Etc, etc..
theres alot of areas for improvement.

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
From: Rakko on
In article
<182c796f-e0db-46e0-a3c6-9b3e809a7a6d(a)j27g2000vbp.googlegroups.com>,
xlar54 <scott.hutter(a)gmail.com> wrote:

> A quick note about the code..
>
> After setting up the windows and controls, the VDC_Main() 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 done 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.
>
> And some general cleanup of the API itself.. Id like CreateWindow to
> return a WINPTR structure pointer, but CC65 wont allow it. Etc, etc..
> theres alot of areas for improvement.
>
> 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

This looks really cool! I always wanted to make a VDC GUI, but I was
planning on using the bitmap screen (but limiting window positions to
VDC color cell sizes).

Why do you call the type WINPTR when it's not a pointer? And won't CC65
allow you to return structure pointers?
From: xlar54 on

>
> This looks really cool! I always wanted to make a VDC GUI, but I was
> planning on using the bitmap screen (but limiting window positions to
> VDC color cell sizes).
>
> Why do you call the type WINPTR when it's not a pointer? And won't CC65
> allow you to return structure pointers?

Thanks. It was meant to be a pointer to a struct, but yeah, cc65 (at
least at the time) wouldnt allow you to return pointers of structs
which were defined within the function. Something about it isnt a C
standard... I dont recall the specifics. You mention graphics...
Potentially, the API could be modified to do that as well. Thanks
again.


From: xlar54 on
You know, looking at it... I already do it for textboxes... Define the
pointer outside.. Might as well do the same for windows in general.
Then we can add callbacks for the window itself, like GotFocus or
Closed.. Ive done some Cocoa Touch development, and am thinking about
sticking with some common callback methods. Anyway, thanks for
keeping me thinking...