Re: returning D string from C++?

2017-08-05 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 05 Aug 2017 20:17:23 + schrieb bitwise : > virtual DString getTitle() const { > DString ret; > ret.length = GetWindowTextLength(_hwnd) + 1; > ret.ptr = (const char*)gc_malloc(ret.length, 0xA, NULL); > GetWindowText(_hwnd,

Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:32:05 UTC, Adam D. Ruppe wrote: On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: Also, does it do the allocation at compile time(reserve space on the stack for the variable along with all the others or does it "allocate" space on the stack at

Re: Create class on stack

2017-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: Also, does it do the allocation at compile time(reserve space on the stack for the variable along with all the others or does it "allocate" space on the stack at runtime?... which is slightly slower). compile time. It works like a

Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:10:31 UTC, Moritz Maxeiner wrote: On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote: On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote: On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a

gtkD: events being triggered twice

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
GtkEventBox - Enter GtkEventBox - Enter Down GtkEventBox - Leave Up GtkEventBox - Leave GtkEventBox - Leave That is when I move the mouse over the event box then click then move out out then release. I would expect Enter Down Leave Up The fact that enter and leave are not paired equally is

Re: Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to

Re: Getting enum from value

2017-08-05 Thread Kreikey via Digitalmars-d-learn
On Saturday, 5 August 2017 at 20:11:27 UTC, Matthew Remmel wrote: On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel I'm annoyed that I didn't think of trying to cast it. That works great if the value exists in the enum. It

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

Re: returning D string from C++?

2017-08-05 Thread Jeremy DeHaan via Digitalmars-d-learn
On Saturday, 5 August 2017 at 20:17:23 UTC, bitwise wrote: I have a Windows native window class in C++, and I need a function to return the window title. [...] As long as you have a reachable reference to the GC memory SOMEWHERE, the GC won't reclaim it. It doesn't have to be on the stack

Re: gtkD load images

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn
On 08/05/2017 10:30 PM, Mike Wey wrote: On 05-08-17 15:23, Johnson Jones wrote: On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote: [...] There are two issues here, you need to properly escape the slash: "C:a.jpg". [...] ``` Pixbuf p = new Pixbuf(r"C:\\a.jpg"); ``` Thanks. Why

Re: gtkD window centering message up and no app on taskbar

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 05-08-17 20:14, Johnson Jones wrote: When trying to center the window. If one uses ALWAYS_CENTERED any resizing of the window is totally busted. CENTER also does not work. move(0,0) seems to not be relative to the main display. I'd basically like to center the window on the main display or

Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 05-08-17 15:23, Johnson Jones wrote: On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote: On 03-08-17 21:56, Johnson Jones wrote: If I do something like import gdkpixbuf.Pixbuf; Pixbuf.newFromResource("C:\\a.jpg"); There are two issues here, you need to properly escape the slash:

Re: Create class on stack

2017-08-05 Thread angel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

returning D string from C++?

2017-08-05 Thread bitwise via Digitalmars-d-learn
I have a Windows native window class in C++, and I need a function to return the window title. So in D, I have this: // isn't D's ABI stable enough to just return this from C++ // and call it a string in the extern(C++) interface? anyways.. struct DString { size_t length;

Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e [...] Capitals c =

Re: lambda function with "capture by value"

2017-08-05 Thread Temtaime via Digitalmars-d-learn
On Saturday, 5 August 2017 at 19:19:06 UTC, Simon Bürger wrote: On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote: Maybe std.functional.partial can help you. Nope. int i = 1; alias dg = partial!(writeln, i); i = 2; dg(); still prints '2' as it should

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote: Maybe std.functional.partial can help you. Nope. int i = 1; alias dg = partial!(writeln, i); i = 2; dg(); still prints '2' as it should because 'partial' takes 'i' as a symbol, which is - for this

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote: On Saturday, 5 August 2017 at 18:45:34 UTC, Simon Bürger wrote: On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote: [...] No, sometimes I want i to be the value it has at the time the delegate was defined. My actual usecase

Re: lambda function with "capture by value"

2017-08-05 Thread ikod via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:45:34 UTC, Simon Bürger wrote: On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote: [...] No, sometimes I want i to be the value it has at the time the delegate was defined. My actual usecase was more like this: void delegate()[3] dgs;

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote: On Saturday, 5 August 2017 at 18:19:05 UTC, Stefan Koch wrote: On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But

Re: lambda function with "capture by value"

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1; auto dg = (){ writefln("%s", i); }; i = 2; dg(); //

Re: Getting enum from value

2017-08-05 Thread Kreikey via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e [...] Capitals c = cast(Capitals)"Chicago"; writeln(c);// Illinois

Re: lambda function with "capture by value"

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:19:05 UTC, Stefan Koch wrote: On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1;

Re: lambda function with "capture by value"

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1; auto dg = (){ writefln("%s", i); }; i = 2; dg(); //

lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1; auto dg = (){ writefln("%s", i); }; i = 2; dg(); // prints '2' Is there a way to make the delegate "capture by

gtkD window centering message up and no app on taskbar

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
When trying to center the window. If one uses ALWAYS_CENTERED any resizing of the window is totally busted. CENTER also does not work. move(0,0) seems to not be relative to the main display. I'd basically like to center the window on the main display or at least be able to set coordinates

Re: Getting enum from value

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn
On 08/05/2017 07:05 PM, ag0aep6g wrote: E enumFromValue(E)(string s) The type of `s` should probably be a template parameter as well.

Re: Getting enum from value

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn
On 08/05/2017 05:33 PM, Matthew Remmel wrote: I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e enum Capitals { Indiana = "Indianapolis", Illinois = "Chicago", Ohio = "Columbus" }

Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like to minimize unnecessary allocations. Is there any way to get D to

Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: Any ideas? You can use to! in std.conv: import std.stdio; import std.conv; enum Foo { A = "A", B = "B" } void main() {

Re: Size of D bool vs size of C++ bool

2017-08-05 Thread Jeremy DeHaan via Digitalmars-d-learn
On Friday, 4 August 2017 at 20:38:16 UTC, Steven Schveighoffer wrote: On 8/4/17 4:16 PM, Jeremy DeHaan wrote: I'm trying to do some binding code, and I know that C++ bool isn't defined to be a specific size like D's bool. That said, can I assume that the two are the same size on the most

Re: gtk get actual pixel height of widget

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:23:15 UTC, Johnson Jones wrote: I am trying to set positions of widgets automatically. e.g., I have a paned widget and I to set the position of the handle manually based on a percentage of the window. e.g., 0.5 will set the handle midway and both children will

Re: Getting enum from value

2017-08-05 Thread Temtaime via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: Any ideas? You can use to! in std.conv: import std.stdio; import std.conv; enum Foo { A = "A", B = "B" } void main() {

Re: How to build GUI-based applications in D ?

2017-08-05 Thread ashit via Digitalmars-d-learn
thank you everybody for your time to answer my questions.

Re: How to build GUI-based applications in D ?

2017-08-05 Thread ashit via Digitalmars-d-learn
On Saturday, 5 August 2017 at 07:10:50 UTC, aberba wrote: The DlangUI docs has you covered with everything you need to set it up both on the github README file or the github wiki. Its just: dub init PROJECT_NAME dlangui This will create project and add dlangui as dependency. Creating a

Re: Getting enum from value

2017-08-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: Any ideas? You can use to! in std.conv: import std.stdio; import std.conv; enum Foo { A = "A", B = "B" } void main() { writeln("A".to!Foo); }

Re: Getting enum from value

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e [...] What you want is already in the standard library. std.conv.to can

Re: gtk: get property

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:19:43 UTC, Gerald wrote: On Saturday, 5 August 2017 at 15:08:21 UTC, Johnson Jones wrote: I am trying to get the handle size of panned. Not sure if I'm doing it right but [...] I'm using this in Tilix: Value handleSize = new Value(0);

Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e enum Capitals { Indiana = "Indianapolis", Illinois = "Chicago", Ohio = "Columbus" } Capitals enumFromValue(string s) { switch (s)

gtk get actual pixel height of widget

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
I am trying to set positions of widgets automatically. e.g., I have a paned widget and I to set the position of the handle manually based on a percentage of the window. e.g., 0.5 will set the handle midway and both children will have the same height. I 0.2 will set it to to 20%. I want it to

Re: gtk: get property

2017-08-05 Thread Gerald via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:08:21 UTC, Johnson Jones wrote: I am trying to get the handle size of panned. Not sure if I'm doing it right but [...] I'm using this in Tilix: Value handleSize = new Value(0); paned.styleGetProperty("handle-size", handleSize);

gtk: get property

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
I am trying to get the handle size of panned. Not sure if I'm doing it right but Value value = new Value(); paned.getProperty("handle-size", value); GLib-GObject-CRITICAL **: g_object_get_property: assertion 'G_IS_VALUE (value)' failed or I get stuff like GLib-GObject-WARNING **:

Re: Remove instance from array

2017-08-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:30:08

Re: Fix gtkD api display

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 04-08-17 17:24, Gerald wrote: On Friday, 4 August 2017 at 15:08:27 UTC, Mike Wey wrote: Improving the documentation is something i want to do but there are always some more important things to do. Like the Questions/Issues you posted earlier. So unless somebody volunteers it won't happen

Re: gtkD load images

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote: On 03-08-17 21:56, Johnson Jones wrote: If I do something like import gdkpixbuf.Pixbuf; Pixbuf.newFromResource("C:\\a.jpg"); There are two issues here, you need to properly escape the slash: "C:a.jpg". And a.jpg is not a

Re: GtkD custom theme on Windows

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 04-08-17 05:06, Andres Clari wrote: I've made a linux program with GtkD, and so far, it's been pretty awesome, however I'm thinking about porting it to Windows also, but the Adwaita theme is too fugly, and cringy, so I'd want to use a compatible theme, which is supposed to be doable. What

Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 03-08-17 21:56, Johnson Jones wrote: If I do something like import gdkpixbuf.Pixbuf; Pixbuf.newFromResource("C:\\a.jpg"); There are two issues here, you need to properly escape the slash: "C:a.jpg". And a.jpg is not a resource file, so you would use the Pixbuf constuctor to load an

Re: Bug in gtkd?

2017-08-05 Thread Mike Wey via Digitalmars-d-learn
On 03-08-17 23:11, Johnson Jones wrote: On Thursday, 3 August 2017 at 21:00:17 UTC, Mike Wey wrote: On 03-08-17 22:40, Johnson Jones wrote: Ok, so, I linked the gtk to the msys gtk that I installed before when trying to get glade to work and it worked! seems that msys is much more up to date

Re: How to build GUI-based applications in D ?

2017-08-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-01 17:45, ashit wrote: thank you James i should try that. i was always enjoy the pure and efficiency of C. that made me stubborn to learn java. Just to be clear, there's no Java code in DWT. Everything is ported to D. -- /Jacob Carlborg

Re: How to build GUI-based applications in D ?

2017-08-05 Thread aberba via Digitalmars-d-learn
On Thursday, 3 August 2017 at 10:02:19 UTC, ashit wrote: On Tuesday, 1 August 2017 at 16:12:45 UTC, Dukc wrote: On Tuesday, 1 August 2017 at 15:18:12 UTC, ashit wrote: i couldn't set control's width and height (Button widget) shows error. maybe it works a different way. 1. Try