Line 1:
Line 1:
== Foreward ==
== Foreward ==
−
LibwiiGui is written in C++ and uses classes. Classes are a collection of functions and variables related to a single thing. When using these classes, their collected functions and variables (if they are declared public) can be accessed by a dot (.) in some cases, and an arrow (->) in other cases. This will become more understandable later on in the tutorial, but for now, know that when the class instance is created with an asterisk (*) before it, you will be using the arrow (->). When the class is created without the asterisk, you will use the dot (.).
+
LibwiiGui is written in C++ and uses classes. Classes are a collection of functions and variables related to a single thing. You work with classes by creating instances of them, called ''objects''. When using these objects, their public functions and variables can be accessed by a dot (.) in some cases, and an arrow (->) in other cases. This will become more understandable later on in the tutorial, but for now, know that when the object is created with an asterisk (*) you will be using the arrow (->), and when the object is created without the asterisk you will use the dot (.).
This tutorial uses the same design as the demo included with libwiigui. Every menu is created inside a function. The GUI updating routine is created as a function, and is in a thread. When wanting to change to a new menu, you set the menu variable to a value that denotes the menu you wish to change to. Again, this will become more apparent later on.
This tutorial uses the same design as the demo included with libwiigui. Every menu is created inside a function. The GUI updating routine is created as a function, and is in a thread. When wanting to change to a new menu, you set the menu variable to a value that denotes the menu you wish to change to. Again, this will become more apparent later on.
Line 14:
Line 14:
<source lang = "text">
<source lang = "text">
−
sudo gedit /usr/bash.bashrc
+
gedit ~/.bashrc
</source>
</source>
Line 30:
Line 30:
If you haven't already done so, [http://code.google.com/p/libwiigui/downloads/list download] libwiigui. You can extract this anywhere, as this is where your source will be for your entire project. You also will need to [http://code.google.com/p/libwiigui/downloads/list download] the required devkitpro libraries. Extract these to your libogc folder (should be devkitPro/libogc) overwriting any existing files.
If you haven't already done so, [http://code.google.com/p/libwiigui/downloads/list download] libwiigui. You can extract this anywhere, as this is where your source will be for your entire project. You also will need to [http://code.google.com/p/libwiigui/downloads/list download] the required devkitpro libraries. Extract these to your libogc folder (should be devkitPro/libogc) overwriting any existing files.
−
== Class Creation ==
+
== Object Creation ==
−
There are two ways a class instance can be created. LibwiiGui uses both methods. When you want a class to be able to be accessed by any other function, you will want to create it with an asterisk, which declares a pointer to your class. You will want to use this for your main GuiWindow, which should contain the background, and every other window (these other windows will be your menus). You also will want to initially set it to NULL for safety's sake.
+
There are two ways an object (an instance of a class) can be created. We will use both methods when working with LibwiiGui. When you want an object to be able to be accessed outside of the function where it was made, you will want to create it with an asterisk, which declares a pointer to your object. You will want to use this approach for your main GuiWindow, which should contain the background and every other window (these other windows will be your menus). You also will want to initially set it to NULL for safety's sake:
<source lang = "cpp" >
<source lang = "cpp" >
Line 38:
Line 38:
</source>
</source>
−
These declarations should be at the top of the file, underneath the includes. Then, when using it, you will use ->
+
These declarations should be at the top of the file, underneath the includes. Then, when calling the object's functions, you will use ->:
<source lang = "cpp">
<source lang = "cpp">
−
mainWindow->Append(image);
+
mainWindow->Append(&someElement);
</source>
</source>
−
If you have a class that is only relevant to the function you are in (e.g. a menu) you will want to declare the instance inside the function:
+
In the above code, we are adding an object called someElement to mainWindow, using mainWindow's Append function.
+
+
If you want an object that is only relevant to the function you are in (e.g. a menu), you will want to declare the instance inside the function:
<source lang = "cpp">
<source lang = "cpp">
Line 53:
Line 55:
</source>
</source>
−
and then use the dot:
+
Then use the dot (.) to operate on the object
<source lang = "cpp">
<source lang = "cpp">
Line 65:
Line 67:
== The GuiElement ==
== The GuiElement ==
−
Every class instance you create, save for a GuiSound, GuiTrigger, or a GuiImageData, will be inherited from the GuiElement class. This means that you can use any GuiElement function in any GuiElement you use, allowing you to move, get the width of, and get the state of images, buttons, keyboards, option browsers, etc. The GuiElement (from libwiigui/gui.h) class defines the following public functions which you can use with any GuiElement:
+
Every LibwiiGui object you create (except for GuiSound, GuiTrigger, and GuiImageData) will inherit from the GuiElement class. This means that you can use any GuiElement function in any GuiElement you use, allowing you to move, get the width of, and get the state of images, buttons, keyboards, option browsers, etc. The GuiElement (from libwiigui/gui.h) class defines the following public functions which you can use with any GuiElement:
<source lang = "cpp">
<source lang = "cpp">
//!Constructor
//!Constructor
−
GuiElement();
GuiElement();
//!Destructor
//!Destructor
−
~GuiElement();
~GuiElement();
//!Set the element's parent
//!Set the element's parent
−
//!\param e Pointer to parent element
//!\param e Pointer to parent element
−
void SetParent(GuiElement * e);
void SetParent(GuiElement * e);
//!Gets the element's parent
//!Gets the element's parent
−
//!\return Pointer to parent element
//!\return Pointer to parent element
−
GuiElement * GetParent();
GuiElement * GetParent();
//!Gets the current leftmost coordinate of the element
//!Gets the current leftmost coordinate of the element
−
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
−
//!\return left coordinate
//!\return left coordinate
−
int GetLeft();
int GetLeft();
//!Gets the current topmost coordinate of the element
//!Gets the current topmost coordinate of the element
−
//!Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values
//!Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values
−
//!\return top coordinate
//!\return top coordinate
−
int GetTop();
int GetTop();
//!Sets the minimum y offset of the element
//!Sets the minimum y offset of the element
−
//!\param y Y offset
//!\param y Y offset
−
void SetMinY(int y);
void SetMinY(int y);
//!Gets the minimum y offset of the element
//!Gets the minimum y offset of the element
−
//!\return Minimum Y offset
//!\return Minimum Y offset
−
int GetMinY();
int GetMinY();
//!Sets the maximum y offset of the element
//!Sets the maximum y offset of the element
−
//!\param y Y offset
//!\param y Y offset
−
void SetMaxY(int y);
void SetMaxY(int y);
//!Gets the maximum y offset of the element
//!Gets the maximum y offset of the element
−
//!\return Maximum Y offset
//!\return Maximum Y offset
−
int GetMaxY();
int GetMaxY();
//!Sets the minimum x offset of the element
//!Sets the minimum x offset of the element
−
//!\param x X offset
//!\param x X offset
−
void SetMinX(int x);
void SetMinX(int x);
//!Gets the minimum x offset of the element
//!Gets the minimum x offset of the element
−
//!\return Minimum X offset
//!\return Minimum X offset
−
int GetMinX();
int GetMinX();
//!Sets the maximum x offset of the element
//!Sets the maximum x offset of the element
−
//!\param x X offset
//!\param x X offset
−
void SetMaxX(int x);
void SetMaxX(int x);
//!Gets the maximum x offset of the element
//!Gets the maximum x offset of the element
−
//!\return Maximum X offset
//!\return Maximum X offset
−
int GetMaxX();
int GetMaxX();
//!Gets the current width of the element. Does not currently consider the scale
//!Gets the current width of the element. Does not currently consider the scale
−
//!\return width
//!\return width
−
int GetWidth();
int GetWidth();
//!Gets the height of the element. Does not currently consider the scale
//!Gets the height of the element. Does not currently consider the scale
−
//!\return height
//!\return height
−
int GetHeight();
int GetHeight();
//!Sets the size (width/height) of the element
//!Sets the size (width/height) of the element
−
//!\param w Width of element
//!\param w Width of element
−
//!\param h Height of element
//!\param h Height of element
−
void SetSize(int w, int h);
void SetSize(int w, int h);
//!Checks whether or not the element is visible
//!Checks whether or not the element is visible
−
//!\return true if visible, false otherwise
//!\return true if visible, false otherwise
−
bool IsVisible();
bool IsVisible();
Line 393:
Line 358:
</source>
</source>
−
Most functions are pretty self-explanatory. Some you will not use often, while others you will be using all the time (like SetPosition). Remember, you will want to use these functions with the upper-most class you can. For example, if you set GuiImageData to a GuiImage, and then set the GuiImage to a GuiButton, you will want to set the position of the GuiButton, not the GuiImage.
+
Most functions are pretty self-explanatory. Some you will not use often, while others you will be using all the time (such as SetPosition). Remember, you will want to use these functions with the upper-most class you can. For example, if you set GuiImageData to a GuiImage, and then set the GuiImage to a GuiButton, you will want to set the position of the GuiButton, not the GuiImage.
−