Re: How to center dlangui on screen

2018-11-28 Thread Edgar Huckert via Digitalmars-d-learn
On Wednesday, 28 November 2018 at 08:55:11 UTC, greatsam4sure 
wrote:

I am learning Dlang and Dlangui.

I encounter, a little problem on:

 how to center dlangui window on screen.

How to set the window width and height outside the constructor

How to maximize and minimize the window using code.

How to set global font for the application.  The font display 
is not too nice.


I have check online, the documentation  and available tutorial 
to no help


Thanks in advance


For a little bit of information look at: 
https://github.com/buggins/dlangui/pull/372


Without going into depth I have tested this under Linux/GTK with 
dlangui:


WindowState state;
Rectrect;
rect.left   = 800;
rect.top= 10;
rect.bottom = 600;
rect.right  = 1000;
bool bRet= window.setWindowState(state,
 false,
 rect);

window.show();

This changed the position and size of my initial window.

Edgar Huckert



Re: extern __gshared const(char)* symbol fails

2018-09-01 Thread Edgar Huckert via Digitalmars-d-learn
On Friday, 31 August 2018 at 17:50:17 UTC, Steven Schveighoffer 
wrote:

...
When you use const char* in D, it's expecting a *pointer* to be 
stored at that address, not the data itself. So using it means 
segfault. The static array is the correct translation, even 
though it leaks implementation details.


In C, it's working because C has the notion of a symbol being 
where an array starts. D has no concept of a C array like that, 
every array must have a length. So there is no equivalent you 
can use in D -- you have to supply the length.




I think this is only correct for dynamic arrays. For static 
arrays I have the impression that it works exactly as in C, i.e. 
the address of the array is the address of the first array 
element. See this simple code:


import std.stdio;
import std.array;

void main()
{
  // static array
  ulong [4] ulArr1 = [0,1,2,3];
  ulong *p1 = ulArr1.ptr;
  ulong *p2 = &(ulArr1[0]);
  ulong [4] *p3 = 
  writeln("same pointers: ", cast(void *)p1 == cast(void *)p2);
  writeln("same pointers: ", cast(void *)p3 == cast(void *)p2);
  writeln("");
  // dynamic array
  ulong [] ulArr2 = [0,1,2,3];
  p1 = ulArr2.ptr;
  p2 = &(ulArr2[0]);
  ulong [] *p5 = 
  writeln("same pointers: ", cast(void *)p1 == cast(void *)p2);
  writeln("same pointers: ", cast(void *)p5 == cast(void *)p2);
}   // end main()

This produces (with dmd):

same pointers: true
same pointers: true

same pointers: true
same pointers: false