MSEide & MSEgui/id

From Free Pascal wiki
Jump to: navigation, search

English (en) Bahasa Indonesia (id)

Pengenalan

MSE IDE adalah Sistem Pengembangan GUI Lintas Platform yang semuanya ditulis dalam Pascal untuk pemrogram Pascal. Meskipun hanya usaha sorang saja (Martin Schreiber) untuk saat ini, IDE memiliki daftar fitur yang mengagumkan. Info dan download lebih jauh tersedia di situs MSEide+MSEgui

Tapi bagaimana dengan Lazarus ?

Lazarus adalah sebuah IDE yang bertujuan untuk menyediakan kompatibilitas tingkat tinggi terhadap kode VCL selain menyediakan tampilan alami pada banyak platform. Tampilan alami sangat penting bagi banyak para pengembang, tapi digabungkan dengan kompatibilitas memerlukan banyak antar muka yang kompleks terhadap set widget alami ini (Gtk,Win32,Carbon,Qt). Evolusi berlanjut dari set widget alami ini (gtk1->gtk2, win32->?, qt) menyebabkan penangkapan tanpa akhir. MSE GUI tidak menyediakan (atau tidak kekurangan :-) kompatibilitas VCL. Librari grafis menyediakan antar muka untuk win32 dan X11. Keunggulan dari lapisan X11 adalah ketersediaan atas sasaran platform yang luas dan stabil. Perbedaan tujuan dari kedua proyek menjadikan kedua proyek memenuhi kebutuhan yang berbeda.

Mengapa wiki ini

Desain MSE GUI adalah pendekatan awal pada pola desain GUI. Fiturnya menyediakan solusi inovatif untuk tugas-tugas GUI sejenis. Karena inovatif, librari MSE GUI secara substansial berbeda dari VCL/LCL/CLX. Beralih dari VCL ke MSE mungkin lebih menantang daripada dari VCL ke LCL. Halaman wiki ini bertujuan untuk memudahkan langkah pertama dengan librari IDE dan GUI yang menjanjikan.

Installation

See home page.

Quick start

Open Project

Launch the IDE and use Project->Open to open the provide demo msegui/apps/demo/demo.prj. The title of the IDE reflects the opened project. Hit F9 and (if you followed the installation instructions :-), be amazed by the speed of FPC+MSE.

First RAD steps

Close the running project. Use Project->Source to open the project source demo.pas. Ctrl-click on the parameter mainfo in the line

application.createform(tmainfo,mainfo);

to navigate to main.pas. Click on F12 to toggle between unit and form. Not everything will feel that familiar, because of that, these pages are written. Click on the button, this will auto raise the property editor (unusual but usefull). Let us add another button. Make the component palette visible if necessary (View->Toolbar->Component Palette). Select the tbutton on the widget page. Click on the form to create the button. Give it a caption in the usual way. Creating an event handler does not work with the usual double clicking on the onexecute property. Instead, you must select the onexecute property in the property editor, type the name of an event handler and press enter. The MSE RAD will create the handler and position the pointer on the definition. Use ctrl-shift-down arrow (or up) to navigate between implementation and definition. Just add some code like writeln('Hello world'); Hit F9. The writeln will end up in the target console window of MSE (not the console in which you started MSE).

Adding a Main Menu

Add Main Menu

Add a tmainmenu component from the Widget Component tab to your main form. Click on your mainform (mainfo) so that the Object Inspector show the properties of the mainform. Use the arrow next to the mainmenu property of the mainform, to select tmainmenu1 as the mainmenu of mainfo.

Add Menu Items

In the object inspector click on the cross to open the mainmenu treeview branch. Open the menu property of mainmenu. Change the submenu.count of menu to 1 (or higher). Now open the submenu.count property, it will show "Item 0". Open "Item 0" and set the caption to "File". Change the submenu.count property of "Item 0" to 1. Open this last submenu.count property and set the caption of the new "Item 0" to Quit. Hit F9 and your program should have a menu File with the entry Quit in it.

Once there is one submenu, you can add more by right clicking on a "Item X". This will reveal a context sensitive menu with "Insert, Append, Delete".

Once you have more than one submenu, you can use drag and drop to move the "Item X"s. Start the drag mouse move on the "Item X" line.

Tips

MSEide

Larger fonts

Some may find the standard menu font a bit small. The standard font for the main menu of an msegui application is the font defined by the stf_menu stock font. You can change a stock font value with a startup parameter.

--FONTALIAS=<alias>,<fontname>[,<fontheight>[,<fontwidth>[,<options>]]]

So if you start the mseide like this, you can get a larger font:

 mseide --FONTALIAS=stf_menu,sans,16

Shortcuts

Common

  • Ctrl+F4 - Close
  • Ctrl+S - Save
  • Ctrl+E - Select page
  • F11 - Toggle Form/Inspector
  • F12 - Toggle Form/Unit
  • Shift+Ctrl+[0..9] - Bookmark 0..9
  • Ctrl+[0..9] - Go to bookmark 0..9
  • Ctrl+LeftClick - Go to var(class, method, unit) declaration
  • Shift+Ctrl+Up - Go to method declaration
  • Shift+Ctrl+Down - Go to method implementation
  • Shift+Ctrl+Space - Show procedure header

Debug

  • F7 - Step
  • F8 - Next
  • F9 - Continue
  • Shift+F7 - Finish
  • Shift+Ctrl+F8 - Next instruction
  • Shift+Ctrl+F7 - Step instruction
  • F5 - Toggle breakpoint
  • Shift+F5 - Toggle breakpoint enabled/disabled
  • Ctrl+B - Breakpoints on/off
  • Ctrl+W - Watches on/off

Editor

  • Ctrl+Z - Undo
  • Ctrl+X - Cut
  • Ctrl+C - Copy
  • Ctrl+V - Paste
  • Ctrl+F - Find
  • F3 - Search again
  • Ctrl+L - Go to line.
  • Ctrl+I - Indent block
  • Ctrl+U - Unindent

Print from IDE

You need the ghostscript

Recent opened files or projects

The last opened projects are in the dropdown list of 'Project'-'Open'-'Name'. The last opened files are in the dropdown list of 'File'-'Open'-'Name'.

Menu Editing

  • Use submenu.count to add the first submenu entry.
  • Right click on a menu item "Item X" to display a context-sensitive menu that allows to insert,append or delete a submenu entry
  • Use drag and drop on a submenu entry to move the different submenu entries.

New Panels in the IDE

Example, you want to have the watch, stack and cpu window in a window:

  • select the menu item View-Panels-New Panel.
  • select the menu item View-Watches.
  • drag the Watches window by the grip (not the window title!) in the new panel.
  • same with Stack and CPU window.
  • to split horizontal drag one of the grip of the inserted widgets to the left border of the panel.
  • to split vertical drag one of the grip of the inserted widgets to the bottom border of the panel.
  • to use tabs drag one of the grip of the inserted widgets to the centre of the panel.

Design Tab-Order

Main way in MSEide is set the tab order after all widgets are placed in the form with the popup menu function "Set Tab Order". Select a widget in the container where you wish to set the tab oder, click right, click "Set Tab Order", click row 0, click "Start", click the widget in the container which should get tab order 0, click the widget which should get tab order 1..

An alternative is to drag and drop the rows to the desired position. The first row corresponds to the tab order 0 the second to the 1 and so on.

Creating a new event handler

Select the event you want in the Object Inspector, then type name of the new event handler. IDE create a new procedure(declaration and implementation) in the source code. If you double-click the name of the event handler in the Object Inspector, source editor opens with the cursor at begin of your handler implementation.

MSEgui

Tabbed control

  • Put ttabwidget control on the form. Now you have container (ttabwidget1) for pages.
  • Put as many ttabpage controls on the ttabwidget1 as tabs you want.

Splitter

We have two widgets (widgetLeft, widgetRight) and we need horizontal splitter between them.

  • Add TSplitter to form and resize it as you want.
  • Change the linkleft of tsplitter1 to widgetLeft and linkright to widgetRight. At this step our widgets stick to splitter.
  • Change the spo_hmove to True. That's all.
  • If you want to save a proportion between width of widgetLeft and width of widgetRight when the main form is resized then change the so_hprop to True.
  • If you need the vertical splitter then use other properties linktop, linkbottom, spo_vmove, spo_vprop.

Switch-off auto-scrolling of the form(widget)

Change the container - frame - sbhorz - options - sbo_showauto property of the form to False.

Read/write data in the twidgetgrid

  • editwidget.value -> value of the actual row
  • editwidget[rowindex] or editwidget.gridvalue[rowindex] -> value of the addressed row
  • editwidget.gridvalues the whole column as a dynamic array.

First events

OnCreate is called before loaded procedures of the components of the form are called, OnLoaded is called after loaded procedures of the components of the form are called. Many components do initializations in loaded procedures, event properties are inactive before procedure loaded of the component is called.

MDI

MDI - application can be created using TDockFormWidget or TDockPanel (as MDI-area) and TDockForm (as ancestor for you MDI-child window). There are examples:

Drawing

Redraw form the additional thread

Use a tthreadcomp (tab Gui) to do the long time procedure. If you need to access widgets and other gui variables from the additional thread, call application.lock before and aplication.unlock after accessing the main event thread elements.

Force repaint

  • twidget.invalidate to invalidate an individual widget
  • twidget.rootwidget.invalidate to invalidate the window
  • application.invalidate to invalidate all windows (=forms) in the application

Draw text

There are two methods to draw texts in MSEgui:

  • Simple text positioning by baseline position of start of the first character with tcanvas.drawstring.
  • With the drawtext procedures of msedrawstring.pas.

Widgets canvas

No twidget has a canvas. The canvas used for painting is normally one of the canvas of twindow, it can also be an canvas of a tbitmap or a tprinter or... MSEgui uses one canvas to paint a whole window with all widgets. tcanvas.font is initialized by twidget.getfont, canvas.color by twidget.actualcolor before calling twidget.dopaint, see twidget.paint procedure in msegui.pas.

Theming (Frames & Faces)

Every twidget has a property frame and face. If they are deactivated (<disabled> in object inspector) they are only an nil pointer and need no more resources. Activate them by clicking on the ellipse button in the right object inspector column in the row face respective frame.

The face property defines the background of the client area of the widget.

It is a combination of a fade and a bitmap. Both of them can be semitransparent. The bitmap can be stretched and/or tiled. Example: you want to create a button with a fade as face.

  • place a tbutton on the form.
  • in object inspector activate property face.
  • set face.fade.color.count to 2.
  • click on the + at color.count.
  • in item 0 select cl_gray.
  • in item 1 select cl_ltgray, now you have a left to write fade from gray to light gray.
  • change face.fade.direction to gd_up or gd_down, you get a convex resp. concave fade.

If you want, you can blend an additional structure over the fade:

  • select the wanted pattern image in face.image.
  • activate face.image.alignment al_tiled.
  • adjust face.image.transparency to your needs, $000000 = opaque, $ffffff = fully transparent. The number defines the transparency of the three color channels ($RRGGBB).

To centralise the face look use an tfacecomp (tab Gui) and select the facecomp in template of the face properties.

The frame property defines the look of an additional frame around the component and shows a possible caption at the widget. Example: you want an lowered frame around and a caption right of the button.

  • activate property frame.
  • set frame.levelo to -1.
  • set frame.leveli to 1.
  • enter the caption text in frame.caption.
  • set frame.captionpos to cp_right.

To centralise the frame look use an tframecomp (tab Gui) and select the framecomp in template of the frame properties.

Desktop colors in the MSE application

Default values of the mapped colors stored in the array msegraphics.defaultmapped. For change it's values you can use function msegraphics.setcolormapvalue Win32 and KDE example ($MSESOURCES/contributed/miha/GuiStyle.pas)

Tutorial

Unofficial incomplete help pages started from Z505 at: http://z505.com/cgi-bin/mse/idx.cgi?file=generalindex

Read the beginner's tutorial (in Russian) at: http://freepascal.ru/article//mse/20060108181639/

Also: "MSEide+MSEgui. Draw lesson." (in Russian) http://freepascal.ru/article//mse/20060205191314/

You can also find an English translation here: http://www.geocities.com/yetanothergeek/mseide-tutorial-en/

This page in Russian: http://freepascal.ru/wiki/index.php/MSEide%26MSEgui

Screenshots

The following screen shots are taken from an MSEgui Firebird database application. The programmer writes he has customized the look and feel of his application in about 30 minutes with a tfacecomp and two tframecomp. He states that the look and feel is identical on Linux and Windows.


mse dbwidgetgrid1.jpg

mse dbwidgetgrid2.jpg

Linux version: mse form1.jpg

Windows version: mse form1w.jpg

Linux version: mse button1.jpg

Windows version: mse button1w.jpg

The report is designed and rendered with the built-in MSEide+MSEgui report designer and report generator.

mse report1.jpg


Two MDI forms with fade and flat frame.

mse gripfade1.png