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.

DarkBASIC Discussion / Dark Windows - it's making a comeback!

Author
Message
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 5th Jun 2009 16:27 Edited at: 8th Jun 2009 11:58
You might remember a thread about this back in January - I planned to create a function library that simulated windows-style buttons, checkboxes and the like by simply pasting images on screen. It didn't come to anything at the time but I'm trying a new approach and it should work quite well (in fact, this time it should even get finished!).

The attached demo shows off what I've got working - Windows forms and buttons. You can click and drag forms around by their titlebars, and also bring one to be in front of the other. There's also a form zero with no image, which fills the screen and allows you to have other components shown behind all others.

By the way, the minimise, restore, and close buttons on each form are just for show, and shouldn't really be there (a consequence of just grabbing a quick image when in Windows!).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Attachments

Login to view attachments
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Jun 2009 20:19
one thing i could suggest is instead of having things like this:



it could be one array

Frm_Data(FrmNum, X) = Var

same with the button data, it's just less dims, not a big deal.

What is the memblock for? couldn't find anything that used it.


Your error system is good when it's not a exe, but when you compile to a exe, the break command just ends the program. just saying.

Other then that, Nice work.

How are you planning on doing sizing and stuff when you use loaded images that the user picks? that seems a bit difficult

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Jun 2009 02:34
Quote: "it could be one array
Frm_Data(FrmNum, X) = Var"

That may seem simpler but it would be very hard to keep track of what each instance means. Using separate functions with descriptive names makes it easier to follow the code.

@Robert
Do you have flags for different operations (ie DragWindow=1), that way you can make sure mutually exclusive operations aren't performed simultaneously (long words there lol). For instance, you want to be able to click on a button without the window moving, so checking the button click operation first and setting its flag will allow you to prevent the window dragging. Simply add a condition to the window dragging check that all other operation flags must be false.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 6th Jun 2009 12:31
Quote: "it could be one array: Frm_Data(FrmNum, X) = Var
What is the memblock for? couldn't find anything that used it."

It's all part of my new approach to the problem. First time I tried this, I used a memblock to hold all the data - the reason was speed, as memblocks are twice as fast as arrays. Unfortunately, I often found that I'd allocate (say) 14 bytes per button and then realise I'd missed a parameter and need an extra byte - but then, every function in the library needed rewriting!

This time, the use of simple arrays means I can just add data on the fly, and then when the whole library is finalised and working flawlessly, I can convert the arrays to a memblock and double my speed!

@Caleb 1994
I only use the "Break" commands because I can't come up with any other way of allowing the system to keep working if some parameters are in error. Maybe I should just resort to defaults if an error is found, but that wouldn't tell you where the problem was...

Oh, and resizing forms isn't possible - yet. It might be if I switch to only use images that are generated by the code, but I think the time delay neede to build the newly sized image might be too much of a hit to the frame rate.

@OBese87
Thanks for the idea, I'll try that out later!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jun 2009 20:53
Quote: "then realise I'd missed a parameter and need an extra byte - but then, every function in the library needed rewriting!"


That's when a UML diagram helps, plan first then code!

If you'd like to see an example of using flags to interact with a gui as Obese mentioned, take a look at my code here: http://forum.thegamecreators.com/?m=forum_view&t=140076&b=1(newest version at bottom)

It's a simple gui, no multiple windows like yours, but it does scrollbars, resizing, file selection. Maybe it'll give you ideas on how to set up the flags in your code.

[url="http://dbcc.zimnox.com"][/url]
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Jun 2009 03:48
What i did for my functions for erros was had a error function that found a free dll and loaded up User32.dll and called a message box. or you could store a error string if you arn't going to have fatal errors. then the programmer would just have to program in how to deal with the strings.


As for the setting buttons on the title bar, why would you need a button on the title bar?

The Time for the redraw shouldn't be bad, i got about 225 fps with mine with 2 Overlapped windows and a couple buttons, drops to about 100 when you are pasting the images back to the screen, and unless you drawing like 4 windows in a row then there isn't a lag when you redrawing it.

In mine it takes 40 milliseconds to completely redraw 2 windows and repaste 3.

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th Jun 2009 12:19
Quote: "That's when a UML diagram helps, plan first then code!"

I know... I spent a lot of time planning, but I alway missed something out!
Oh, and thanks for the link - your code looks very impressive, especially for the fact that it does resizing. I may have a way of getting DW to do that, if I ignore my normal way of making images (Create Btimap, Line, Box, Get Image) and just fill data in to a memblock and make the image from that. It's just a thought, but it might work...


Quote: "As for the setting buttons on the title bar, why would you need a button on the title bar?"

Well, it's more for if you want an "X" button to close the form - if that button is clicked, the user can then hide the form!

DW's redraw time isn't bad, I was getting about 40fps on my computer with 100 forms on screen and everything was fine (Sounds low, but I just remembered - I forgot to call "Sync Rate 0" ). The real limit is the speed of "Paste Image" - it is a slow command but it's still the fastest way of getting images on screen, short of using textured 3d plains (which is not something I really want to do).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Jun 2009 23:29
Are you pasting the images every loop?

if so then you don't need to, What i am doing (which i just changed to) is Using one bitmap that the user can use to draw behind the windows, then every loop it copies that to bitmap 1 and then pastes a image of all the windows to bitmap 0, but that image has only the windows and everything else is black so i can use transperency and it works great. I got about 350 fps not doing anything with one window, i think about 50 or so with abunch of windows(Don't remember the exact number)

then you just have a function that will update that image with the images of the windows, so only do that if you need to. saves abunch of speed. and then have a hole separate process for updating each indavidual window's image that is separate from that. that way if you want to move a window then you don't have to redraw it, you just repaste the images.

as for the button on the window, Ya i geuss that makes sense, i didn't think of it cuz mine is a system thing that just closes it when you hit it.

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Jun 2009 12:15
Firstly, I've got a new demo, it's attached to the first post. New features include fully functional checkboxes, and working (though the full command set isn't there yet) Radio Buttons.

@OBese87 and Phaelax
Thanks for your help with the flags, I've got it running smoothly now. Turned out I had to have the program check for form repositioning after checking if the components had been clicked. If any components were clicked, the form couldn't be moved! Simple!

@Caleb1994
I do paste images every loop, but that's so that I can have DW there when 3d is active. I originally intended this as a GUI for Lightning Limbs, but with 3d objects active, "Paste Image" only puts the image on screen for one "Sync".

It's an interesting idea of yours, though - the only thing that bothers me is that I thought "Get image" was a slow command. I'll have to run some tests, see if one "Get image" and 100 "Paste image" on bitmap 1 is faster than 100 "Paste Image" on Bitmap 0. I'll let you know how I go on...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Jun 2009 16:12
Just a random thought but maybe you could save processing time if you "cheat" by drawing all inactive windows onto a bitmap, then keeping that as a static image and only updating the active window.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Jun 2009 18:29 Edited at: 8th Jun 2009 21:19
Obese:

That's what i was just thinking!!!!!!

Robert:

I never ran any tests on get image.... hmmmmm i'll try also just to satisfy my curiosity lol


I ran some tests,

The test reveled that getting 100 images takes 0 milliseconds, Pasting 100 images is the same.

i say go with the image and bitmap idea, it jumped my fps to 275 with 100 windows on my GUI

If you want it to work with 3d, instead of using a bitmap just have the image of the windows with a black background and paste that with transperancy, that should work right? and it would probably up your fps.

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Jun 2009 03:45
Quote: "The test reveled that getting 100 images takes 0 milliseconds, Pasting 100 images is the same."

Are you sure your code works
It will take a couple of milliseconds to run through any loop.
100 isn't really enough iteration, try at least 1000.
Or did you make a typo and it was 80 milliseconds or something.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Jun 2009 05:40


that breaks with 0

and so does paste image.

doing 1000 takes 1 millisecond for either 1.

New Site! Check it out \/
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Jun 2009 05:45
thats cause you had sync on I think, turn it off it jumps to 3000+ for 1000 (3 seconds)

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Jun 2009 06:19
Well who would run a program with sync off? lol

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 9th Jun 2009 12:56
Quote: "Well who would run a program with sync off? lol "

Any noob who hasn't read the help files!

@Caleb1994
My tests gave similar results to yours, so you are right when you say "Get image" takes zero time - it just takes less than a millisecond to execute. However, the key point is that "Sync" becomes much slower!

@All
Well, here are my test results - drawing to offscreen bitmaps, grabbing an image and pasting that to bitmap 0 is indeed faster than just drawing to screen in the first place:


I get 31Ms for bitmap 0 (about 32fps), and 20Ms for bitmap 1 (about 50fps). That's with Windows Media Player open and an mp3 playing, in place of the proper code to hike the screen fps.

That impressed me, but when I tried adding it to Dark Windows I actually got a lower frame rate than when I drew straight to the screen. I've attached an experimental copy of the library, but the important points are the start and end of the "DW_Draw_Update(Memblock)".





(The remmed out bits were an alternative method that was slightly faster, but I didn't like the idea of locking bitmap 0 in case the user still had other stuff to do after updating DW)

If I call "DW_Draw_To_Screen" and set all images to be drawn to the screen, I get 56 frames a second. If I use "DW_Draw_To_Bitmap()", placed at line 57, I only get 42/43 fps. I think it's a combination of CLS 0 and the fact that the image I draw to bitmap 0 has to be transparent. I can't come up with any faster way of redrawing all images to screen, short of writing a dll like the "lotsofsprites" example that came with DB, and I don't want to go down that road.

That brings me to OBese87's idea. It would be great to draw all inactive forms once, and keep pasting that image on screen and then draw the currently active form on top. I haven't properly tested this, but drawing one image of the screen per loop gives me 80-90 frames a second with 100 forms, and transparency enabled (Windows Media Player open again).

While this doubles my frame rate, I'm still troubled about one feature of DW that's currently under construction. You may have noticed the parameter "ClickType" when creating forms. "FormType" would be a better name for it, because in Windows there are three types of forms. There are your normal ones (like the ones already in DW - you click one, and it goes to the front), there are floating palettes (like the ones in Corel PhotoPaint, or the toolboxes that appear in MS Word/PowerPoint etc), and there are Message boxes (which always stay on top until you close them).

Message boxes are easy to add, but Palette forms are going to be tricky - they can be moved in front of normal forms, but are always active and always clickable. Any ideas?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Attachments

Login to view attachments
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Jun 2009 18:42


Well you could add a if to your pasting code so it would be:


No reall code of course but you get the idea.

Oh and there are 2 different styles for Windows forms that would fit your discription:

WS_EX_TOOLWINDOW

and

WS_EX_PALETTEWINDOW

I am looking on msdn to see if theres a difference(sometimes 2 style mean the same thing lol) just to make sure.


Heres the stuff from MSDN


WS_EX_TOOLWINDOW


WS_EX_PALETTEWINDOW



Just putting that out there, cuz it confused me for a second. lol


Quote: "i say go with the image and bitmap idea, it jumped my fps to 275 with 100 windows on my GUI"


Quoting and corecting myself, i got 275 fps with like 15 to 20 overlapped windows on mine 100 got about 100 fps. just saying, i know it doesn't have anything to do with this post but, it was a lie! lol. i wish i got 275 with 100 windows

New Site! Check it out \/
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Jun 2009 20:30
btw caleb, im not sure if i was accidental or not but u put the quote into a code snippet instead of a quote box, if you dont know how to make a quote box like this:

Quote: "Quote Here"


its the same process as code snippet but hit the quote button instead of the code button

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Jun 2009 23:08
Oh whoops ya i kmew how i just hit the wrong 1

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Jun 2009 21:42
@Caleb1994

That code was a brilliant idea, exactly what I'm after now I've stopped and thought about how Palette forms actually behave. Only snag is, I'm not sure how to implement it and keep things nice and fast.

I draw all "background" normal forms to an offscreen bitmap, grab that as a static image and keep pasting it on screen, then drawing the topmost form. Now, Palette forms are always drawn over normal forms - so I now need a fast way of putting all these extra forms on top of this "Topmost Form".

Pasting them individually will be too slow, as I found before. But if I repeat the process I used for normal forms:

the computer is going to start to struggle. I've found that if I paste a typical 1024x768 image on screen twice per sync (transparency enabled) then frame rate drops from 90fps to about 40-50fps, which is perhaps a little slow - especially as a user would have other things to do each loop as well.

I'm completely out of ideas on this, maybe I should just scrap the idea of these floating toolboxes?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 10th Jun 2009 22:03
Quote: "the computer is going to start to struggle. I've found that if I paste a typical 1024x768 image on screen twice per sync (transparency enabled) then frame rate drops from 90fps to about 40-50fps"


Why 2?


Hmmmmm....


So your Drawing all the "Normal Forms" to a offscreen bitmap and then getting a image, pasting that then pasting the Tool/Palette Forms every loop? why not just paste all of them to a offscreen bitmap, get that image, paste that, then only update it when NEEDED, that should help fps, oh and don't rely on 1024x768 as i don't think very many people use that on db. i havn't really seen any programs that do.

I did that with mine and thought my frame rate sucked! then i changed back to 640x480 and it jumped up! I would say work on getting the frame rate up on 640x480 as much as possible then if needed work on the 1024x768 part.

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Jun 2009 23:15
Lowering the resolution will increase speed but I don't think 640x480 is really big enough for a decent looking program.
Maybe you could have the option to change resolution for people with slower machines.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Jun 2009 00:21
Well He is making functions for other programmers to use so it's up to the programmer to change the resolution/have options but i'm just saying, i havn't seen much db stuff that's not in 640x480(probly because people are to lazy to change it lol)

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Jun 2009 00:49
If at all possible avoid get image if you are using offscreen bitmaps. Sometimes you may have to. Use copy bitmap instead.

Something to consider which I believe has been stated earlier is only update what is being worked on. Never redraw anything that you don't have to. If you have 10 windows, assumingly they are overlapped somehow. You never redraw what is hidden behind other windows. That means, the image of all the windows oeverlapped and stacked should be drawn on it's own bitmap. You copy this bitmap to the main view and do no additional drawing unless you have to. If a user is clicking in a box, only update the box. If the user is clicking on a button, only update the button. in the case of a scroll bar, you'll probably have to update the whole window. If you are working with 2d and 3d, keep the windows above the 3d. I'm not sure why you are using transparency for the windows. If you need to see through a window, that would be an exception.

Have flags for that in which case you'd have to use individual images to copy and paste.

Once a window is created, all the controls, buttons, whatever should only be part of the picture of the window until someone tries to interact with them. If you are running functions and code and redrawing controls when a window is displayed, you are wasting resources. The only time a control has to function is when someone clicks on it, otherwise it is just a picture as part of the window. So the whole window with it's controls should be one thing. And if it covers another window, that window underneat should not be redrawn until part or all of it is visible.

Anyway, there's some ideas to chew on if you haven't already taken a bite.

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Jun 2009 05:08
You would need a Get Image Command in my oppinion so that you can have the user draw behind the windows,

Paste all images to a off screen bitmap(background RGB(0,0,0))
Get the image
Every loop copy the background bitmap and Paste the image with transperency that preserves the background.


Just a thought, Would it be possible, when updating a window to check each pixel to see if it needs to be pasted then if so show that pixel of the. that way, it would only draw the parts of the window thats showing. don't know if it would be 2 slow or what.... just a thought.

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 17th Jun 2009 19:08
Hadn't realised it had been so long - a curious combination of internet connection going down, and then a friend needed help with his computer and by the time I'd finished I was in no mood to face programming! But that's not to say I haven't been thinking about DW - far from it, I think I have it all worked out.

My original idea was to create an image of all the normal forms, and another image of all the palette forms and paste both on screen (hence the two 1024x768 images) but that won't work (as I said, it's too slow).

So I now have a two stage plan. First, to optimise the draweing of both forms and components, I'll create an image of the normal form with all it's components on it. When the form is drawn, only the one image must be pasted on screen.

Second, I'll take Latch's advice and only draw what needs to be drawn. When a button is pressed, two image will be generated. One shows the static backdrop, with everything as normal. The other will be exactly the same, but with the button pressed. Depending where the mouse is, DW will paste the image showing all forms plus pressed button, or all forms plus unpressed button.

As far as moving forms goes, the approach has to be a little more CPU intensive. All forms below the form currently being dragged around will be on a static bitmap, while the moving form and any forms above it will be redrawn straight to the screen.

I don't think it would be wortwhile redrawing just one or two forms that have been intersected by the current moving form, as that would mean redrawing the entire screen anyway.

I'll hopefully have a working demo in the next day or so, I'll let you know how I go on.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Jul 2009 22:42
Ok, It's been a while but I've not given up on this yet. I got the draw to bitmap function working, but decided to throw in textboxes before I next posted (thought they'd be easy to add! )

After about a months work, I'm quite proud of how they've turned out - as in windows, you can slide left or right using the arrow keys, use the "Home", "End" and "Delete" Keys, and even the backspace key!

There's only one snag - DBC's "Text Width()" command is broken:


As you can see, the two texts are different widths, but it only lists the same width - the text width of the last piece of text drawn to screen. DW uses the text width to work out how many characters can be shown, clicking twice, or calling sync after changing text size) will clear the problem and reset DW, but it isn't really satisfactory.

Does anyone know if there's a workaround, or should I just restrict DW to only one font size?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Attachments

Login to view attachments
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Jul 2009 05:55
Quote: "There's only one snag - DBC's "Text Width()" command is broken"

It's not broken that's just how it works. It returns the length in pixels of the string in default size or size 1 I can't remember.
Multiply the length by the font size or a factor of it and you'll correct it.
I did this ages ago but I think it was on my old pc which is in the bin

TGC Forum - converting error messages into sarcasm since 2002.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Jul 2009 07:42
@Robert The Robot

You have to call sync after you change the font and width for the text adjustment to register internally:



Enjoy your day.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 9th Jul 2009 13:57
Quote: "It's not broken that's just how it works"

No, I'm afraid it is broken (they fixed it for DBPro!) "Text Width" behaves as though all of the "Set Text Size" commands were placed at the top of the loop, and then it calculates the size of your text string based on the last font size set. "Get Text Size()" also shows this problem:


I've tried your idea of scaling the text width, but with no luck - the scale fctor in this case is approximately 2 (font size doubles), but then you have to multiply by something like 1.05. Unfortunately, the value changes from font to font, and also breaks down at large font sizes.

So, I don't think there's a proper fix - Latch's idea of just calling Sync is a good one, but it won't work for DW. If I called Sync on changing the text font, the screen would start flickering like crazy bacause not every form would be pasted on screen each Sync.

I think I'll have to restrict users to just one font and one font size, and hope that it's not too limiting. It's a little irritating, but I suppose it can't be helped.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Jul 2009 21:38
If you set the font, draw the window offscreen, capture it as an image, memblock, or leave it offscreen, you can have multiple windows with multiple fonts being drawn pasted, copied, to the main view.

I don't understand why you would be constantly setting a font in a loop, unless I'm missing your point. A single font setting won't cause the screen to flicker. The forms that aren't pasted to view would be hanging around in memory already drawn with their respective fonts.

Enjoy your day.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 13th Jul 2009 19:03
Hi Latch, just read your post and you've got some good ideas, I'm just not sure I can work them in to DW. I did consider a "Lock Form" command, where the form and all its components would be grabbed as a single image that could be pasted on screen. The only problem was that it wouldn't be able to handle overlapping components (not that they should overlap, but it has been of use to me now and again).

The main idea behind DW was to paste every window, then paste the components one at a time. Textboxes require an image to be pasted, and then the text drawn on top - if I had two textboxes with different font sizes, that would mean changing the font settings between drawing each textbox.

Now, when I click a textbox, it recalculates how many characters to show based on how many pixels wide the string of text is so that editing can start. Text Width() uses the last font size shown in the entire Do : Loop, and will only be correct for my textbox if a sync is called after setting the font. Now if I still have two forms to draw when I call Sync, those two forms will "Vanish" for a split second - that's the flicker I was talking about. Not only that, a user might have other stuff to do before Sync came, so it still wouldn't work.

That said, though, I've just had a thought - If, at the end of the entire DW Drawing cycle, I was to call "Set Text Size" and set it to the font size that the selected text box has, the text width commands would return the right values I needed! Maybe Font changes are possible after all!!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Jul 2009 19:56
I heard somewhere that you could multiply the size returned by text width() by some factor, and it would make it the real one. idk though.

Another option is to store all the sizes of each letter in each size in data statements then just read them out and create your own text width function.

New Site! Check it out \/
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Jul 2009 20:33
just a theory but this sounds right:

currentsize = the current text size
defaultsize = the default text size (idk what it is)

realwidth = textwidth(string$) * (currentsize/defualtsize)

sounds right, establishes a ratio from the current size to the default then multiplies the width by that ratio

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Jul 2009 07:33
Thats what i was thinking.i will test it real quick.

New Site! Check it out \/
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 14th Jul 2009 08:05 Edited at: 14th Jul 2009 08:05
yep, I just tested it and it does work

also the default size is 10

edit:

sorry caleb just saw your post, didnt mean to steal your thunder there

Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 14th Jul 2009 11:54
Thanks guys, will try that out as well!

I've already managed to test my own idea, this is what I got:


If I set the text size at the end, the first line of text is given the correct width. I'm just not too where to put that new line in DW!

BTW - with your ideas, does it still work if you change font?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Jul 2009 18:14
Quote: "sorry caleb just saw your post, didnt mean to steal your thunder there"


It's cool, you actually found out how to do it, i just said i think it's possible lol.

Quote: "I've already managed to test my own idea, this is what I got:"


It's returning 225 for the size on both, and 50 for the size on both.

Hey comet can you upload the working code cuz i tried and it didn't work.

New Site! Check it out \/
Brick Break
User Banned
Posted: 21st Jul 2009 06:25
Is DarkWindows really making a comeback? It looks more like it's falling back! I'm bumping this thread in order for Robert the Robot to make a reply. Rob, judging by previous messages, it seems you have accidentally forgotten about the project. Well, here's a reminder.

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 21st Jul 2009 12:00
Sorry, I've not forgotten. Just had a minor crisis with my computer - I think the hard drive's going, but I've managed to salvage all my data. It's a pity too, I was all set to post a new demo but that's going to have to wait now.

Anyway, I've tried playing about with the rescaling of the text, and I've tried my idea of setting the text size again at the end of the loop, but "Text Width()" still breaks down. So, the upshot is that you're stuck with just one font in the whole project. It's an annoying niggle, but I can't find any way around it.

I've fully implemented textboxes, numboxes (that's textboxes, where you only type in numbers) and also Spin Edit Boxes. I'm just starting to work on Sliders and trackbars, and then I think it'll be finished. I promise to keep you posted!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Brick Break
User Banned
Posted: 21st Jul 2009 20:05
Awesome! Um, good luck with your computer.

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st Jul 2009 23:59
@Robert the Robot
Did you ever look at Magic Windows by freddix? I think it can have multiple text size in multiple windows. Some of the coding in there may be helpful.

Enjoy your day.
Brick Break
User Banned
Posted: 22nd Jul 2009 00:32
Hey, I made this function a while ago. It sets the program to a special fullscreen mode where The bitmap doesn't get erased, the full monitor resolution is used, and you can switch between windows quickly. I think it might be useful for DarkWindows.


WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jul 2009 15:56
In the past, I've played with 'emulating" windows a couple of times in DB with some success - I have a set of (incomplete) window functions and a drag and drop form designer I based on Delphi.

But, they have remained incomplete because I just couldn't think of a way to actually use the functions other than to create pretty windows.

Here's an exe of an early version I found:

Window in DBC demo

Not everything works correctly, but it does have gadgets and custom resize cursors.

Out of interest, when your project is finished, how can you see it being used by others?

TDK

Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 24th Jul 2009 16:22
@Latch
Found it yesterday, but it appears that only one text font size is ever allowed (the code's a bit tricky to follow, I don't know any French, but never mind). You can change the size, but it's a global setting like mine. I just don't think it can be done in DBC.

BTW - wasn't Freddix the one who made a level editor that's in the DBC showcase? It was brilliant, but I could never figure out the Load Level function.

@Brick Break
Nice function, I'll possibly include it as an addon command, but it only affects how the main program appears and not how any "Windows" DBC draws to the screen.

@TDK
Thanks for the demo, I'll take a look at it later. Is is based on your GUI library?

My ultimate aim is to simplify application building - my Lightning Limbs project could have had its GUI done in about 3 days instead of 3 weeks if I had DW. A Delphi style GUI builder is in the pipeline, once I get all of DW finished and converted to run from a memblock.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jul 2009 17:00
Quote: "Is is based on your GUI library?"


No - the demo I posted is a set of window functions written specifically for doing what I think you are doing.

Quote: "A Delphi style GUI builder is in the pipeline, once I get all of DW finished and converted to run from a memblock."


That sounds a lot easier than it actually is!



TDK

Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 24th Jul 2009 21:15
Wow, group boxes, tables and grids as well! I really have got a lot more to do! (Don't suppose you'd want to share some code, would you? )

Quote: "That sounds a lot easier than it actually is!"

Don't I know it...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Jul 2009 22:23
@RTR
In regards to Magic Windows, it does allow multiple text fonts and sizes for each window. See attachment.

There is a word document with the description of each function in english. If you use that and then look at the code in the functions, you could probably figure it out.

Enjoy your day.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-20 05:32:16
Your offset time is: 2024-05-20 05:32:16