Greetings fellow programmers... On Wed, Oct 2nd I started coding my GUI for my operating system. I did this every school day since then in my spare time in Period 3 of 4 (In my peer-tutoring class - I help Grade 10's program in Turing). Because I have to help people, I get about 30 mins a day...
Stats about the GUI:
- Compiled with the PowerC Compiler (email me for it)
- Can handle a current MAX of 64 windows. (can be
changed to whatever with 1 line)
- Enables the user to move, select, deselect
windows to make them active or what not.
- 500 lines of C Code...
- 2D engine allows clipped rectangles and pixels
EVENTUALLY I WILL ADD A DOUBLE BUFFER TO REMOVE FLICKERING
Controls(will change to mouse soon): Arrow keys to move the cursor (a pixel) and space bar to select windows for making active, once more to select to move, and once more to deselct. Currently I have tons of other squares and such drawn... the GUI itself is the group of 3 windows. Here is a search loop:
Code:
unsigned char inwhatwin(int x, int y)
{
unsigned int tz;
unsigned char i;
for (tz = 0; tz < MAXWINDOWS; tz++)
{
for (i = 0; i < MAXWINDOWS; i++)
{
if (wm_elements[i].zorder == tz)
{
if (wm_elements[i].flags & WMFLAGS_ACTIVE)
{
if ((x >= wm_elements[i].x) && (x < (wm_elements[i].x + wm_elements[i].width)))
if ((y >= wm_elements[i].y) && (y < (wm_elements[i].y + wm_elements[i].height)))
return i;
}
}
}
}
return 255;
}
That will start at the top(most visible) active window and search if (x,y) is in it. If not, it'll check the next top most, next top most, etc... wm_elements are the windows. MAXWINDOWS is 64. Returns the handle of the window that the (x,y) point is in of 255 if in none... All of my search and redraw loops look pretty much the same as that. I don't want to give out my actual source file...
I am wondering if ANY one could optimize this loop to make it run faster.
Designer/Programmer of the Comtech Operating System(CTOS)