You are herepremiers pas
premiers pas
Getting started with MSEide+MSEgui
by Jean-Pierre Anghel - 2009
Introduction
What MSEide and MSEgui?
It is a visual programming tool that, like the famous Delphi Borland Pascal language is. GNU license requires, Pascal used here is Pascal. Special very interesting compilation of programs is also well under Windows ® Linux keeping the same visual results under both OS. The trick, so to speak, was to build a portable graphics library on both systems using the primitives lowest possible level of these two systems: Win32 for Windows and Linux X11.
Another surprising feature is a single person who is behind this tool: a Swiss named Martin Schreiber .
Installation
Whether Windows or Linux, you must first install Freepascal. We will speak here of version 2.0 of MSEIde + MSEGui and fpc versions 2.2.2 or 2.2.4 Pascal compiler are compatible with this version. You will find the site www.freepascal.org installation files for each OS, a self-installing Windows and various versions of Linux.
Freepascal existing Debian packages there should be no problem to install on most Linux distributions.
Everything that follows was tested on Linux Pup (Puppy Linux), an ultra lightweight version of Linux. Tutu on Linux you'll need in addition to installing a linker included in the package developement devx_411.sfs (411 being the version number of Puppy) that you find at:
Then download the ESM files on the SourceForge site. You will find all the information on the official website of MSE:http://homepage.bluewin.ch/msegui/
Note that gradually builds as a wiki: http://wiki.freepascal.org/MSEide_&_MSEgui/
and recently there an official site: http://msegui.org
Once both files mseide_bin_ and mseide_msegui_src_ *. zip *. zip in your possession:
Linux:
Extract the files in the directory of your choice: for example, "MSE".
Launch MSE/bin/i386-linux/mseide
Click on "Settings" - "MSEide Configure" and put the alias "$ (MSED)" to "MSE / msegui.
Click on "Project" - "Open" and choose "MSE / msegui / apps / demo / demo.prj"
Click on "Target" - "Continue" (or the green arrow) and run in the debugger.
Windows:
Download and install the GDB debugger (see official website MSE), in fact MinGW.
Extract the files MSE in the directory of your choice: eg "C: / MSE.
Run C: / MSE/bin/i386-win32/mseide
Click on "Settings" - "MSEide Configure" and put the alias "$ (MSED)" to "C: / MSE / msegui.
In the same dialog box set the alias "$ (COMPILE)" at the file '. Exe' compiler
fpc: C: / fpc/2.2.2/bin/i386_win32/ppc386.exe
In the same dialog box set the alias "$ (DEBUGGER)" at the file '. Exe' file
GDB: C: / MSE / gdb / bin / gdb.exe
Click on "Project" - "Open" and choose "MSE / msegui / apps / demo / demo.prj"
Click on "Target" - "Continue" (or the green arrow) to build "Demo.exe" and engage in debugger.
Whether Linux or Windows you will get the same result ie a window with a button above with the inscription "Exit".
Foreword
All too often the "Getting Started with ..." simply displays "Hello world" in a window with (or not!) A close button and you get by leaving you alone for the rest. Instead, we will build an entire program, functional, using some properties of MSE. It is of course not possible to use all the features of MSE, it would take a whole book. But at the end of this text you can throw farther, the important thing is you "put your foot in the stirrup," the online help or not is at present virtually nonexistent.
Early explanations are therefore the most detailed possible and fade gradually to avoid repetitions and not linger on what has not been seen before. The analysis of source code in the IDE you will understand many things. The Object Inspector also!
This example is part of a comprehensive program dedicated to genealogy which explains the presence of odd tools and reading text files in a grid.
First Step
The first image you see when launching the program is an image like this:

Figure 1
If you see a little more than that, it's a program (eg a demo) has already been executed and you see an image like this:

Figure 2
The upper band indicated in parentheses under the current program.
To put the clean click "Project" then "Close".
Exit the program ( "File" then "Exit") and restart it. The image in Figure 1 appears.
Note:
MSE uses an initialization file located in Windows:
C: / Documents years settings / username / Application Data / .mseide / msewi.sta
Linux:
root / .mseide / mseideli.sta
This file stores the last executed application and then opens automatically at startup.
Start:
To create a project, if there is already a picture displayed on the screen do as above: "Project" - "Close" then / else do "Project" - "New" - "From template" and select "default.prj.
To open an existing project to "Project" - "Open" and scroll through directories with the help of the arrow "Up". Accustomed to the attention of Windows: one click on the icons directory to grow!
In what follows we will explain the construction of a project using the attached files in the folder "Demo" from this tutorial. By opening the project as stated above you can view different files in the IDE MSE.
The Menu
A Honor to whom honor. Let's start by installing a menu that will then allow us, by clicking on its items, launching various operations.
To install a widget on the form nothing more simple: just select the palette component ( "Component Palette"). At the tab "Dialog" choose the widget TMainMenu. A click above the button goes in, click on the form and TMainMenu is deposited on the latter. Everything is then in the Object Inspector. The menu will be built in cascade developing and closing properties, indentation facilitates understanding. For a menu "classic", that is to say, horizontally, one begins by stating the property "submenu.count" the number of headers you want: here 5. Immediately 5 submenus appear titled "Item0, Item1" ... etc.. These sub-menus behave as before with properties "submenu.count" and other items that are emerging based on the number in the "count". In fact the first sub-menu representing the headers horizontal and vertical following items for each header.
To remove an "item" just right click on it and click "Delete item".
History beautify a little added a presentation on TFrame a context to each item.
We will see later how the items correspond to an event.
The Calculator
Although the source file is available we will do as if it was not and enter a little into the details of construction of the first sheet to help understanding.
The goal is to bring up a calculator by clicking the menu item "Tools" - "calculator".
We will then create a new form: "File" - "New" - "Form" - "Dockingform.
MSEide asks us to enter a name for the unit that will be created. Call "Ucalc. We will then file a "Ucalc.pas" containing the unit with the code we will write and file "Ucalc.mfm" containing the description of the shape to the compiler.
Add file "main.ps" in describing the type of class, the following procedure:
AfficheCalc procedure (const sender: TObject);
and develop it in the implementation part:
tmainfo.AfficheCalc procedure (const sender: TObject);
var UCalc: tUCalcfo;
begin
UCalc: tUCalcfo.create = (nil) / / Create an object tUCalcfo
try
UCalc.show (true) / / execution of the object
finally
UCalc.free / / Release memory by destroying the object
end;
end;
So we create an instance of tUCalcfo and we simply display it. Ucalc.show (true) is enough to show the shape and make the modal boolean passed as parameter.
He must also tell the program how to call this procedure. It returns to the main form, click on the TMainMenu and in the Object Inspector you go to the item called "Calculator". By clicking on the ellipse of the event "OnExecute" is the procedure we have to type: "AfficheCalc. One click to enter and that's it! While we are choose the display mode of the form:
in the Object Inspector to assign the property "optionwindow" value "wo_message.
Note:
for "optionswindow"
wo_popup: during execution, cache all icons of OS-windows manager (WM), title bar,
buttons "Close / Redimenssionner, Min / Max" etc. ...
wo_message: Same as "wo_popup" but allows the window to be closed by the button "Close" and
to be moved.
Compile, execute and admire the empty form which has a close icon in the banner.
Let then a fuzzy and 20 trichbuttons which represent the keys of the calculator. For each button you indicate in the property "caption" the numbers or symbols as shown in Figure 3.

Figure 3
Add file "hand" in describing the type of class, the following procedure:
tUCalcfo.ButtonClick procedure (const Sender: TObject);
begin
CalcKey (TRichButton (Sender). Caption [1]);
end;
and for each button in the Object Inspector, attribute to "OnExecute, clicking on the ellipse, the procedure ButtonClick. Which procedure retrieves cast by the first digit of "caption" for each button.
As it is still more convenient to use the keypad for a calculator, we need to intercept keyboard events. This is done by the following procedure:
tUCalcfo.KeyDo procedure (const Sender: TWidget var info: keyeventinfoty);
begin
CalcKey (info.chars [1]);
end;
Edur proc which returns to the same procedure "CalcKey" as buttons. In the same way we pass the first character in the string: the first digit of "caption" button, and the first character of the keyboard event "info". At the event 'onkeydown "shape is attributed in the Object Inspector, the procedure" KeyDo. Notice the difference in parameters. To understand what parameters to pass in a procedure is nothing to consult the source code. We found the description of "keyeventinfoty" in file "mseguiglob.pas"
keyeventinfoty = record
eventkind: eventkindty;
key, keynomod: keyty;
tanks: msestring,
shiftstate: shiftstatesty;
eventstate: eventstatesty;
timestamp: Cardinal / / usec
end;
The result is displayed in a simple fuzzy with color and character display are selected in the Object Inspector.
The source code of the calculator is an example set long ago in Turbo Pascal 6 (1990) for the first occurrence of the event-driven programming (Turbo Vision) ... It's simple and it works again!
Note:
Martin Schreiber made me noticed that Linux usually uses utf-8 encoding for accented characters and he better use msestring (= WideString) that the string itself. This is what I have done in the Republican calendar, which follows (I myself am not aware of anything with Tutu Linux ...).
It should not be any problems with the calculator but for those who want to standardize their code by msestring should be coded as follows:
Martin Schreiber made me noticed that Linux usually uses utf-8 encoding for accented characters and he better use msestring (= WideString) that the string itself. This is what I have done in the Republican calendar, which follows (I myself am not aware of anything with Tutu Linux ...).
It should not be any problems with the calculator but for those who want to standardize their code by msestring should be coded as follows:
...
Number: msestring;
...
uses UCalc_mfm, StrUtils;
...
procedure SetDisplay (R: Real);
var S: msestring;
begin
...
if S [1] <> '-' then Sign: = '' else
begin
S: = RightStr (S, Length (S) -1);
Sign: = '-';
end;
...
else
begin
while S [Length (S)] = '0 'do S: = LeftStr (S, Length (S) -1) / / Dec (S [0]);
if S [Length (S)] = ''. then S: = LeftStr (S, Length (S) -1) / / Dec (S [0]);
Number: = S;
end;
end;
...
CalcKey begin ()
...
# 8, # 27, '<':
begin
CheckFirst;
if Length (Number) = 1 then Number: = '0 'else Number: LeftStr = (Number, Length (Number) -1);
end;
...
Number: msestring;
...
uses UCalc_mfm, StrUtils;
...
procedure SetDisplay (R: Real);
var S: msestring;
begin
...
if S [1] <> '-' then Sign: = '' else
begin
S: = RightStr (S, Length (S) -1);
Sign: = '-';
end;
...
else
begin
while S [Length (S)] = '0 'do S: = LeftStr (S, Length (S) -1) / / Dec (S [0]);
if S [Length (S)] = ''. then S: = LeftStr (S, Length (S) -1) / / Dec (S [0]);
Number: = S;
end;
end;
...
CalcKey begin ()
...
# 8, # 27, '<':
begin
CheckFirst;
if Length (Number) = 1 then Number: = '0 'else Number: LeftStr = (Number, Length (Number) -1);
end;
...
end;
The Republican Calendar
We will now try another component: the grid.
The goal is to build a Republican calendar. That is to say, a calendar that automatically displays the conversion of a date expressed in revolutionary language used to date in the Gregorian calendar.
Through him we see the use of a TStringGrid mode "readonly", but with the possibility, however, select a cell. It is a simple calendar, we will choose a modal window.
So let's start by creating a new form: "File" - "New" - "Form" - "Dockingform.
A new form appears. Choose any of the following operating mode: no need to set icon, or larger window. We therefore choose the Inspector object property "optionwindow" to which we assign the value "wo_message.
Then table a stringgrid on the form. The Republican calendar was 10 days per week and three weeks per month. We will therefore need a fixed line to indicate the days and 3 lines for weeks.
Donations attribute values appropriate properties:
"name" = "Republican Calendar" in the title of the window.
"datacols.count" = 10 for the number of columns.
"fixrows.count" = 1 for fixed line indicating the days of the week.
"rowcount" = 3 for the number of lines that is to say weeks.
While we are also attribute the lines and color selection:
"fixrows.count" - "Coloraction" = cl_red
Add 4 buttons to change months and years, and two fuzzy for display.
Let a novelty display bubbles of information under the buttons. These are filled in the object inspector in the property "Hint".

Figure 4
Note:
Freepascal taken as the beginning of time 30/12/1899, unlike some versions of Delphi (Delphi 1 and 7 for example) beginning on 01/01/01. Here we soustreyons therefore we find 38,815 to the 22/09/1793, in Delphi 7 it would add 654,779 ... all is to know.
The "About Box" messages.
The "About" is only to show the "wo_popup. More context, more buttons, etc. ... A system TImage is filed on a form, it puts its properties "anchors" to "true", it loads an image by clicking on the ellipse of the property "Bitmap" and is everything.
The messages are displayed with the procedure
ShowMessage (text)
Note that the message windows can be resized. In fact outside of the "wo_popup" all windows are resizable.
The Text Editor
Parmi les widgets de MSE figure un objet ttextedit. C'est lui que nous allons utiliser pour visualiser des fichiers. MAIS, car il y a un gros "mais", il ne s'utilise pas tout seul. Il faut l'inclure dans un twidgetgrid !
Dans l'ordre :
-
Posons donc un twidgetgrid sur la forme principale.
-
Sélectionnons un ttextedit dans la palette des composants.
-
D'un clic droit de la souris sur le twidgetgrid faisons apparaître un pop-up menu : cliquons sur l'item "Insert component". Letwidgetgrid montre alors un embrion de colonne et un objet sélectionné en dessous. Dans l'inspecteur d'objet, et dans la fenêtre concernant le twidgetgrid, remarquons que la rubrique "datacols.count" est passée à "1" et que le premier item indique "<> ttextedit1", c'est-à-dire le nom que vous aurez attribué à l'objet ttextedit.
Nous pouvons maintenant utiliser la méthode "loadfromfile" de "ttextedit1" en lui passant en paramètre le nom du fichier récupéré dans la propriété " controller.filename " de "Openfiledialog1".
Nous ne nous attardons pas sur l'utilisation du tfiledialog qui est classique : on dépose un objet tfiledialog sur la forme et on l'appelle de façon normale dans le menu. La récupération du nom du fichier choisi se comprend aisément au vu du code source. A noter les propriétés " controller.captionopen = 'Ouvrir un fichier texte' " et "controller.captionsave = 'Sauver un fichier texte'" ce qui indique que l'objet peut aussi bien être utilisé en ouverture qu'en sauvegarde de fichier.
Observez dans l'inspecteur d'objet (propriété "controller.filterlist" et cliquer sur l'ellipse) la façon de mettre un filtre dans un tfiledialoget comment cela se traduit dans le fichier ".mfm".

Figure 5
Let then a TStringGrid just below the couple twigetgrid-ttextedit.
We will do two things at once and see the use of ttextedit TStringGrid and at the same time. To do this we open a file in a text stream, read the first line if this line contains a tab character (# 9) is that it's a table and then we open the TStringGrid.Instead, in the absence of a # 9 we open the file in the ttextedit. You will understand the source code is very simple. It is there to argue that some specific components.
The first TStringGrid:
The first line is separate from others and is reserved for column titles. Besides the following lines have their numbers start at "0". In the Republican calendar "we completed the first line using the Object Inspector, here we do it dynamically:
tstringgrid1.fixrows [-1]. captions [column number]. caption: = column name;
Assigning values to other cells is through the use of descriptive lines of columns and brackets
tstringgrid1 [NOCOL] [NoLigne]: = value;
Warning: "Col" before "Row". He who has never invert both, raise your hand!
The ttextedit:
To avoid having unsightly separations in the text we fix the thickness of the lines of twidgetgrid to 0:
"datarowlinewidth = 0"
"datarowheight = 15"
Then load the file is done transparently, the widget with the method "LoadFromFile"
Note:
Files. Txt "test indicate their names in the termination of each line: CR, LF or CRLF in Windows. MSE bed three without problem.
For backups, the ttextedit has a method "SaveToFile" while the need to develop a method to that of ttstringgrid.
Figure 6 shows what the software running.

Figure 6
For backup we use the same tfiledialog and property "controller.filename" which retained the name of the file open.
Note:
Including in the property "options" of tfiledialog "fdo_checkexist value if the filename already exists a confirmation message is automatically requested.
Conclusion.
For nostalgic regret that Delphi no longer have this great development tool for Linux, Kylix has disappeared and being generally not very developed, MSE is the program they need!
As for Pascal programmers who hesitate between Gtk + and Qt they have now offered a third way and which way!

