Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Window Z-Order

Author
Message
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 03:11
Hi folks,

working on my GUI system, i've added alot of features but am stuck on how i can get z-order on the windows, dont suppose n e 1 knows any good examples of z-ordering windows

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 03:26
Try GetWindowInfo

Beware the cat... The alien... The heretic...
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 03:29
its for my OWN gui system, it doesn use MFC or win32 i draw all the windows myself etc. so i need to sort out the Z-Order for the windows

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 03:31
Okay...

Beware the cat... The alien... The heretic...
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 03:33
GetWindowInfo will retreive info about the win32 window? isnt that correct?

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 03:34
Yes

Beware the cat... The alien... The heretic...
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 03:39
yah so i cant use it for my own GUI system
i'm using a vector array to store the windows and need to reorder the array to mimic z-ordering
should maybe have mentioned that earlier
i was thinking that when the user clicks a window i add a new element to the end of the vector then delete the prev. element? but is this gonna be slow

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 03:41
Unfortunately, cant help there.

Beware the cat... The alien... The heretic...
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 03:42
cheers n e way TCA,
thx for the quick response

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 03:43
No problem.

Beware the cat... The alien... The heretic...
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Dec 2004 05:20
Vectors aren't really designed for insertion/deletion in the middle, which is what you need to do. In fact, I think that to do this you need to use brute force ...



A more efficient way to do this would be to hold the items in a list instead, but that makes searching a little slower and harder.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 05:40
thx,

just as a side, are images really slow? i get about 36fps when making bitmaps and drawing to the screen

If i dont know,
I'm sure you will
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 17:07
It depends on the size, and how many you paste.

Lets see the image pasting code.

Beware the cat... The alien... The heretic...
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 14th Dec 2004 21:37
this is the block of code that renders the image then pastes it to screen. attached is the full source for the win.h as it stands at the moment



If i dont know,
I'm sure you will
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 15th Dec 2004 00:23
Well I dont know how to make it any better, not having the SDK hinders that. But in general I bet you could reduce the number of function calls in drawGUI. It seems to me you keep creating the exact same bitmap but with minor changes to width, height, etc. Is there a way to just create the bitmap once and then in drawGUI only change the width, height, etc as needed? Again I dont know for sure, but I bet all that creation is slowing it down.

Oh and a note about using STL vectors. Its better to use classes instead of structs. Thats because its easier to handle memory management. So I bet you have a memory leak because when vector tries to delete your struct, it doesnt delete some of the variables properly.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Dec 2004 01:50
You are right about the bitmap creation - it's not fast.

You are not right about using classes instead of structs - a struct *is* a class. The only difference between them is that struct contents are public by default, instead of private.

When the only things within your struct are plain numbers (which they appear to be), then there is no memory management to do. If there were pointers, it'd be a different case, but still exactly the same thing would need to be done whether using classes or structs (copy, assignment, destructor).

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 15th Dec 2004 02:17
Yeah but he IS using pointers.

If he deletes those char* vars somewhere else in the code, then ok no problem. But its better to use classes just in case he doesnt. Plus its less of a headache to try and keep track of what was allocated/deallocated and what wasnt, at least for me. And even if he does delete the char* vars properly it doesnt hurt to make sure with a class destructor. You can call delete or free() as many times as you want without it hurting anything. Id be happy to explain why because I just had to rewrite malloc() and free() for class.

Structs should only be used if all the contents are static, otherwise use classes. And structs ARE NOT classes, similar but not the same. Like you said classes allow for public, private, etc. And they allow for easier memory management. With a class you can define the destructor, but you cant with a struct. And this makes it nice because then I dont have to create a whole seperate function to delete any dynamically allocated memory in the class/struct. You can also do inheritance with classes, and as far as I know the same cant be done with structs. Plus you arent supposed to be allowed to use functions in structs, although VC++ allows for that. But its not considered good practice.

Anyway just use classes, makes life easier.
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 15th Dec 2004 02:34
I'm going to have to side with IanM on this one. Using classes to handle a simple task such as storing simple information is beyond me. A struct would work good in this case. For example, you should have to create a class to store first name, last name, age, weight, height etc.. That can be done with a struct. Classes are used better in data structures, creating templates etc.... With the above, you can easily do a struct. I don't see anything related to memory in the above code.
SoulMan

This is as backwards as is This
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 15th Dec 2004 02:52
Ok look he is dealing with allocated memory when he does:

struct wGadget
{
char* gName;
char* gCaption;
};

So somewhere he has to delete those 2 variables. All Im saying is that its easier from a debug point of view to use classes since you can define the destructor. Now an acceptable way to use a struct in this particular case is to do:

using namespace std;

struct wGadget
{
string gName;
string gCaption;
};

OR

struct wGadget
{
std::string gName;
std::string gCaption;
};

The reason its acceptable is because STL takes care of the memory management for the string. But in his code, he needs to do the memory management himself. And if he is going to do it himself, he should use a class.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Dec 2004 02:58
There is actually a char* defined in there, but even so, I still wouldn't create a class for this - I'd use a std::string to store it. There is no point in creating a whole class for what is simply a data store. If I wanted to do things with it rather than just store data, then I would make a class.

Quote: "With a class you can define the destructor, but you cant with a struct"


Try it with GCC, Borland or Digital Mars instead then ... betcha it works.

Quote: "You can also do inheritance with classes, and as far as I know the same cant be done with structs"


Another bet?

Quote: "Plus you arent supposed to be allowed to use functions in structs, although VC++ allows for that"


So does every other standard compliant C++ compiler available. Really, believe me, a struct *is* a class. Or more correctly, a class is a struct - classes evolved from structs.

It's far easier to implement one standard structure type than two of them after all.



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 15th Dec 2004 03:10
Quote: "There is actually a char* defined in there, but even so, I still wouldn't create a class for this - I'd use a std::string to store it."


Read above. If it wasnt for that newbie post checker...

Look I agree with both of you that there is really no need for a class if you dont have to do memory management. Although I didnt know you could define destructors in structs, so I guess it doesnt matter. But he needs to put that destructor in there if he wants to use char* vars, just to make sure they get deleted properly. Or use std::string like IanM and I said. Agreed?
gdogg2k
20
Years of Service
User Offline
Joined: 20th May 2004
Location: Cornwall, UK
Posted: 15th Dec 2004 04:24
so firstly i do draw the same window every frame, reason being is the windows will be resizable, and also the gadgets need adding and the windows can be minimized,
so are we agreed it prob. wont go n e faster
secondly using std::string name; isnt gonna help speed? or will it

If i dont know,
I'm sure you will
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 15th Dec 2004 04:54
Using std::string will just prevent memory leaks (important), but no efficiency will be gained.

As for your function, Im sure there are ways to speed it up. But I dont have the SDK yet, so I cant tell you what needs to be done.

Login to post a reply

Server time is: 2024-11-22 14:04:18
Your offset time is: 2024-11-22 14:04:18