Page 1 of 1

Warrior Window Manager

Posted: Mon Mar 07, 2005 1:39 pm
by Warrior
Rather than start a new topic I decided to post some things I thought of while at school for a pretty basic windowing system


There would be an Array which stores the windows and information about them:

wID - Window ID (What the window is identified by throught the Operating System)
wCaption - Window Caption
wX - X position
wY - Y position
wState - (Minimized, Maximized, etc)

Then in each window have an array of the Controls within each window.

I am not sure as to how I would handle the clicks on a button or handle keyboard input for textbox's but I managed to whip up a theory on a sort of header of a control.

wID (ID of the Window it belongs to) (Sanity)
cID - ID the Control is identified by
cX - X Position of Control
cY - Y Position of Control

from there I am totally lost as to how associate control events and I want to have the controls have this header so that others can develop thier own controls similiar to ActiveX controls in Microsoft.

Thats all since I am going home now.

Regards,
Warrior


Edit: Looking at a Tutorial on Bona Fide I saw it used x and x2 as well as y and y2 (Why is that)

Anyway I wrote some sample code to get possible feedback on

Code: Select all

/* GUI.c */

#include <system.h>

struct wSize
{
    long x1;
    long y1;
    long x2;
    long y2;
};

struct wInfo
{
    dword wID;
    wSize wPos; 
    byte *wCaption;
    dword wState;
    byte repaint;
    cInfo *wControls
};


void paint_window(dword wID)
{
   /* Repaints the Window if it needs to be repainted */
}

void gui_init()
{
   /* Sets up the Enviroment for the GUI */

   /* Also initializes the Desktop (Will most likely be a big window with 
      several child Windows (our Windows) */
}

void handle_window(dword wID)
{
   /* This code handles the Window Events (wClick, wLoad, wUnload)
   I really should leave this to the discretion of the Program */
}

Re:Warrior Window Manager

Posted: Tue Mar 08, 2005 3:29 am
by Pype.Clicker
Warrior wrote: Rather than start a new topic I decided to post some things I thought of while at school for a pretty basic windowing system
That's usually a BadIdea (tm). Keep one thing per thread if you can or we'll be lost between replies to old posts and newer posts.
There would be an Array which stores the windows and information about them:

wID - Window ID (What the window is identified by throught the Operating System)
wCaption - Window Caption
wX - X position
wY - Y position
wState - (Minimized, Maximized, etc)
You'll usually prefer a z-sorted linked list rather than an array ...
Then in each window have an array of the Controls within each window.

I am not sure as to how I would handle the clicks on a button or handle keyboard input for textbox's but I managed to whip up a theory on a sort of header of a control.
Here again, an array may not be the best approach. You usually prefer to organize your controls into container objects in a hierarchical fashion. When a click (x,y) is received by the "topmost" container, it will compute which object should receive it based on size of contained of objects (using a dichotomic search or simply a division if all objects are known to have the same size)

Your navigator could be

Code: Select all

   window = vertical_container(
       menubar = horizontal_container(popup("File"), popup("Edit"), ...)
       urlbar = horizontal_container(back=button(), forward=button(), refresh=button(), stop=button(), url=textbox()),
       frame = scrollable_area(),
       statusbar = horizontal_container(...)
    );
Edit: Looking at a Tutorial on Bona Fide I saw it used x and x2 as well as y and y2 (Why is that)
that's because you'll need to know _how large_ the control is, in addition of knowing where it is. Keep in mind that your controls may need (or not) to be repositionned when window is resized, etc.

I suggest you read more about internals of GTK (or something similar) and about James Klik's favourite threads...

Re:Warrior Window Manager

Posted: Tue Mar 08, 2005 1:02 pm
by Warrior
Thanks!

Re:Warrior Window Manager

Posted: Tue Mar 08, 2005 6:12 pm
by Warrior
New Question: I wan't to draw the images for a Loading Screen while in the background I setup my files needed for the OS to work properly. Now heres my question: Does one have to include the .bmp image in the Directory or is there another way, maybe draw it at run time with a drawbmp feature. If so can anyone point me in any articles/example code/tutorials. Any help is appreciated, thanks.

- Warrior

Re:Warrior Window Manager

Posted: Tue Mar 08, 2005 7:24 pm
by SANiK
Warrior wrote: New Question: I wan't to draw the images for a Loading Screen while in the background I setup my files needed for the OS to work properly. Now heres my question: Does one have to include the .bmp image in the Directory or is there another way, maybe draw it at run time with a drawbmp feature. If so can anyone point me in any articles/example code/tutorials. Any help is appreciated, thanks.

- Warrior
Oh you got to be kidding me...

1) If you are making an GUI in Windows, then use ANSI-C's ability to load files.
2) If you are PRO self-relying programs, then convert the BMP to a header file, and have the draw pixel function load data from there.
I advise you use RLE compression for this.
3) I have a BIG feeling that you're starting at the top, by making the GUI first instead of the OS. That's a big no-no, you might as well completely stick to GUI dev.
4) Why do Japanese people draw normal eyes in animes?

Re:Warrior Window Manager

Posted: Tue Mar 08, 2005 7:45 pm
by Warrior
Hah, well I guess I let myself go on that one. I sorta was making the GUI first which is generally a bad idea. I've been working on rewriting my Kernel to be more modular based yet this is only a theory

Modules interact with the kernels "registering" what they want to support as a module. In response the kernel sends the appropriate data to them (Window Events, Keyboard input, etc) so I can have my Kernel just be a main module loader so I can write my software drivers more as drivers as opposed to having them hardcoded into the kernel which in my opinion is a bad idea.

I was just bored at school and came up with this idea for a Window manager in my notebook and I guess I stuck to it :P .

Thanks for the virutal slap to reality :)

Re:Warrior Window Manager

Posted: Sun Mar 13, 2005 11:49 pm
by open_coder
Even though, you started out on the wrong track. Don't forget about GUI development until the last minute either. I am just starting out but I am working on understanding everything. It's okay to get a little ahead of yourself. And It is also a good idea to know what direction you are heading in.

--Alex

Re:Warrior Window Manager

Posted: Mon Mar 14, 2005 1:38 pm
by mystran
I'd like to mention that libpng (which obviously handles PNG files, which pretty much rule as a lossless graphics format) has pretty small requirements about the environment in which it runs. You don't necessarily even need a filesystem to use it.

The API is definitely not the nicest possible, but it's not the worst either. Basicly, you supply PNG data through callbacks, and libpng gives you a decoded image back. There are half-a-million different image formats to support if you want to do it "the right way" but fortunately you won't encounter most of the possibilities in real world.

It is relatively easy to support "basic operation" through libpng, and writing a png loader using libpng for the first time (on Linux, not my own OS) took me something like 2 hours of reading and coding, with the end-result being about 150 lines of C++ code, with alpha-channel and all.

Re:Warrior Window Manager

Posted: Mon Mar 14, 2005 2:14 pm
by Warrior
Wow, thanks! I'll look into libpng when I'm ready.