Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 start of a gui
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ericfourfour




PostPosted: Fri Sep 15, 2006 3:01 pm   Post subject: start of a gui

Version 0.2.

Currently Has:
*Blank Buttons
*Text Buttons
*Picture Buttons
*Rotation (almost fully implemented)

Improvements:
*Blank Button (I wonder why this one came last out of the 3 buttons)
*Rotation is implemented and works (well... only with blank buttons).
*Made a generic button class
*Reorganized the variables, functions, etc.
*Various Opimizations
*Uses triangle collision detection for widgets that are angled.

To do:
*Get rotation working with picture buttons (limit to 90 degree rotation though)
*Tons of optimizations
*Move everything into separate unit files
*Change the gui module to a class so the programmer can free the gui from the memory completely if it is not needed (shouldn't be that difficult to do).

Future widgets:
(This should be in order of when I will make them)
*Scroll Bar
*Drop-Down Menu
*Check-Box
*Radio Button
*Text Field
*Text Box
*Window
*Open/Save Box

This gui will be better than the one made by Holt Soft. It will not use up all of your memory, will have no loading time, will be easy to remove widgets to lower file size, returns objects instead of id#'s, will have widget rotation (except the ones that have text, since text can't be rotated efficiently), allow the programmer to easily derive their own custom widgets, and the list goes on (and will be continued in the documentation when I feel like writing it).

It (in the next update) also gives the programmer the option whether to use action procedures or not. This is because, while I was creating the scrollbar class, it wouldn't let me use procedures that were in the class for the action procedure. So, I had to rearrange the gui and now you have the decision. Just use ap_ or nap_ before the class name (ex. nap_blank_button, ap_picture_button).


This section will be removed later and place in documentation. It is most likely out of date since I will be adding/changing/removing functions to/from the gui on a regular basis.

There are a few functions in the gui module that you should know.

code:

create_button (text : string, font, x, y, width, height : int, action_proc : proc x ()) : ^button
This creates a button object that can be displayed on the screen, clicked, etc.

code:

update () : boolean
This updates all of the widgets and returns true if it is going to continue.

code:

delete (button_object : ^button)
This deletes/removes a widget.

code:

unload ()
This unloads all of the memory allocated by the gui.

There are also a few functions in the button class that you may also want to know.

code:

move (newx, newy : int)
This moves the button to a new x, y position

code:

set_border (width, colour1, colour2, colour3 : int)
This allows you to change the width of the border, and the 3 colours. colour1 is the box around the button. colour2 is the bottom and right section of the border. colour3 is the top and left section of the border.

code:

set_body_clr (unpressed_clr, pressed_clr, mouse_over_clr : int)
This allows you to change the body colours of the button.


Suggestions or requests for widgets would be appreciated.



gui v0_2.zip
 Description:
This is gui v0.2

Download
 Filename:  gui v0_2.zip
 Filesize:  9.26 KB
 Downloaded:  112 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Fri Sep 15, 2006 3:23 pm   Post subject: (No subject)

ericfourfour wrote:

Suggestions or requests for widgets would be appreciated.


dont use action procedures, they really make it messy to try and code something (and i dont like them to begin with Razz), just allow whoever is using your gui to do whatever they want without having to go through action procedures if they are not necessary. just a little thing, but its a major problem with turings built-in gui, and when programming your own should really be avoided when possible. other than that not bad Very Happy
ericfourfour




PostPosted: Sun Sep 17, 2006 6:59 pm   Post subject: (No subject)

Okay, I thought of one idea. I would have the widget detect a change (button click, scroll, etc.) and set a flag (most likely called change) to true. Then it would return in update () that it has changed. The gui would then return in its update () that a change has happened. Finally, the main program would check the widgets and see which one has changed and it would perform an action associated to that widget.

However, I think there must be a simpler way because the main program shouldn't have to search through the widgets to find out what to do.

Any suggestions would be appreciated. I am also curious how they do it in professional gui's (links would be helpful).

Edit Googled it.

I just searched for open source gui's on google. Google actually had a list prepared. So, I looked at this one called fox-toolkit. It uses a, "Target/Message System" (click "documentation", then "targets and messages"). This system seems to be efficient but I can't comprehend it.

On the same page, it said, "the most common methods being used today are callback functions". So naturally, i googled it and got to [url=http://en.wikipedia.org/wiki/Callback_(computer_science)]this[/url] page. It turns out that callback functions are similar to action procedures (except it uses pointers?).

Unless I can figure out this, "Target/Message System", I am going to stick with what I have.
ericfourfour




PostPosted: Sat Sep 23, 2006 7:43 pm   Post subject: Coming up next

This is just an application showing what is coming up next. You can click the button in the middle to move it around and the one at the bottom left corner quits. The cool thing is that these don't use action procedures they use variables showing there status. They will be released with v0.3 along with scroll bars. I just made this to see if I could use the buttons with my scroll bars.


Test 2.zip
 Description:

Download
 Filename:  Test 2.zip
 Filesize:  280.13 KB
 Downloaded:  74 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: