6. Ring Documentation, Release 1.9
QString displayText(void)
bool dragEnabled(void)
int echoMode(void)
void end(bool mark)
void getTextMargins(int *left, int *top, int *right, int *bottom)
bool hasAcceptableInput(void)
bool hasFrame(void)
bool hasSelectedText(void)
void home(bool mark)
QString inputMask(void)
void insert(QString)
bool isModified(void)
bool isReadOnly(void)
bool isRedoAvailable(void)
bool isUndoAvailable(void)
int maxLength(void)
QString placeholderText(void)
QString selectedText(void)
int selectionStart(void)
void setAlignment(int flag)
void setCompleter(QCompleter *c)
void setCursorMoveStyle(int style)
void setCursorPosition(int)
void setDragEnabled(bool b)
void setEchoMode(int)
void setFrame(bool)
void setInputMask(QString)
void setMaxLength(int)
void setModified(bool)
void setPlaceholderText(QString)
void setReadOnly(bool)
void setSelection(int start, int length)
void setTextMargins(int left, int top, int right, int bottom)
void setValidator(QValidator *v)
QString text(void)
QMargins textMargins(void)
QValidator *validator(void)
void clear(void)
void copy(void)
void cut(void)
void paste(void)
void redo(void)
void selectAll(void)
void setText(QString)
void undo(void)
void setTextChangedEvent(const char *)
void setcursorPositionChangedEvent(const char *)
void seteditingFinishedEvent(const char *)
void setreturnPressedEvent(const char *)
void setselectionChangedEvent(const char *)
void settextEditedEvent(const char *)
Note: Most of the content of the previous configuration file is removed from this documentation, for a complete
version see the Ring source code distribution.
82.19. Configuration file for the Qt Framework 924
7. Ring Documentation, Release 1.9
82.20 Static Methods
Starting from Ring 1.8 the code generator support the staticmethods option.
So the code generator can know that the class doesn’t need an object to call the methods.
Example:
<class>
name: QStandardPaths
para: void
nonew
staticmethods
</class>
QString displayName(QStandardPaths::StandardLocation type)
QString findExecutable(QString executableName, QStringList paths))
82.21 Loading Files
Starting from Ring 1.9 the code generator support the <loadfile> command.
<loadfile> filename.cf
This is useful to separate the extension configuraition file to many files
Example:
The file : qt_module_network.cf in the RingQt Extension
<comment>
Module (network)
</comment>
<loadfile> qabstractsocket.cf
<loadfile> qnetworkproxy.cf
<loadfile> qtcpsocket.cf
<loadfile> qtcpserver.cf
<loadfile> qhostaddress.cf
<loadfile> qhostinfo.cf
<loadfile> qnetworkrequest.cf
<loadfile> qnetworkaccessmanager.cf
<loadfile> qnetworkreply.cf
82.22 Managed Classes
Starting from Ring 1.9 the code generator support the <managed> option when defining classes.
Using this option, the generator will use RING_API_RETMANAGEDCPOINTER() to return the C pointer.
So the Garabage Collector will manage these C pointers.
Example
82.20. Static Methods 925
8. Ring Documentation, Release 1.9
<class>
name: QFont
para: QString, int, int, bool
managed
</class>
82.23 Configuration Files Examples
You can learn from the next examples
• RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf
• RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/classes/qt.cf
• RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/libsdl.cf
After modifing the configuration file, You will need to generate the code, You can learn from the next examples
• RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat
• RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat
• RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/gencode.bat
After generating the code, You will need to build the library, You can learn from the next examples
• RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat
• RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat
• RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/buildvc.bat
82.23. Configuration Files Examples 926
9. CHAPTER
EIGHTYTHREE
CREATE YOUR FIRST EXTENSION
In this chapter we will create RingBeep
RingBeep is a simple extension for the beep() function in Windows API
Just a simple example about creating extensions
83.1 Location
You will find this extension in the ring/extensions/ringbeep folder
83.2 Steps to create the extension
At first we write the configuration file in : ringbeep.cf
notepad ringbeep.cf
The file ringbeep.cf contains
<code>
#include "windows.h"
</code>
int Beep(int dwFreq,int dwDuration)
Then we run : gencode.bat to generate ringbeep.c
gencode.bat
The gencode.bat contains the next command to call Ring Extensions Generator
ring ..codegenparsec.ring ringbeep.cf ringbeep.c
Then we build the extension using :
buildvc.bat
The file buildvc.bat contains the next commands to build the extension using Visual C/C++
cls
call ../../src/locatevc.bat
cl /c /DEBUG ringbeep.c -I"....include"
link /DEBUG ringbeep.obj ....libring.lib kernel32.lib /DLL /OUT:ringbeep.dll ^
927
10. Ring Documentation, Release 1.9
/SUBSYSTEM:CONSOLE,"5.01"
del ringbeep.obj
83.3 Testing the extension
Then we test the function using
ring test.ring
The file test.ring contains
loadlib("ringbeep.dll")
for f = 750 to 1000 step 50
beep(f,300)
next
83.3. Testing the extension 928