Re: [fpc-pascal] GUI confusion
On 09/29/2013 03:24 PM, Patrick wrote: Could anyone point me to resources on how to build GUI applications without Lazarus? If you mean the GUI library Lazarus offers there are alternatives that have been pointed out. If you mean Lazarus the IDE, you always can create a GUI using the Lazarus Library GUI (LCL) by manually doing the calls to create and manage the Widgets. In fact the IDE just creates a program that does exactly this and supplies it with the information about the GUI elements in a linked-in resource. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Status of UTF8
On 09/28/2013 02:51 PM, Jonas Maebe wrote: . You can read your data into a RawByteString and then call SetCodePage(rawbytestr,codepagenr,false) to set its code page to whatever the code page of the data in that string is (without attempting to convert the data, which is what the last "false" parameter indicates). What is supposed to happen when you uses such thingies a string "+" operation (to be added to each other, with a "normal" string or with a string constant ? What happens when using it in a string "copy" or "pos" function ? What happens when struing it in a TStringList ? (OK I can try all this myself ...) -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
On Sep 29, 2013 8:24 AM, "Patrick" wrote: > I don't really like IDEs. I used gvim and I suppose it could almost be called an IDE as well but I mean I would rather use the shellr then clicking on a build button. For what its worth, I use free pascal practically every day, but rarely open Lazarus. I write most of my code in emacs, running inside a tmux session: http://tangentstorm.imgur.com/all/ But if I were going to make a GUI app, it would be crazy of me to ignore Lazarus. :) I also use it when I want to browse and navigate through other people's source code. You can ctrl-click on identifiers as id they were hyperlinks. Also if part of what bothers you is all the floating panels, you can enable the anchor docking extension and put everything into one window. That made a tremendous difference for me. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
Am 30.09.2013 04:10 schrieb "Xiangrong Fang" : > > 2013/9/30 Sven Barth >> >> >>> However, this does not work, because it seems that I cannot make any >>> generic method virtual! In TIntTree, I have to write: >>> >>> function TIntTree.DoClone: TIntTree; >>> >>> As it is not possible to write TTree outside of the generic definition. >> >> >> This should do it: > > > Right, this worked. My last question for this issue: is the TSelfType a 2.6.2 workaround, or it is required even in 2.7.1? I mean, how about this: > > === code === > type > generic TTree = class > protected > procedure DoClone(aNode: TTree); virtual; //<<-- instead of TSelfType > end; > TIntTree = class(specialize TTree protected > procedure DoClone(aNode: TTree); override; //<<-- instead of TSelfType > end; > === end code === > > In another word, use "TTree" to represent any of its specialization and their descendants. Is it possible in 2.7.1 or later? You don't require "TSelfType" in 2.7.1, but the correct one is not "TTree", but "specialize TTree". If "TTree" should work then that's a bug... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
2013/9/30 Sven Barth > > However, this does not work, because it seems that I cannot make any >> generic method virtual! In TIntTree, I have to write: >> >> function TIntTree.DoClone: TIntTree; >> >> As it is not possible to write TTree outside of the generic definition. >> > > This should do it: Right, this worked. My last question for this issue: is the TSelfType a 2.6.2 workaround, or it is required even in 2.7.1? I mean, how about this: === code === type generic TTree = class protected procedure DoClone(aNode: TTree); virtual; //<<-- instead of TSelfType end; TIntTree = class(specialize TTree___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: GUI confusion
> I tried Lazarus but it did not seem to be creating GTK code or QT, it was just some sort of weirdo Lazarus only stuff and then in tandem with the QT binding statement I mentioned earlier http://wiki.freepascal.org/Overview_of_Free_Pascal_and_Lazarus#Lazarus_Architecture > it wasn't even obvious whether or not it could generate GUI code outside of the IDE http://wiki.freepascal.org/LCL_Tips#Creating_a_GUI_by_code By logic, there won't be anything that can be done by IDE but not by code, code is far more superior in terms of capability. After all, code is what works behind all those abstractions (forms, data module, etc.). The IDE does almost exactly the same thing as if you code everything by hand (but it does by reading and interpreting the form's definition). > It would be painful to learn an IDE to only find out later that it is for teaching purposes. Welcome to the world of Modern Pascal. Nah, Pascal itself has NEVER been designed for such a purpose only. Free Pascal and Lazarus despite volunteer only projects are designed for real world application. Both are written in itself (Free Pascal is bootstrapping compiler, Lazarus is built from LCL, the same framework you use for building GUI applications with Lazarus) which shows their power. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/GUI-confusion-tp5716891p5716900.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
There are alternatives, but first a distinction needs to me made. When you say "Lazarus", do you mean simply the IDE, or do you mean the LCL (Lazarus Component Library)? >From your earlier remard about IDE's I assume you simply don't like IDE, but you might not mind building LCL-based applications. Obviously you can create LCL-based GUI applications without using Lazarus IDE. It is a bit more work though. Just in case you didn't know, LCL uses other underlying widgetset's. So LCL can target GTK1, GTK2, Win32, fpGUI and Carbon toolkits. Another alternatives is to use fpGUI, which is a 100% custom drawn GUI toolkit, that doesn't rely on any other underlying toolkits. fpGUI talks directly to X11 or GDI. fpGUI isn't tied to any specific editor or IDE, so you are free to code with Notepad or VI if you wanted to. fpGUI does come with its own tools to help you with some tasks, but in is still not a requirement to use them. For example, fpGUI includes a stand-alone GUI Designer for visually designing forms. All that the GUI Designer does, is generated Object Pascal source code, just like you would have done by had. It doesn't use external files like the *.lfm files which Lazarus IDE produces - which ain't Object Pascal source files. Yet another alternative is MSEide+MSEgui, but as the name says, it is recommended to use the MSEide to write code. Regards, Graeme Thanks again Sven. Hi Graeme This was a very helpful post. I will definitely give fpGUI a try, along with Lazarus. I don't really know anything about using LCL outside of Lazarus yet. Your point about LCL is super helpful. I hope no one minds the constructive criticism but my lack of understanding of this was the tipping point that sent me away last time. I tried Lazarus but it did not seem to be creating GTK code or QT, it was just some sort of weirdo Lazarus only stuff and then in tandem with the QT binding statement I mentioned earlier, it wasn't even obvious whether or not it could generate GUI code outside of the IDE. The FUD circling around Pascal is that it is for teaching only. It would be painful to learn an IDE to only find out later that it is for teaching purposes. I have family members with urgent care needs and I don't have too much time. However I would really like to start posting on the net about my experiences, maybe I can help to clear away the FUD. BTW, Would it be correct to compare LCL to WxWidgets ? In the sense that it is a meta-widget toolkit? Thanks ! -Patrick ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
On 29/09/13 14:24, Patrick wrote: > Could anyone point > me to resources on how to build GUI applications without Lazarus? There are alternatives, but first a distinction needs to me made. When you say "Lazarus", do you mean simply the IDE, or do you mean the LCL (Lazarus Component Library)? >From your earlier remard about IDE's I assume you simply don't like IDE, but you might not mind building LCL-based applications. Obviously you can create LCL-based GUI applications without using Lazarus IDE. It is a bit more work though. Just in case you didn't know, LCL uses other underlying widgetset's. So LCL can target GTK1, GTK2, Win32, fpGUI and Carbon toolkits. Another alternatives is to use fpGUI, which is a 100% custom drawn GUI toolkit, that doesn't rely on any other underlying toolkits. fpGUI talks directly to X11 or GDI. fpGUI isn't tied to any specific editor or IDE, so you are free to code with Notepad or VI if you wanted to. fpGUI does come with its own tools to help you with some tasks, but in is still not a requirement to use them. For example, fpGUI includes a stand-alone GUI Designer for visually designing forms. All that the GUI Designer does, is generated Object Pascal source code, just like you would have done by had. It doesn't use external files like the *.lfm files which Lazarus IDE produces - which ain't Object Pascal source files. Yet another alternative is MSEide+MSEgui, but as the name says, it is recommended to use the MSEide to write code. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
On 29.09.2013 20:54, Patrick wrote: I actually tried to get started with FPC back In January. I felt that the language was too tied to Lazarus and that I didn't want to use an IDE so I gave up. FPC is definitely independant of Lazarus, but Lazarus on the one hand simplifies development significantly (I myself am using it e.g. for working on the compiler itself) and it also allows to develop user application in a way similar to Delphi. Most Object Pascal people are using either Delphi or Lazarus to develop GUI applications based on the VCL or LCL respectively. Few go the route of using another GUI (e.g. mseGUI and fpGUI) or use the native platform API (e.g. direct WinAPI, GTK 2, Carbon, etc.). I will report back when I am a little further along this time. It is possible that the language is not being presented exactly as is intended or that there is too much room for people to misinterpret how the programming environment works. I've never read the "Getting started with Lazarus" book, so I can not comment on this. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
Thanks again to Reinier and Sven I just bought Getting Started with Lazarus IDE. I actually tried to get started with FPC back In January. I felt that the language was too tied to Lazarus and that I didn't want to use an IDE so I gave up. I will report back when I am a little further along this time. It is possible that the language is not being presented exactly as is intended or that there is too much room for people to misinterpret how the programming environment works. -Patrick On 09/29/2013 12:50 PM, Sven Barth wrote: On 29.09.2013 15:24, Patrick wrote: Hi Everyone I really like the pascal code I have looked at and I am very excited about FPC. I hope this email won't upset anyone, it is a bit negative. I don't really like IDEs. I used gvim and I suppose it could almost be called an IDE as well but I mean I would rather use the shellr then clicking on a build button. IDEs are less about "build buttons", but about the additional features they provide: - integrated debugging - error location highlighting - code completion - code refactoring tools I am trying to learn what Lazarus is all about but I am still clueless. There are screen shots of it being used to develop GTK and QT applications but I have also read that GTK 2 is new and buggy and then there is this line: It seems that this wasn't updated for quite some time...GTK2 is no problem today and is the standard GUI interface for Lazarus on Linux "The FPC Qt4 Binding is not meant to create Qt applications in FPC. But it should allow the Lazarus LCL developers to create a Qt Widget set for Lazarus" I would say scratch that sentence. The first part can be more or less considered nonsense... Can I build GTK 2 (or 3) and QT applications in this? GTK 3 is not yet supported, but GTK 2 and QT are. Could anyone point me to resources on how to build GUI applications without Lazarus? You could take a look at the packages/gtk2/examples directory of a FPC source distribution. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SSE instructions
Am 27.09.2013 23:48, schrieb August Oktobar: > Are there any plans to add support for SSE intrinsic instructions, > similar to MMX? Planned is a lot, when it happens is a another question. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GUI confusion
On 29.09.2013 15:24, Patrick wrote: Hi Everyone I really like the pascal code I have looked at and I am very excited about FPC. I hope this email won't upset anyone, it is a bit negative. I don't really like IDEs. I used gvim and I suppose it could almost be called an IDE as well but I mean I would rather use the shellr then clicking on a build button. IDEs are less about "build buttons", but about the additional features they provide: - integrated debugging - error location highlighting - code completion - code refactoring tools I am trying to learn what Lazarus is all about but I am still clueless. There are screen shots of it being used to develop GTK and QT applications but I have also read that GTK 2 is new and buggy and then there is this line: It seems that this wasn't updated for quite some time...GTK2 is no problem today and is the standard GUI interface for Lazarus on Linux "The FPC Qt4 Binding is not meant to create Qt applications in FPC. But it should allow the Lazarus LCL developers to create a Qt Widget set for Lazarus" I would say scratch that sentence. The first part can be more or less considered nonsense... Can I build GTK 2 (or 3) and QT applications in this? GTK 3 is not yet supported, but GTK 2 and QT are. Could anyone point me to resources on how to build GUI applications without Lazarus? You could take a look at the packages/gtk2/examples directory of a FPC source distribution. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
On 29.09.2013 11:47, Xiangrong Fang wrote: 2013/9/29 Sven Barth mailto:pascaldra...@googlemail.com>> I would suggest you to add an additional protected virtual method to TTree<> which is called from TTree<>.Clone and you override that in your descendant classes. Could you please give an example how to do this? I tried the following: === code start === function TTree.DoClone: TTree; //protected, virtual begin Result := TSelfClass(Self.ClassType).Create(Data, FParent); end; function TTree.Clone: TTree; var node: TTree; begin Result := DoClone; node := FirstChild; while node <> nil do begin node.Clone.Remove(Result); node := node.NextSibling; end; end; === code end === However, this does not work, because it seems that I cannot make any generic method virtual! In TIntTree, I have to write: function TIntTree.DoClone: TIntTree; As it is not possible to write TTree outside of the generic definition. This should do it: === code begin === type generic TTree = class protected type TSelfType = TTree; protected procedure DoClone(aNode: TSelfType); virtual; public function Clone: TSelfType; end; procedure TTree.DoClone(aNode: TSelfType); begin (* empty *) end; function TTree.Clone: TSelfType; var n: TTree; begin Result := TSelfType(Self.ClassType).Create(Data, FParent); node := FirstChild; while node <> nil do begin node.Clone.Remove(Result); node := node.NextSibling; end; DoClone(Result); end; type TIntTree = class(specialize TTree) protected procedure DoClone(aNode: TSelfType; override; end; procedure TIntTree.DoClone(aNode: TSelfType); begin inherited; (* whatever *) end; === code end === Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: GUI confusion
On 29/09/2013 15:24, Patrick wrote: > I am trying to learn what Lazarus is all about but I am still clueless. > > There are screen shots of it being used to develop GTK and QT > applications but I have also read that GTK 2 is new and buggy and then > there is this line: > Can I build GTK 2 (or 3) and QT applications in this? Could anyone point > me to resources on how to build GUI applications without Lazarus? This sounds like a blast from the past. Yes, Lazarus has been able to build GTK applications for quite a while now, as well as Qt and Windows applications. GTK2 is the default widgetset for Lazarus on Linux; GTK3 support probably is more experimental. I'd suggest simply installing it and trying it. About building GUI applications without Lazarus: Graeme, this is your cue! Try looking into fpgUI, MSEIDE+MSEGUI. Presumably you could handcode pascal using the bindings to create forms etc as well but why you would want to do that escapes me. Good luck. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] GUI confusion
Hi Everyone I really like the pascal code I have looked at and I am very excited about FPC. I hope this email won't upset anyone, it is a bit negative. I don't really like IDEs. I used gvim and I suppose it could almost be called an IDE as well but I mean I would rather use the shellr then clicking on a build button. I am trying to learn what Lazarus is all about but I am still clueless. There are screen shots of it being used to develop GTK and QT applications but I have also read that GTK 2 is new and buggy and then there is this line: "The FPC Qt4 Binding is not meant to create Qt applications in FPC. But it should allow the Lazarus LCL developers to create a Qt Widget set for Lazarus" Can I build GTK 2 (or 3) and QT applications in this? Could anyone point me to resources on how to build GUI applications without Lazarus? Please don't RTFM me, I am trying, there just seems to be a lot of conflicting information and I am confused-Patrick ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
2013/9/29 Sven Barth > > I would suggest you to add an additional protected virtual method to > TTree<> which is called from TTree<>.Clone and you override that in your > descendant classes. > Could you please give an example how to do this? I tried the following: === code start === function TTree.DoClone: TTree; //protected, virtual begin Result := TSelfClass(Self.ClassType).Create(Data, FParent); end; function TTree.Clone: TTree; var node: TTree; begin Result := DoClone; node := FirstChild; while node <> nil do begin node.Clone.Remove(Result); node := node.NextSibling; end; end; === code end === However, this does not work, because it seems that I cannot make any generic method virtual! In TIntTree, I have to write: function TIntTree.DoClone: TIntTree; As it is not possible to write TTree outside of the generic definition. Regards, Xiangrong ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
On 29.09.2013 05:49, Xiangrong Fang wrote: 2013/9/28 Sven Barth mailto:pascaldra...@googlemail.com>> On second sight your solution is not correct, because you are using Clone inside your parent class which would not use the (non-virtual) Clone you created. I've now played around with 2.6.2 myself and this should solve this problem: === code begin === type generic TTree = class private type TSelfType = TTree; TSelfClass = class of TSelfType; // earlier I suggested TTree which 2.6.2 does not support=== code end === I think this solution only fixed the problem with 2.6.2 that you have to use TSelfType, but the logic is still not correct. Using your modified version, I try to achieve some complex Clone strategy, for example, either one of the following: 1) the descendant has added a field other than Data that needs to be cloned; 2) the clone is "non-verbatim", it will multiple Data by 2 when cloning. Let's use the 2nd one as an example, the following does not work: type TIntTree = class(specialize TTree) public function Clone: TIntTree; end; function TIntTree.Clone: TIntTree; begin Result := TIntTree(inherited Clone); Result.Data *= 2; end; It only multiple the ROOT node of the cloned tree, not every node. I would suggest you to add an additional protected virtual method to TTree<> which is called from TTree<>.Clone and you override that in your descendant classes. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] class inheritance and type incompatibility
On 29.09.2013 04:47, Xiangrong Fang wrote: 2013/9/29 Sven Barth mailto:pascaldra...@googlemail.com>> If you want to override the virtual Clone method of TTree in TIntTree you need to use the same result type + override or otherwise you gain nothing, because the compiler will not consider the method as overloaded and use the Clone method of TTree inside TTree's methods instead. Yes, you are right, for virtual method, you need have exactly same type... But this leads me to think how the generics are implemented? The important things about generics: - The generic type itself (in this case TTree<>) does *not* exist inside the code (bugs not withstanding...), only the textual representation of the generic exists as metadata inside the PPU (which you can not access from a program) - When specializing a generic the compiler loads this metadata and reparses the textual representation whereby the generic type parameters are replaced by the types you specified, so in code a "specialize TTree" looks like a "TTree" which you manually have made non-generic and replaced each occurence of "T" with "Integer". For example: === snippet 1 === type TIntTree = class(specialize TTree) public function Clone: TTree; override; end; === end of snippet 1 === This will leads to a compile error: Generics without specialization cannot be used as a type for a variable. "TTree" is not valid anywhere except inside the declaration of the generic (and only in non-Delphi modes). If so, why in the code TTree can be used everywhere, for example: === snippet 2 === function TTree.Level: Cardinal; var n: TTree; <-- here TTree is not specialized. begin ... ... end; === end of snippet 2 === In snippet 1, why the compiler don't treat the TTree same as its own type i.e. TIntTree? I imagine that TTree in snippet 1 is logically similar to TObject. I mean, a class's method is of course possible to return a value of its parent's type or any other class's instance? In case of generics in non-Delphi modes the own class name without generic parameters (here "TTree") is a place holder for the own type of the generic. The compiler replaces any reference to this type with references to the generic you are declaring. If you now specialize a generic (e.g. "specialize TTree") all those references are now handled as references to "TTree". Would you please show how exactly you changed the code? With all those methods calling each other it's a bit hard to imagine in my head what you changed. ;) With your TSelfClass solution in TTree, I mean either: === solution 1 === type TIntTree = class(specialize TTree public function Clone: TIntTree; end; function TIntTree.Clone: TIntTree; begin Result := TIntTree(inherited Clone); //typecast in TIntTree end; === end of solution 1=== or: === solution 2 === type TIntTree = class(specialize TTree) end; begin //main it2 := TIntTree(it1.Clone); //typecast in main program end. === end of solution 2 === Are both solutions correct? Yes, correct are both. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] generic class helper and class references
On 29.09.2013 05:30, Xiangrong Fang wrote: type generic TTree = class ... ... end; TTreeType = class of TTree; This is illegal code and compiled by pre-2.7.1 FPC only because of bugs in the generic implementation. "TTree" is not a legal type outside of the generic's declaration or implementation (and no, TTree is neither). 1) is it possible to define class helper for generic classes? No. I recently had the thought to allow this as well, but not now. 2) why class helper require a class and we cannot use a class reference? A class helper always work on variables (or return values) of the type you specified. So if you'd be able to define a class helper for TTreeType you'd only be able to use it on variables of type TTreeType or e.g. TTreeType(Self.ClassType), but not on instances of TTree<>. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal