The Ring Programming Language Version 1.5.1 Book - Part 67 of 180
The Ring Programming Language Version 1.5.1 Book - Part 67 of 180
The Ring Programming Language Version 1.5.1 Book - Part 67 of 180
TD { text("Sales" ) }
TD { text("Future" ) }
}
next
}
}
write("report.html",mypage.output())
func PrintEvent
printer1 = new qPrinter(0) {
setoutputformat(1)
setoutputfilename("report.pdf")
}
oView {
web.print(printer1)
web.show()
}
system ("report.pdf")
class CustomersReportView
Screen Shot:
55.60. Creating Reports using the WebLib and the GUILib 635
Ring Documentation, Release 1.5.1
55.60. Creating Reports using the WebLib and the GUILib 636
CHAPTER
FIFTYSIX
In this chapter we will learn about Building RingQt Applications for Mobile.
Update the Android SDK to get the API and tools packages required for development
637
Ring Documentation, Release 1.5.1
Note: All of the missing libraries ((LibCurl, OpenSSL & Allegro) can be compiled for Android, but they are not
included in this Qt project.
3. use if isandroid() when you want to modify the code just for android
Example:
if isandroid()
// Android code
else
// other platforms
ok
(4) Sometimes you will find that the button text/image is repeated in drawing ! its Qt problem that you can avoid
using the next code.
if isandroid()
setStyleSheet("
border-style: outset;
border-width: 2px;
border-radius: 4px;
border-color: black;
padding: 6px;")
ok
5. Always use Layouts instead of manual setting of controls position and size.
This is the best way to get the expected user interface to avoid problems like (controls with small/extra size)
6. When you deal with Qt Classes you can determine the images from resources (you dont need to copy them
using main.cpp)
Example:
if isandroid()
mypic = new QPixmap(":/resources/cardsimage")
else
mypic = new QPixmap("cards.jpg")
ok
In the previous example, cards.jpg is added to the resources then we write the cardsimage as alias for cards.jpg
FIFTYSEVEN
In this chapter we will learn about the objects library for RingQt applications.
Ring comes with the Objects library for RingQt applications. Instead of using global variables for windows objects
and connecting events to objects using the object name, the Objects Library will manage the GUI objects and will
provide a more natural API to quickly create one or many windows from the same class and the library provide a way
to quickly set methods to be executed when an event is fired. Also the library provide a natural interface to quickly
use the parent or the caller windows from the child or sub windows.
The Objects Library is designed to be used with the MVC Design Pattern.
The Objects Library is merged in RingQt so you can use it directly when you use RingQt
57.2 Example
640
Ring Documentation, Release 1.5.1
The User Can click on the button many times to open many sub windows.
Each Sub Window contains Two buttons.
The first button in the sub window change the Main and the Sub Windows Titles.
The second button in the sub window close the Sub Window.
load "guilib.ring"
new qApp {
open_window( :MainWindowController )
exec()
}
The next screen shot after clicking on the button in each sub window.
We can use the Open_WindowAndLink() function to connect between the application windows, pass messages (call
methods) between the objects.
This function uses Meta-programming to define dynamic methods in the Caller Class to use the dynamic objects of
other windows that we create.
Example : (Uses the Form Designer)
First Window
1. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/twowindowspart5/firstwindowView.ring
2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/twowindowspart5/firstwindowController.ring
Second Window
1. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/twowindowspart5/secondwindowView.ring
2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/twowindowspart5/secondwindowController.ring
func OpenSecondWindow
Open_WindowAndLink(:SecondWindowController,self)
func SendMessage
if IsSecondWindow()
SecondWindow().setMessage("Message from the first window")
ok
The Open_WindowInPackages() function is the same as Open_Window() but takes an extra list that determine the
packages to import before opening the window.
Syntax:
Open_WindowInPackages(cClassName,aPackagesList)
Example:
The next example from the Form Designer source code, Open the Window Flags window using the
open_windowInPackages() function.
We determine the class name WindowFlagsController and the packages name.
The Window Flags window uses the FormDesigner and System.GUI packages.
open_windowInPackages(:WindowFlagsController,[
"formdesigner",
"System.GUI"
])
The library source code is very simple, You can check the source code files
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/objects.ring
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/subwindows.ring