|
|
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Porting a Delphi Application
Porting a Delphi Application [message #11475] |
Sat, 15 September 2007 03:40  |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
Hi,
I have a Delphi application that I have been (very slowly) developing for quite some time now and for a while I have been thinking about porting the code to some C++ GUI library.
I don't like C++Builders proprietary extensions to C++, GTK is too C-ish (gobject) and can sometimes be very slow on Windows (the GUI), and Qt is one precompiled mess. I researched some other GUI toolkit's too, and I think U++ would be the best for me (even though it's too nonconformist).
So I will try to do the port, at first as a test, and if it works out I will continue add future developments to the U++ version. If it doesn't work, nobody will ever know .
I've gotten quite a good idea of the U++ API, but I can't seem to find and equivalent to Windows MDI Application style windows (TopWindows inserted into TopWindows, with tiling, cascading, ... support). Is MDI supported by U++ or do I have to convert my application to a SDI interface?
Thank you
|
|
|
Re: Porting a Delphi Application [message #11480 is a reply to message #11475] |
Sat, 15 September 2007 13:44   |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
So I started porting and managed to create the File menu with relative ease. It takes some time to get used to the package management scheme in TheIDE, it's image editor and the fact that it is it's own little world, which is surprisingly self-contained.
The layout editor is great, but is not well suited for creating really complex layouts and it seems to favour composing a large number of simple layouts to achieve this goal. And it has no frame support (which I think is a design choice) and no menu editor. But it still helps a lot and I'm glad to have it.
But even after this brief time of exposure to U++ I have identified some issues. I will describe them:
1. My applications exe doesn't have the correct icon (it uses the generic one) when I compile my application in Optimal mode. I compiled some of the example applications to, and these also lack the correct icon. But if I compile it in Debug mode, the icons are fine.
2. If the layout designer or image editor is in the main tab of the editor in the moment the application launches (F5), these editors loose their advanced functionality and revert back to a plain text editor.
3. Fullscreen windows (under Windows) get a border and a title bar if the window looses focus.
4. If I create a frame parameterised with a Button (FrameLeft<Button> for example), the Button will have a strange blue-ish skin. But if I create a Frame with a layout which contains a Button, the Button has a normal skin. Is this intentional?
5. How do you activate the MacOS theme under Windows as seen in the screenshot (this is not an issue, just a question).
I think I forgot another one, and if I stumble upon it I will post again.
Thank You.
|
|
|
|
|
Re: Porting a Delphi Application [message #11514 is a reply to message #11480] |
Sun, 16 September 2007 12:30   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
cbpporter wrote on Sat, 15 September 2007 07:44 |
1. My applications exe doesn't have the correct icon (it uses the generic one) when I compile my application in Optimal mode. I compiled some of the example applications to, and these also lack the correct icon. But if I compile it in Debug mode, the icons are fine.
|
Debug mode is trange, however to procedure is to activate .ico export and add .rc file that uses it. See ide/.rc file as an example (the icon is BTW usually the only use for .rc in U++).
Quote: |
2. If the layout designer or image editor is in the main tab of the editor in the moment the application launches (F5), these editors loose their advanced functionality and revert back to a plain text editor.
|
That is feature, not error The problem is that these files are, through some macro hackery, in fact valid C++ sources that can be stepped through by debugger.
Press Ctrl+T to get designer back.
Quote: |
3. Fullscreen windows (under Windows) get a border and a title bar if the window looses focus.
|
Well, fullscreen windows are not quite typical, this might be a bug. Cared to post a testcase? (BTW, next time please post problems to more appropriate forums, this is really mostly about interesting apps being developed in U++, not problem solving area... your problem might be unnoticed here).
Quote: |
4. If I create a frame parameterised with a Button (FrameLeft<Button> for example), the Button will have a strange blue-ish skin. But if I create a Frame with a layout which contains a Button, the Button has a normal skin. Is this intentional?
|
Yes, tries to immitate the appearance of ComboBox buttons.
Quote: |
5. How do you activate the MacOS theme under Windows as seen in the screenshot (this is not an issue, just a question).
|
Google: "uxtheme".
Mirek
|
|
|
Re: Porting a Delphi Application [message #11516 is a reply to message #11511] |
Sun, 16 September 2007 12:32   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
cbpporter wrote on Sun, 16 September 2007 05:16 |
But I found another bug. If a create a menu with a caption containing the accessor key multiple times (for example "Zoom &Out"), when I press Alt the first of that character will be highlighted (as if I had "Z&oom Out"). This is a minor detail but things like this shouldn't be ignored.
|
Actually, nobody cares about explicitly defining '&' keys - let U++ runtime generate them for you... and perhaps do it manually in cases when you do not like automatic assignment. You can also assign only some and let U++ do the rest.
Mirek
[Updated on: Sun, 16 September 2007 12:33] Report message to a moderator
|
|
|
Re: Porting a Delphi Application [message #11523 is a reply to message #11475] |
Sun, 16 September 2007 15:49   |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
Quote: |
Actually, nobody cares about explicitly defining '&' keys - let U++ runtime generate them for you... and perhaps do it manually in cases when you do not like automatic assignment. You can also assign only some and let U++ do the rest.
|
And it seems it does quite a good job assigning the keys. But is still wish it would respect my explicitly assigned position, because a have "Zoom &In" and "Zoom &Out" and I would like to keep the "_"s aligned. But this little detail won't make me think less of U++, and I must admit that I'm impressed.
Quote: |
No, there is no MDI support.
|
Well with owner draw widgets maybe I could emulate somehow MDI behaviour. Or at least I need a Window menu which allows you to switch between all your open documents.
Quote: |
BTW, next time please post problems to more appropriate forums, this is really mostly about interesting apps being developed in U++, not problem solving area... your problem might be unnoticed here.
|
Sorry, I wanted to keep all info regarding this project in one place.
But to keep with the theme of this thread, I will need some custom components. Most of them are highly specialized and I don't see a general use for them, but one could be useful. It is a foldable panel. It looks like a LabelBox with a Button instead of the label, and by clicking it you can open and close it. In my original application this is done by a Panel, a Bevel, a Button and hand-coded folder behaviour. This is not that nice, and I'm going to try to develop a custom component which at least should extend to a property specified size (even better would be if I can make it to auto-detect the correct size and hide, show and align it's children. I attached a picture with this component.
|
|
|
|
|
|
|
Re: Porting a Delphi Application [message #11542 is a reply to message #11539] |
Mon, 17 September 2007 05:48   |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
Thanks, that served as a quick fix. I don't like the multiple windows but this way I don't have to wory about multiple documents in the same instance of the main window.
Quote: | I see thanks. (ops)
|
If you don't have time, maybe I could find some time in weekend to look over the code, maybe find a way to fix this.
Regarding that drop down panel control, I managed to create one. It works well enough for the time being, even though the code is rough, functionality is missing and it has problems with auto sizing. But it gets me going, so it’s a good thing. I can imagine a custom Bar component which would accept such controls as children and automatically align them vertically one under the other as their size change.
I attached the control's source. I don't have any experience in writing U++ controls, so maybe I get some feedback. And I couldn't find a centralized place where position or size change is handled (except WndSetPos, but that is OS dependent).
-
Attachment: DropPane.zip
(Size: 1.09KB, Downloaded 495 times)
|
|
|
|
|
Re: Porting a Delphi Application [message #11564 is a reply to message #11545] |
Mon, 17 September 2007 19:40   |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
luzr wrote on Mon, 17 September 2007 10:03 |
Usual custom here, when you post some sources like this, is to use package and perhaps provide another one as demonstration - that way downloaders can just unpack to some package nest, start theide, choose the test and run it.
This is not a complaint, just a note - I guess it is time to write U++ netiquette summmary 
|
I will post another improved version (current one gives error when trying to use it as base for a template layout because it misses a SetRect function with a Rect parameter) once it is ready and I'll try to have a proper package format. Previous post was only so people get an idea of what I'm trying to do (and if can be done easier point me in the right direction).
But I have a functional (barely) DropPane and now I'm trying to insert inside an array of 2x4 ToolButtons (I'm not using button because I need them to be flat-looking), like in the attached picture.

Layout and positioning is very important, so I did not use a ToolBar component, instead I hand placed all the buttons. I also need them to check when the user click on them. I managed to do this, but unfortunately I had to use pointers (old habits die hard). I wonder if there is a better way to do this in a U++ style?
layout
LAYOUT(ToolsLayout, 60, 200)
ITEM(ToolButton, btnMove, LeftPosZ(8, 22).TopPosZ(24, 22))
ITEM(ToolButton, btnEdit, LeftPosZ(30, 22).TopPosZ(24, 22))
ITEM(ToolButton, btnLine, LeftPosZ(8, 22).TopPosZ(46, 22))
ITEM(ToolButton, btnBezier, LeftPosZ(30, 22).TopPosZ(46, 22))
ITEM(ToolButton, btnRectangle, LeftPosZ(8, 22).TopPosZ(68, 22))
ITEM(ToolButton, btnEllipse, LeftPosZ(30, 22).TopPosZ(68, 22))
END_LAYOUT
code
struct ToolsDropPane: public WithToolsLayout<DropPane> {
typedef ToolsDropPane CLASSNAME;
ToolsDropPane();
void SetActive(ToolButton *btn);
};
ToolsDropPane::ToolsDropPane()
{
CtrlLayout(*this);
btnMove.Image(CBPImages::Move()).Text("Modify");
btnMove.WhenAction = THISBACK1(SetActive, &btnMove);
btnEdit.Image(CBPImages::Edit()).Text("Edit");
btnEdit.WhenAction = THISBACK1(SetActive, &btnEdit);
btnLine.Image(CBPImages::Line());
btnLine.WhenAction = THISBACK1(SetActive, &btnLine);
btnBezier.Image(CBPImages::Bezier());
btnBezier.WhenAction = THISBACK1(SetActive, &btnBezier);
btnRectangle.Image(CBPImages::Rectangle()).Text("Rectangle");
btnRectangle.WhenAction = THISBACK1(SetActive, &btnRectangle);
btnEllipse.Image(CBPImages::Ellipse()).Text("Ellipse");
btnEllipse.WhenAction = THISBACK1(SetActive, &btnEllipse);
//btnLine.Check(true);
}
void ToolsDropPane::SetActive(ToolButton *btn)
{
btn->Check(true);
}
On the other hand, you will notice that the third and fourth button doesn't have a Text. This is intentional. When I don't specify a text to a button inserted like this into a layout, I get a weird tool tip for it: "(Alt+Shift+address)". Does this mean anything?
-
Attachment: panel2.PNG
(Size: 1.88KB, Downloaded 1617 times)
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 01:45:01 CEST 2025
Total time taken to generate the page: 0.03484 seconds
|
|
|