View Full Version : New mad idea on UI module
ErosOlmi
06-08-2008, 17:24
This one is real vaporware: nothing developed, only free neurons.
_________________________________________________
It just come to my mind this morning when traveling to work a way to use the many Dialog Editors there are around the world without the necessity to write a thinBasic dedicated one but at the same time remain compatible: resource files!
Resource files (or usually named RC files) are text files containing the text descriptions of the many resources an application can needs: cursors, fonts, menus, icons, equates, dialogs, strings, ...
But how is the form of a RC file?
Imagine the Dialog showed in first picture here designed with FbEdit Dialog Editor ( http://www.radasm.com/fbedit/ )
What is its RC representation? Just the following:
define IDD_DLG1 1000
define IDC_GRP1 1003
define IDC_EDT1 1001
define IDC_STC1 1002
define IDC_BTN1 1004
define IDC_CHK1 1005
define IDC_CHK2 1006
define IDC_RBN1 1007
define IDC_RBN2 1008
define IDC_CBO1 1009
define IDC_LST1 1010
define IDC_PGB1 1011
define IDC_TRV1 1012
define IDC_LSV1 1013
define IDC_TRB1 1014
define IDC_SBR1 1015
define IDC_DTP1 1016
define IDC_MVI1 1017
define IDC_RED1 1018
define IDC_IPA1 1019
define IDC_HDR1 1020
IDD_DLG1 DIALOGEX 6,6,461,313
CAPTION "IDD_DLG"
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x10CF0000
EXSTYLE 0x00000008
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x50010000,14,16,104,15,0x00000200
CONTROL "IDC_STC",IDC_STC1,"Static",0x50000000,12,38,106,17
CONTROL "IDC_GRP",IDC_GRP1,"Button",0x50000007,10,62,108,32
CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,144,16,84,39
CONTROL "IDC_CHK",IDC_CHK1,"Button",0x50010003,148,68,56,11
CONTROL "IDC_CHK",IDC_CHK2,"Button",0x50010003,148,88,58,13
CONTROL "IDC_RBN",IDC_RBN1,"Button",0x50010009,128,114,70,13
CONTROL "IDC_RBN",IDC_RBN2,"Button",0x50010009,128,134,70,15
CONTROL "",IDC_CBO1,"ComboBox",0x50010003,224,72,72,15
CONTROL "",IDC_LST1,"ListBox",0x50010141,222,101,72,68,0x00000200
CONTROL "",IDC_PGB1,"msctls_progress32",0x50000000,14,158,120,11
CONTROL "",IDC_TRV1,"SysTreeView32",0x50010007,310,12,86,44,0x00000200
CONTROL "",IDC_LSV1,"SysListView32",0x50010003,310,68,82,50,0x00000200
CONTROL "",IDC_TRB1,"msctls_trackbar32",0x50000000,308,129,84,11
CONTROL "IDC_SBR",IDC_SBR1,"msctls_statusbar32",0x50000003,0,205,403,14
CONTROL "",IDC_DTP1,"SysDateTimePick32",0x50010004,308,153,84,15
CONTROL "",IDC_MVI1,"SysMonthCal32",0x50000000,14,180,140,67,0x00000200
CONTROL "IDC_RED",IDC_RED1,"RichEdit20A",0x50010000,174,179,114,56,0x00000200
CONTROL "",IDC_IPA1,"SysIPAddress32",0x50010000,14,107,90,17
CONTROL "",IDC_HDR1,"SysHeader32",0x50000002,318,197,126,17
END
Few equates used to define Controls IDs. An area where the DIALOG start its description. A BEGIN/END area in which all the controls placed over the dialog are described in details with exactly the same information you would specify in your script.
So, to create a new dialog with all controls why not using one of the many Dialog Editors to write a resource file and inside thinBasic script write something like the following:
#RESOURCE ".\MyResources.rc"
'---The following is just a prototype of a possible syntax
DIALOG LOAD IDD_DLG1 To hWnd
'---
The above script with just one line would load all dialog information searching inside loaded resources and will create a new dialog using the dialog ID IDD_DLG1. Consider the little fact that also all controls present into the RC files will be created automatically for you inside the dialog.
_________________________________________________
I'm still elaborating this possibility because I do not know if RC files are written the same way by the many Dialog editors present. I just wanted to share the idea to see if more expert people on RC files have something to say or other users here have something to tell about it. The more I think about it the more it seems doable to me. I need a new parser specifically implemented for RC resources. But this is not a big problem.
Let me know.
Ciao
Eros
MikeStefanik
06-08-2008, 17:59
The format that you have there from FreeBasic isn't a standard resource file (.rc) format, which is generally oriented towards C/C++. Here's what a resource file looks like that's generated by Visual C++, which is the de facto standard:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "This is a comment"
VALUE "CompanyName", "Company Name"
VALUE "FileDescription", "File Description"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "FILENAME"
VALUE "LegalCopyright", "Copyright 2008 Some Company. All rights reserved."
VALUE "OriginalFilename", "FILENAME.EXE"
VALUE "ProductName", "Product Name"
VALUE "ProductVersion", "1.0.0.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAINDIALOG DIALOGEX 0, 0, 295, 170
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Main Dialog"
FONT 8, "Tahoma", 400, 0, 0x0
BEGIN
ICON 32516,IDC_STATIC,14,15,20,20
LTEXT "Text message",IDC_STATIC,41,15,239,18
LTEXT "Label1:",IDC_STATIC,100,61,164,10
EDITTEXT IDC_EDIT1,100,86,158,13,ES_AUTOHSCROLL
LTEXT "Label2:",IDC_STATIC,41,104,53,10
EDITTEXT IDC_EDIT2,100,102,158,13,ES_AUTOHSCROLL
LTEXT "Label3:",IDC_STATIC,41,120,47,10
EDITTEXT IDC_EDIT3,100,119,158,13,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,94,149,48,14
PUSHBUTTON "Cancel",IDCANCEL,153,149,48,14
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit\tAlt-F4", ID_FILE_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&Contents\tF1", ID_HELP_CONTENTS
MENUITEM SEPARATOR
MENUITEM "&About", ID_HELP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "res\\icon1.ico"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_VALUE1 "This is string value number one."
IDS_VALUE2 "This is string value number two."
IDS_VALUE3 "This is string value number three."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
In short, your parser would need to understand C-style comments and macros. The definition of the constants (e.g.: IDD_MAINDIALOG) would be defined in a separate .h header file, not in the resource file itself, so you'd also need to be able to load and parse that as well.
ErosOlmi
06-08-2008, 18:07
Thanks a lot Mike.
So far I'm just interested in the DIALOG and MENU areas of a RC file so many resources described there can be avoided and just ignored during first implementation.
Many of the equates can be pre-defined in the parser.
Anyhow, after the next thinBasic release I will start to study RC possibility.
Petr Schreiber
06-08-2008, 18:24
Idea is very nice,
I thought about it too, but not in form of RC parsing, but in form of RC to UI code generator.
Your method is better, at least for the programmer I think, as it means less work.
Then there is that RC editor coming with PB too, which was the reason for my idea ... but that RC editor is not very luxury one, as it is 16bit proggie from Microsoft :)
Petr
MikeStefanik
06-08-2008, 18:41
Have you guys reached out to any of the third-party folks like Chris Boss (EZGUI) or Paul Squires (Firefly) about contributing a UI designer for thinBasic? The fact that syntatically it's similar to PowerBASIC would seem to make it a good fit. Perhaps they could do something like contribute a basic version to be included with thinBasic, and offer a more advanced commercial version. Just a thought, there.
jcfuller
06-08-2008, 18:51
Ketil O's is the best I've used.
http://www.radasm.com/resed/index.html
Edit: I forgot to mention there is a dll version implemented as a control so it's easy to just add it to a Dialog just like any other control. His Edit control is quite good too. I was going to put a PB IDE together using these but got side tracked with.......
James
Petr Schreiber
06-08-2008, 19:34
Mike,
that is interesting idea ;)
Jcfuller, thanks a lot for good program link, it seems very comfortable so far.
I think I can leave the realm of MS DlgEdit.exe and enter new world :o
Petr
ErosOlmi
06-08-2008, 20:00
Have you guys reached out to any of the third-party folks like Chris Boss (EZGUI) or Paul Squires (Firefly) about contributing a UI designer for thinBasic? The fact that syntatically it's similar to PowerBASIC would seem to make it a good fit. Perhaps they could do something like contribute a basic version to be included with thinBasic, and offer a more advanced commercial version. Just a thought, there.
Mike,
on UI side, I think we have still to improve a bit. And next thinBasic version will make a great jump into the right direction.
So far to be able to manage a Window message loop we had to create a WHILE/WEND loop just after a DIALOG SHOW MODELESS ...
Also getting a windows message was in reality simulated by an internal thinbasic function that cumulates events in a per window array of events. Even if this has done the job for most of the basic cases, it reached a nightmare handling.
Next thinBasic version will have real message handling driven by new callbacks script functions. Callbacks will be available for mainly all controls (except for those controls driven by notifications to parent window) and all windows. Callback syntax will be almost the same as in PB. Maybe this will be the starting for a possible interest from other programmers to jump here and see where we are and maybe if they can find their ways with thinBasic.
The one you mentioned are professional programmers that mainly look at sales for their jobs. So I'm not sure they will be interested in a free project. In any case I can see some space for possibly commercial applications (both as utilities or commercial modules) but we need to have a wider user base. I prefer to move with little steps.
Thanks a lot for your ideas and contributions.
Eros
_________________________________________________
PS: for those reading this post about commercial possibilities, be sure: thinBasic programming language will always remain free.
Michael Hartlef
06-08-2008, 20:13
Hi Eros, that is a great idea. Back in 2004 and my IBasic Pro times I was working on a dialog editor. Would be interesting to revieve this project.
Petr Schreiber
06-08-2008, 20:52
Hi Mike,
your project looked very nice, reminds me of Delphi dialog designer.
Petr
Michael Hartlef
06-08-2008, 21:11
Thanks Petr,
of course if is Delphi influenced and also made with Delphi.
Michael
Mike your editor looks great.
Nice idea Eros, I think a way to tap into forms and do simpler gui is a wonderful thing anytime.
Nice links and ideas from the rest of you guys too.
Nice to see this sort of direction for thinBasic, even if early stages.
ErosOlmi
07-08-2008, 07:46
I thought about it too, but not in form of RC parsing, but in form of RC to UI code generator.
At first I too thought about a code generator but that way would be a one way direction: draw the dialog (and all needed controls), when ready generate the code.
Going with RC and developing a RC loading function working directly with the RC source has the advantage to separate the code from the design. You can always reload the RC file into the Dialog Editor again and again for further changes without mixing coding/design. More: we would use a "standard" concept (RC).
ErosOlmi
07-08-2008, 08:10
Ketil O's is the best I've used.
http://www.radasm.com/resed/index.html
Edit: I forgot to mention there is a dll version implemented as a control so it's easy to just add it to a Dialog just like any other control. His Edit control is quite good too. I was going to put a PB IDE together using these but got side tracked with.......
James
James,
it seems a good solution also considering it is present as DLL so it would be very easy to be inserted into thinBasic project. RC generated file is very easy to understand and parse. I will take this Dialog Editor as starting point for implementing my idea.
Thank you.
Eros
jcfuller
07-08-2008, 12:16
This would be the way I would approach it.
Use GoRc to compile resources. It is free and redistributable.
http://www.jorgon.freeserve.co.uk/
Use an empty dll with your designer to use as a project resource dll and add
your compiled resources Dlg,Bitmap,Menu ..... to that.
For changing font,color,StausBar,TabDialog,ToolBar..... I create an RCDATA
Item with the same ID as the control.
IDC_SBR1 RCDATA is the status bar and PARTS= are the sizes in percent of the total.
Example Rc File:
#define IDD_DLG1 1000
#define IDC_STC1 1001
#define IDC_RBN1 1002
#define IDC_RBN2 1003
#define IDC_RBN5 1006
#define IDC_RBN7 1008
#define IDC_RBN6 1007
#define IDC_RBN3 1004
#define IDC_RBN4 1005
#define IDC_STC2 1020
#define IDC_STC3 1021
#define IDC_GET_FILE 1022
#define IDC_CREATE_SOURCE 1023
#define IDC_CANCEL 1024
#define IDC_SBR1 1009
#define IDD_DLG2 1100
#define IDC_BTN1 1101
#define IDC_BTN2 1102
#define IDC_STC4 1103
#define IDBMP_1200 1200
#define IDBMO_1201 1201
#include "resource.h"
IDD_DLG1 DIALOGEX 5,5,321,156
CAPTION "Dialog Rc File To Source Code Generator"
FONT 9,"Tahoma",400,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW|DS_CENTER|DS_SETFONT
BEGIN
CONTROL "Source Type",IDC_STC1,"Static",WS_CHILD|WS_VISIBLE|WS_DLGFRAME|SS_CENTER,10,58,201,76
CONTROL "Main RC Dialog",IDC_RBN1,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,18,78,98,9
CONTROL "Modal RC Dialog",IDC_RBN2,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,18,90,86,9
CONTROL "RDT Script File",IDC_RBN5,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,18,101,86,9
CONTROL "DDT Main Dialog",IDC_RBN7,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,18,113,86,9
CONTROL "DDT Modal",IDC_RBN6,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,116,78,86,9
CONTROL "Main JCFDLG",IDC_RBN3,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,116,90,81,9
CONTROL "Modal JCFDLG",IDC_RBN4,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,116,101,82,9
CONTROL " Dialog Rc File",IDC_STC2,"Static",WS_CHILD|WS_VISIBLE|WS_DLGFRAME,8,12,297,38
CONTROL "",IDC_STC3,"Static",WS_CHILD|WS_VISIBLE,15,27,256,12,WS_EX_CLIENTEDGE
CONTROL "...",IDC_GET_FILE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,277,27,17,12
CONTROL "#1200",IDC_CREATE_SOURCE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|0x00000080,228,63,80,22,WS_EX_STATICEDGE
CONTROL "Dismiss",IDC_CANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_OWNERDRAW|0x00000080,228,97,81,22
CONTROL "",IDC_SBR1,"msctls_statusbar32",WS_CHILD|WS_VISIBLE|CCS_BOTTOM,0,143,321,13
END
IDC_STC2 RCDATA
BEGIN
"FORECOLOR=&H606000, BACKCOLOR=-1"
END
IDC_STC1 RCDATA
BEGIN
"FORECOLOR=&H606000,BACKCOLOR=-1,FONT=Tahoma;10;600"
END
IDC_CANCEL RCDATA
BEGIN
"ODB_TEXTCOLORUP=&H000080,ODB_TEXTCOLORDN=&H000080,ODB_BORDERCOLOR=&H000000,ODB_FONTUPDN=Tahoma;10;600,BORDERCOLOR=0"
END
IDC_RBN1 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN2 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN3 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN4 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN5 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN6 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDC_RBN7 RCDATA
BEGIN
"FORECOLOR=&H800000,BACKCOLOR=-1"
END
IDD_DLG2 DIALOGEX 6,6,315,153
CAPTION "Test Dialog -> Click Set Text"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW|DS_CENTER
BEGIN
CONTROL "Dismiss",IDC_BTN1,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,228,123,54,19
CONTROL "Set Text",IDC_BTN2,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,34,123,54,19
CONTROL "",IDC_STC4,"Static",WS_CHILD|WS_VISIBLE|SS_SUNKEN|SS_CENTERIMAGE,48,31,210,15
END
IDBMP_1200 BITMAP DISCARDABLE "CreateSource.BMP"
IDBMO_1201 BITMAP DISCARDABLE "Dismiss.BMP"
IDC_SBR1 RCDATA
BEGIN
"PARTS=50;15;10;10;15"
END
I then have a Control Init Routine that parses the binary res data (the RCDATA is just a string)
James
ErosOlmi
07-08-2008, 13:27
Thanks a lot James.
My original idea was to go and manage directly text source of RC files without the need to compile them into binary format.
Thia also because we have to consider obfuscated files (that usually have no external dependencies) and bundled exe (again without external include files). So my idea was to add to thinBasic parser the ability to parse .RC files on the fly.
Anyhow, this area is all new to me so I first need to improve my knowledge and than decide.
All posts here served to me to understand better the possibilities.
Eros
jcfuller
07-08-2008, 14:33
Eros,
Using a resource Dll you could also store your scripts in it.
I have a small parser I developed for Data Input screens that reads a text script,
creates a Dialog template (for use with CreateDialogIndirectParam) then compresses it using
aPlib. I then add this file to a resource dll. A Sample script read by the parser
'RDTSCRIPT
'Cross Spans
'---------------------------------------------------------------------------
Win.Load=RES:;CB.DLL;R50_RDT
SPREADDLL=SS32D25.DLL
'---------------------------------------------------------------------------
This tells RDT (Rapid Dialog Templates) it's actual running script is located as a Resource
in CB.DLL with a name of R50_RDT.
I'm not sure if you use DDT internally for your UI but creating your own dialog templates might
give you a bit more flexibility. I posted the code a couple different times on the PB Forum.
Just more food for thought.
James
ErosOlmi
07-08-2008, 15:04
Thanks James!
More ideas better than one.