Help with making a window code!

Developer
Aug 17, 2011 at 9:15 AM
Edited Aug 21, 2011 at 8:51 AM

Please can I have some help with making a proper window code, I have got the visual assets all worked out but need help with the background running code (window position, whether the window is in front or not, is the window minimized?) Any help and code snippets would be much appreciated! I think I could have each window as a variable or class with all that information in e.g

 

window calcwindow = new window();

 

 Thanks

melikesPCcheese

Developer
Aug 17, 2011 at 4:31 PM

I would suggest having a few sets of things, the first thing you need is an organized list. (I have a SkipList implementation that would do pretty well at keeping the windows, and should work just fine in cosmos) This list will contain all of the minimized windows. Then you'll have a Queue<Window> (You'll have to do a small modification, or write an extension method (Do extension methods work in cosmos?), that allows you to locate an item in the queue, and pull it to the front) that represents the windows that are visible. The window at the front is the currently active window. The window should implement a draw() method, and also keep track of it's own position on the screen, as well as size. Only send click events to the active window, and if the click is outside of the bounds of the window check if it's in the bounds of any of the other windows, and if it is switch to it. (do the check from front to back (Queue.Dequeue()) ) The window class should also contain a property that defines it's current state, Active, Visible, and Minimized, that will be very useful in the future. When you go to draw windows, draw the active ones from back to front,  (Reverse the queue, then dequeue) and only update the active window (when we have multi-threading fully implemented, then you might be able to go about updating the inactive windows).

I hope this was able to give you at least some idea as to where to start with this.

Aug 17, 2011 at 4:45 PM

I have most of a window system implemented for my Intrexity OS and I will help anyone who needs it.

On Aug 17, 2011 12:31 PM, "blah38621" <notifications@codeplex.com> wrote:

From: blah38621

I would suggest having a few sets of things, the first thing you need is an organized list. (I have a SkipList implementation that would do pretty well at keeping the windows, and should work just fine in cosmos) This list will contain all of the minimized windows. Then you'll have a Queue<Window> (You'll have to do a small modification, or write an extension method (Do extension methods work in cosmos?), that allows you to locate an item in the queue, and pull it to the front) that represents the windows that are visible. The window at the front is the currently active window. The window should implement a draw() method, and also keep track of it's own position on the screen, as well as size. Only send click events to the active window, and if the click is outside of the bounds of the window check if it's in the bounds of any of the other windows, and if it is switch to it. (do the check from front to back (Queue.Dequeue()) ) The window class should also contain a property that defines it's current state, Active, Visible, and Minimized, that will be very useful in the future. When you go to draw windows, draw the active ones from back to front, (Reverse the queue, then dequeue) and only update the active window (when we have multi-threading fully implemented, then you might be able to go about updating the inactive windows).

I hope this was able to give you at least some idea as to where to start with this.



Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@di...

Developer
Aug 18, 2011 at 12:06 PM
blah38621 wrote:

I would suggest having a few sets of things, the first thing you need is an organized list. (I have a SkipList implementation that would do pretty well at keeping the windows, and should work just fine in cosmos) This list will contain all of the minimized windows. Then you'll have a Queue<Window> (You'll have to do a small modification, or write an extension method (Do extension methods work in cosmos?), that allows you to locate an item in the queue, and pull it to the front) that represents the windows that are visible. The window at the front is the currently active window. The window should implement a draw() method, and also keep track of it's own position on the screen, as well as size. Only send click events to the active window, and if the click is outside of the bounds of the window check if it's in the bounds of any of the other windows, and if it is switch to it. (do the check from front to back (Queue.Dequeue()) ) The window class should also contain a property that defines it's current state, Active, Visible, and Minimized, that will be very useful in the future. When you go to draw windows, draw the active ones from back to front,  (Reverse the queue, then dequeue) and only update the active window (when we have multi-threading fully implemented, then you might be able to go about updating the inactive windows).

I hope this was able to give you at least some idea as to where to start with this.

Thanks for the help this should help a lot

Developer
Aug 18, 2011 at 12:07 PM
iProcessor wrote:

I have most of a window system implemented for my Intrexity OS and I will help anyone who needs it.

No offense to you but I would like to write my own so I know how it works and then I can fiddle and do what I like with it without problems.

Aug 18, 2011 at 6:56 PM

Ik that. I will help u if u get stuck.

On Aug 18, 2011 8:07 AM, "melikesPCcheese" <notifications@codeplex.com> wrote:

From: melikesPCcheese


>
> iProcessor wrote:
>
> I have most of a window system implemented for my Intrexity OS and I will...

No offense to you but I would like to write my own so I know how it works and then I can fiddle and do what I like with it without problems.



Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@di...

Developer
Aug 20, 2011 at 1:54 AM

I also might be able to help you with it Melikes, as I'm currently working on my own window system. (Is it good if i have a button control fully working before I have the window system working fully?) Currently I'm able to move (drag & drop), resize (resize must be done in code, haven't implemented drag-resize support yet), and, as soon as I implement the buttons, close, minimize, and maximize windows. (just a matter of defining a few more bounds, and checking them, also requires a few more drawing checks, as i handle & draw the min, max, and close buttons manually)  Also, the windows pass the MouseClick, MouseUp, MouseDown, and MouseMove, to the controls in the window, making sure to make the location being passed, relative to the content frame of the window.


(As a note, I'm currently working inside a PictureBox on a winforms app, so it's much easier to debug, and should port quite easily to Cosmos :P)

iProcessor, what capabilities have you implemented in your window system?

Aug 20, 2011 at 2:17 AM

Buttons, moving, close, and apps!
Each window can have a different app. For example my xWrite app can be in one window and xDraw in the other.. And I dont have to code in an app for each one.

On Aug 19, 2011 9:54 PM, "blah38621" <notifications@codeplex.com> wrote:

From: blah38621

I also might be able to help you with it Melikes, as I'm currently working on my own window system. (Is it good if i have a button control fully working before I have the window system working fully?) Currently I'm able to move (drag & drop), resize (resize must be done in code, haven't implemented drag-resize support yet), and, as soon as I implement the buttons, close, minimize, and maximize windows. (just a matter of defining a few more bounds, and checking them, also requires a few more drawing checks, as i handle & draw the min, max, and close buttons manually) Also, the windows pass the MouseClick, MouseUp, MouseDown, and MouseMove, to the controls in the window, making sure to make the location being passed, relative to the content frame of the window.


(As a note, I'm currently working inside a PictureBox on a winforms app, so it's much easier to debug, and should port quite easily to Cosmos :P)

iProcessor, what capabilities have you implemented in your window system?



Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)



To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receivi...

Developer
Aug 20, 2011 at 1:33 PM

blah does Cosmos have xml parseing and if not how easy would it be to implement I imagine eventually a window code which can execute xml based code (like HTML which can be coded by third party developers)

Aug 20, 2011 at 3:29 PM

Uh theres not even a physical file system yet.

On Aug 20, 2011 9:33 AM, "melikesPCcheese" <notifications@codeplex.com> wrote:

From: melikesPCcheese

blah does Cosmos have xml parseing and if not how easy would it be to implement I imagine eventually a window code which can execute xml based code (like HTML which can be coded by third party developers)



Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@di...

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.



Please note: Images and attachments will be removed from emails. Any posts to this discussion will...

Developer
Aug 21, 2011 at 8:50 AM

OK, I've implemented all the necessary variables into a window class which works well as shown in the first post. I have also made a draw method which takes the window code and prints it onto the VGAscreen.

 

I have also got a list which accepts the window class eg

windowmanagerlist.Add(calcwindow)

I have a rough idea on how to implement the drawing of the whole list onto the screen but would like additional help. Help would also be appreciated on handling the clicks on the windows eg the close and minimize button.

 

Also if a cosmos dev is here do you know how to get a res higher than 320x200 working in the VGAScreen, as far as I know from experimenting you can setmode up to a high res but cannot setpixel even at low res in more recent version which as per usual has forced me back to using MS4 for everything, help much appreciated,

 

Thanks

 

melikesPCcheese

Aug 21, 2011 at 11:05 PM
melikesPCcheese wrote:

OK, I've implemented all the necessary variables into a window class which works well as shown in the first post. I have also made a draw method which takes the window code and prints it onto the VGAscreen.

 

I have also got a list which accepts the window class eg

windowmanagerlist.Add(calcwindow)

 

I have a rough idea on how to implement the drawing of the whole list onto the screen but would like additional help. Help would also be appreciated on handling the clicks on the windows eg the close and minimize button.

 

Also if a cosmos dev is here do you know how to get a res higher than 320x200 working in the VGAScreen, as far as I know from experimenting you can setmode up to a high res but cannot setpixel even at low res in more recent version which as per usual has forced me back to using MS4 for everything, help much appreciated,

 

Thanks

 

melikesPCcheese

As far as I know, in order to move up to a higher VGA resolution > 320x200, you need a specific driver for the video card your targeting.

Aug 22, 2011 at 4:27 AM

Using VESA standards you should detect the capabilities of the Video Card using function 0x00h (I think thats it, google it) which returns information about the video card, from there you should be able to extract information about higher resolutions.

Aug 22, 2011 at 2:05 PM

Why do people always come here and beg for code? If you can not do it by your self than you need to learn more about C# and programming and then try again.

Developer
Aug 22, 2011 at 3:22 PM
Edited Aug 22, 2011 at 4:25 PM
Grunt wrote:

Why do people always come here and beg for code? If you can not do it by your self than you need to learn more about C# and programming and then try again.

This is actually one of the things that having programming experience doesn't necessarily mean you can do. It is nearly impossible to find a usable sample of code to look at for this type of thing. It takes a very large amount of thought to even figure out where to start (and without a decent amount of experience, it's nearly impossible) and asking for help as to where to start is generally the best way to figure it all out.

 

Also, he wasn't asking for code, he was asking for a starting point.

 

Also as a note, from what I've read, my current window implementation is considered a Compositing system XD (Windows Vista and 7 both  use Compositing systems, while Windows XP and below used a stacking system :P)

Aug 22, 2011 at 4:43 PM
charsleysa wrote:

Using VESA standards you should detect the capabilities of the Video Card using function 0x00h (I think thats it, google it) which returns information about the video card, from there you should be able to extract information about higher resolutions.

Isn't that a BIOS interrupt though? COSMOS runs in protected mode not real mode. So you can't use any BIOS interrupts unless you went back to real mode or into virtual 8086 mode. IIRC.

Developer
Aug 22, 2011 at 7:42 PM
I am thinking that there might be a way to use a for to run through the windows from back to front and only using the method when a window has changed position, however I do not know how to get the names of all the items from the list so I can detect the order of the windows and get the name of the window to print them. Clicking can probably be done in the same way running through the windows to see if any clicks are in the vicinity of any control surfaces or if in another window is capable of bringing it to the front.

Best Regards

melikescheese

P.S Can grunt please note that people come this discussion board to learn, not to boast or say things they already know and most of all they don't tend to come to be big headed!
Developer
Aug 23, 2011 at 3:54 PM
Edited Aug 23, 2011 at 4:25 PM

I would suggest using an array, and keeping the items in that array in order of the windows from front to back, then have 2 bool properties on the window, 1 for maximized, and 1 for minimized. If the active window (the one at index 0 in your window array), is maximized, there is no need to draw any of the other windows. If a window is minimized, you don't need to draw it at all. (I actually need to switch my code to use 2 bools rather than a window state enum, due to the way I draw the window header, and it's contents.)

  I also now have maximizing working, although I am having issues with my testbed, due to the fact my drawimage code relies on the getpixel/setpixel methods, and since i'm working against a bitmap (only on the top level), that is extremely slow. Anyone know of a bitmap type that i can directly handle from a picture box with much faster get/set pixel methods? (currently investigating moving the testbed to render against opengl, as my dev machine barely supports DirectX 4 XD (Graphics card in it is REALLY old :P (Windows 95 anyone?) ))

 

Edit:

I fixed my issue with the testbed, I just switched around the way in which I deal with the rendering, and instead use the lockbits method to work with the data much faster.

Coordinator
Aug 23, 2011 at 5:25 PM
The mentioned function is a BIOS function, which is not usable in cosmos, as we run in Protected mode..


On Tue, Aug 23, 2011 at 5:54 PM, blah38621 <notifications@codeplex.com> wrote:

From: blah38621

I would suggest using an array, and keeping the items in that array in order of the windows from front to back, then have 2 bool properties on the window, 1 for maximized, and 1 for minimized. If the active window (the one at index 0 in your window array), is maximized, there is no need to draw any of the other windows. If a window is minimized, you don't need to draw it at all. (I actually need to switch my code to use 2 bools rather than a window state enum, due to the way I draw the window header, and it's contents.)

I also now have maximizing working, although I am having issues with my testbed, due to the fact my drawimage code relies on the getpixel/setpixel methods, and since i'm working against a bitmap (only on the top level), that is extremely slow. Anyone know of a bitmap type that i can directly handle from a picture box with much faster get/set pixel methods? (currently investigating moving the testbed to render against opengl, as my dev machine barely supports DirectX 4 XD (Graphics card in it is REALLY old :P))

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Aug 23, 2011 at 5:29 PM

Also, if your looking for example code, look at the OForms project in my user folder, as I just committed a version that supports closing, maximizing, moving (haven't implemented resizing yet), and apps (in the same way winforms supports apps). Currently working on implementing a taskbar. Will add window titles at some point soon, as that just requires me adding string drawing support to Orvid.Graphics.Image (which isn't that hard to do).

Developer
Aug 23, 2011 at 6:52 PM
blah38621 wrote:

Also, if your looking for example code, look at the OForms project in my user folder, as I just committed a version that supports closing, maximizing, moving (haven't implemented resizing yet), and apps (in the same way winforms supports apps). Currently working on implementing a taskbar. Will add window titles at some point soon, as that just requires me adding string drawing support to Orvid.Graphics.Image (which isn't that hard to do).

Is this in the source code for cosmos?

Developer
Aug 23, 2011 at 6:53 PM

Yep. source2->Users->Orvid->OForms

Developer
Aug 23, 2011 at 7:07 PM
Edited Aug 23, 2011 at 7:21 PM

Thanks for this now using your code for ideas on how to get a system with arrays up and running. You will have an attribution in our about window when we release Envy OS at grapevineos.codeplex.com come and have a look round.

Developer
Aug 23, 2011 at 11:43 PM

Also, if you wanted to see my system in action,

http://www.youtube.com/watch?v=tCgRQC7vx7Q

Developer
Aug 26, 2011 at 10:40 AM

I have everything worked out but the code doesn't work, why? It's probably something really simple but I can't work it out. For testing purposes it prints all the windows everytime during the loop. There is one test window which is at activewindows[0] but it doesn't print.

            for (int i = activewindows.Length; i > -1; i--)
            {
                Window w;
                w = activewindows[i];
                if (w.thiswindow == Window.WindowState.minimized)
                {
                }
                else
                {
                    DrawWindow(w);
                }
            }

HELP!

Developer
Aug 26, 2011 at 2:13 PM
melikesPCcheese wrote:

I have everything worked out but the code doesn't work, why? It's probably something really simple but I can't work it out. For testing purposes it prints all the windows everytime during the loop. There is one test window which is at activewindows[0] but it doesn't print.

 

            for (int i = activewindows.Length; i > -1; i--)
            {
                Window w;
                w = activewindows[i];
                if (w.thiswindow == Window.WindowState.minimized)
                {
                }
                else
                {
                    DrawWindow(w);
                }
            }

 

HELP!

This would be because you aren't running through the loop at all yet. When your iterating down through an array, you have to account for the differences in bases, the Legth property has a base of 1, while the index has a base of 0, meaning that you have to use activewindows.Length - 1 as the initial value for i.

Also, declaring a new variable inside a loop is a bad thing, as a new object is allocated every loop, where-as if you declare it ouside of the loop, and assign a value to it in the loop, it's only allocated once. (depending on the number of loops and the size of the object, this can cause GC-Thrashing (wouldn't happen within Cosmos currently as there is no real GC yet) )

Coordinator
Aug 26, 2011 at 3:20 PM
Your remark about declaring a variable inside a loop is wrong: declaring a variable doesn't mean a new object is instantiated.



On Fri, Aug 26, 2011 at 4:13 PM, blah38621 <notifications@codeplex.com> wrote:

From: blah38621

melikesPCcheese wrote:

I have everything worked out but the code doesn't work, why? It's probably something really simple but I can't work it out. For testing purposes it prints all the windows everytime during the loop. There is one test window which is at activewindows[0] but it doesn't print.

            for (int i = activewindows.Length; i > -1; i--)
            {
                Window w;
                w = activewindows[i];
                if (w.thiswindow == Window.WindowState.minimized)
                {
                }
                else
                {
                    DrawWindow(w);
                }
            }

HELP!

This would be because you aren't running through the loop at all yet. When your iterating down through an array, you have to account for the differences in bases, the Legth property has a base of 1, while the index has a base of 0, meaning that you have to use activewindows.Length - 1 as the initial value for i.

Also, declaring a new variable inside a loop is a bad thing, as a new object is allocated every loop, where-as if you declare it ouside of the loop, and assign a value to it in the loop, it's only allocated once. (depending on the number of loops and the size of the object, this can cause GC-Thrashing (wouldn't happen within Cosmos currently as there is no real GC yet) )

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Aug 26, 2011 at 8:02 PM
Brilliant never knew that about the .Length property of an Array object.
It wasn't fully explained in the MSDN article.
When finished I will post to tell you how it's going.

Hopefully in the future this discussion thread will come in handy for people who have got to the stage where they want a proper GUI window system.

Sent from my iPod via Hands, Eyes and Brain

On 26 Aug 2011, at 15:13, "blah38621"<notifications@codeplex.com> wrote:

From: blah38621

melikesPCcheese wrote:

I have everything worked out but the code doesn't work, why? It's probably something really simple but I can't work it out. For testing purposes it prints all the windows everytime during the loop. There is one test window which is at activewindows[0] but it doesn't print.

            for (int i = activewindows.Length; i > -1; i--)
            {
                Window w;
                w = activewindows[i];
                if (w.thiswindow == Window.WindowState.minimized)
                {
                }
                else
                {
                    DrawWindow(w);
                }
            }

HELP!

This would be because you aren't running through the loop at all yet. When your iterating down through an array, you have to account for the differences in bases, the Legth property has a base of 1, while the index has a base of 0, meaning that you have to use activewindows.Length - 1 as the initial value for i.

Also, declaring a new variable inside a loop is a bad thing, as a new object is allocated every loop, where-as if you declare it ouside of the loop, and assign a value to it in the loop, it's only allocated once. (depending on the number of loops and the size of the object, this can cause GC-Thrashing (wouldn't happen within Cosmos currently as there is no real GC yet) )