CC65 and Windowing Library

Started by xlar54, February 24, 2008, 11:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xlar54

Hey guys, just wanted to toss out something that is evolving out of the edit128 application... looks like with the need for drop down menus and such, that Ive actually started a windowing library for the 128.  Its coming along slowly, but here's a sample of the code:

void main()
{
   Window win;
   Label label1;
   Label label2;
   Button btnOK;
   Button btnCancel;

   win.x1 = 10;
   win.y1 = 5;
   win.x2 = 59;
   win.y2 = 16;
   win.style = WINDOW_STYLE_REVERSE;
   win.bgcolor = COLOR_WHITE;
   win.mode = WINDOW_MODE_NONDESTRUCTIVE;

   Window_Initialize(&win);

   label1.x = 0;
   label1.y = 0;
   label1.text = "This is label1";

   label2.x = 2;
   label2.y = 4;
   label2.text = "This is label2...";

   btnOK.x = 12;
   btnOK.y = 8;
   btnOK.text = "    Ok    ";
   btnOK.onclick = NULL;

   btnCancel.x = 25;
   btnCancel.y = 8;
   btnCancel.text = "  Cancel  ";
   btnCancel.onclick = NULL;

   Window_AddControl(&win, &label1, 1, CONTROL_TYPE_LABEL);
   Window_AddControl(&win, &label2, 2, CONTROL_TYPE_LABEL);
   Window_AddControl(&win, &btnOK, 3, CONTROL_TYPE_BUTTON);
   Window_AddControl(&win, &btnCancel, 4, CONTROL_TYPE_BUTTON);

   Window_Draw(&win);

}

It uses the save / restore for a non destructive dialog window, and you can define event handler functions for things like buttons and textboxes.  Will post more when its more complete.  I think Contiki is already doing something like this, but its available if you would like to poke around with it.

Thanks

X