Text Alignment, how is it handled ?

2005-02-07 Thread George Ginden
Hi the following code part is not working in Wine as it work (as 
supposed) in Windows.

HRight = GetDlgItem (hDlg,IDC_RIGHT);
Edit_SetText(HRight, "Right");
How is text alignment, in a edit field, handled ?
It looks like the Edit_SetText function is mapped to SetWindowText, 
which calls X11DRV_SetWindowText...
But again, text alignment doesn't work.

Can I do something ?
PS: c source code is attacched
Regards.
/*
**   Ditta..:TeamSystem spa
**   Programmatore..:Stefano Peraldini
**   Nome programma.:Test Wine
**   Data...:04/02/2005
**
*/

//INCLUDE
#include 
#include 
#include "resource.h"

//VARIABILI GLOBALI
HWND hUnaligned, HCenter, HRight;
HDC hdc;

//PROTOTIPI
BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM);

//MAIN
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int 
nCmdShow)
{
// Visualizzazione e controllo errore visualizzazione dialog
if (DialogBox (hInstance, (LPCSTR) IDD_DIALOG1, NULL, DlgProc) == -1)
MessageBox (NULL, "Errore visualizzazione dialog!!","Test 
Wine", MB_ICONQUESTION | MB_OK);
return 0;
}

//DLGPROC della dialog1
BOOL CALLBACK
DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
//Switch per la gestione dei messaggi provenienti dalla dialog1
switch (message) {
//Gestione del VM_CLOSE
case WM_CLOSE:
return TRUE;
break;
//Impostazione dialog1
case WM_INITDIALOG:
{
hUnaligned = GetDlgItem (hDlg,IDC_UNALIGNED);
HCenter = GetDlgItem (hDlg,IDC_CENTER);
HRight = GetDlgItem (hDlg,IDC_RIGHT);
//Edit Box Unaligned
Edit_SetText(hUnaligned, "Unaligned");
//Edit Box Center
Edit_SetText(HCenter, "Center");
//Edit Box Right
Edit_SetText(HRight, "Right");
return TRUE;
}
//Gestione messaggi dialog1
case WM_COMMAND:
switch (LOWORD (wParam)) 
{
case IDOK:
EndDialog (hDlg, 0);
return TRUE;
break;  // END WMCOMMAND
}
return FALSE;
}
return FALSE;
}



Re: Text Alignment, how is it handled ?

2005-02-07 Thread Dimitrie O. Paun
On Mon, Feb 07, 2005 at 04:07:06PM +0100, George Ginden wrote:
> Hi the following code part is not working in Wine as it work (as 
> supposed) in Windows.
> 
> HRight = GetDlgItem (hDlg,IDC_RIGHT);
> Edit_SetText(HRight, "Right");
> 
> How is text alignment, in a edit field, handled ?

Currently, our edit box (dlls/user/edit.c) does not support
right-aligned fields. It is a known limitation. If you want
you can try to implement it, and submit a patch.


-- 
Dimi.



Re: Text Alignment, how is it handled ?

2005-02-08 Thread George Ginden
Dimitrie O. Paun ha scritto:
Currently, our edit box (dlls/user/edit.c) does not support
right-aligned fields. It is a known limitation. If you want
you can try to implement it, and submit a patch.
 

OK, I'm into it. But wait, I'm pretty new to the Wine codebase...
Do you think it is a hard implementation or an easy one ?
If the alignment thing is still not implement... Well there must be a 
reason ...
Do I miss somthing ?

Regards.



Re: Text Alignment, how is it handled ?

2005-02-08 Thread Ulrich Czekalla
Actually I just started to look at this as well. I expect to have a patch
in the next day or so. If you already have something let me know and I'll
stop working on it.

Thanks,

/Ulrich

On Tue, Feb 08, 2005 at 09:26:30AM +0100, George Ginden wrote:
> Dimitrie O. Paun ha scritto:
> 
> >Currently, our edit box (dlls/user/edit.c) does not support
> >right-aligned fields. It is a known limitation. If you want
> >you can try to implement it, and submit a patch.
> > 
> >
> OK, I'm into it. But wait, I'm pretty new to the Wine codebase...
> Do you think it is a hard implementation or an easy one ?
> If the alignment thing is still not implement... Well there must be a 
> reason ...
> Do I miss somthing ?
> 
> Regards.
> 
> 



Re: Text Alignment, how is it handled ?

2005-02-10 Thread Ulrich Czekalla
Hi George,

I haven't heard back from you so I assume you haven't implemented anything
yet. Here is my quick attempt at adding support for ES_RIGHT and ES_CENTER.

Modifying the edit control made me realize how much room there is to
improve the edit control implementation. Of course, my patch makes no
attempt to rewrite any of it ;-)

/Ulrich


On Tue, Feb 08, 2005 at 12:53:56PM -0500, Ulrich Czekalla wrote:
> Actually I just started to look at this as well. I expect to have a patch
> in the next day or so. If you already have something let me know and I'll
> stop working on it.
> 
> Thanks,
> 
> /Ulrich
> 
> On Tue, Feb 08, 2005 at 09:26:30AM +0100, George Ginden wrote:
> > Dimitrie O. Paun ha scritto:
> > 
> > >Currently, our edit box (dlls/user/edit.c) does not support
> > >right-aligned fields. It is a known limitation. If you want
> > >you can try to implement it, and submit a patch.
> > > 
> > >
> > OK, I'm into it. But wait, I'm pretty new to the Wine codebase...
> > Do you think it is a hard implementation or an easy one ?
> > If the alignment thing is still not implement... Well there must be a 
> > reason ...
> > Do I miss somthing ?
> > 
> > Regards.
> > 
> > 
Index: dlls/user/edit.c
===
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.14
diff -u -p -r1.14 edit.c
--- dlls/user/edit.c19 Jan 2005 20:53:38 -  1.14
+++ dlls/user/edit.c10 Feb 2005 17:49:00 -
@@ -1274,7 +1274,10 @@ static void EDIT_BuildLineDefs_ML(EDITST
rc.top = es->format_rect.top + nstart_line * es->line_height -
(es->y_offset * es->line_height); /* Adjust for 
vertical scrollbar */
rc.bottom = rc.top + es->line_height;
-   rc.left = es->format_rect.left + 
(INT)LOWORD(GetTabbedTextExtentW(dc,
+   if ((es->style & ES_CENTER) || (es->style & ES_RIGHT))
+   rc.left = es->format_rect.left;
+   else
+   rc.left = es->format_rect.left + 
(INT)LOWORD(GetTabbedTextExtentW(dc,
es->text + nstart_index, istart - 
nstart_index,
es->tabs_count, es->tabs)) - 
es->x_offset; /* Adjust for horz scroll */
rc.right = es->format_rect.right;
@@ -1312,7 +1315,27 @@ static void EDIT_BuildLineDefs_ML(EDITST
  */
 static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
 {
-es->text_width = (short)LOWORD(EDIT_EM_PosFromChar(es, strlenW(es->text), 
FALSE));
+   SIZE size;
+   LPWSTR text;
+   HDC dc;
+   HFONT old_font = 0;
+
+   text = EDIT_GetPasswordPointer_SL(es);
+
+   dc = GetDC(es->hwndSelf);
+   if (es->font)
+   old_font = SelectObject(dc, es->font);
+
+   GetTextExtentPoint32W(dc, text, strlenW(text), &size);
+
+   if (es->font)
+   SelectObject(dc, old_font);
+   ReleaseDC(es->hwndSelf, dc);
+
+   if (es->style & ES_PASSWORD)
+   HeapFree(GetProcessHeap(), 0, text);
+
+   es->text_width = size.cx;
 }
 
 /*
@@ -1412,6 +1435,10 @@ static INT EDIT_CharFromPos(EDITSTATE *e
line--;
}
x += es->x_offset - es->format_rect.left;
+   if (es->style & ES_RIGHT)
+   x -= (es->format_rect.right - es->format_rect.left) - 
line_def->width;
+   else if (es->style & ES_CENTER)
+   x -= ((es->format_rect.right - es->format_rect.left) - 
line_def->width) / 2;
if (x >= line_def->width) {
if (after_wrap)
*after_wrap = (line_def->ending == END_WRAP);
@@ -1441,11 +1468,22 @@ static INT EDIT_CharFromPos(EDITSTATE *e
} else {
LPWSTR text;
SIZE size;
+   INT indent;
if (after_wrap)
*after_wrap = FALSE;
x -= es->format_rect.left;
if (!x)
return es->x_offset;
+
+   if (!es->x_offset)
+   {
+   indent = (es->format_rect.right - es->format_rect.left) 
- es->text_width;
+   if (es->style & ES_RIGHT)
+   x -= indent;
+   else if (es->style & ES_CENTER)
+   x -= indent / 2;
+   }
+
text = EDIT_GetPasswordPointer_SL(es);
dc = GetDC(es->hwndSelf);
if (es->font)
@@ -2884,9 +2922,13 @@ static LRESULT EDIT_EM_PosFromChar(EDITS
INT li;
INT x;
INT y = 0;
+   INT w;
+   INT lw = 0;
+   INT ll = 0;
HDC dc;
HFONT old_font = 0;
SIZE size;
+   LINEDEF *line_def;
 
index = min(index, len);
dc = GetDC(es->hwndSelf);
@@

Re: Text Alignment, how is it handled ?

2005-02-10 Thread Ulrich Czekalla
Hi George,

I haven't heard back from you so I assume you haven't implemented anything
yet. Here is my quick attempt at adding support for ES_RIGHT and ES_CENTER.

Modifying the edit control made me realize how much room there is to
improve the overall edit control implementation. Of course, my patch makes
no attempt to rewrite any of it ;-)

/Ulrich


On Tue, Feb 08, 2005 at 12:53:56PM -0500, Ulrich Czekalla wrote:
> Actually I just started to look at this as well. I expect to have a patch
> in the next day or so. If you already have something let me know and I'll
> stop working on it.
> 
> Thanks,
> 
> /Ulrich
> 
> On Tue, Feb 08, 2005 at 09:26:30AM +0100, George Ginden wrote:
> > Dimitrie O. Paun ha scritto:
> > 
> > >Currently, our edit box (dlls/user/edit.c) does not support
> > >right-aligned fields. It is a known limitation. If you want
> > >you can try to implement it, and submit a patch.
> > > 
> > >
> > OK, I'm into it. But wait, I'm pretty new to the Wine codebase...
> > Do you think it is a hard implementation or an easy one ?
> > If the alignment thing is still not implement... Well there must be a 
> > reason ...
> > Do I miss somthing ?
> > 
> > Regards.
> > 
> > 
> 
Index: dlls/user/edit.c
===
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.14
diff -u -p -r1.14 edit.c
--- dlls/user/edit.c19 Jan 2005 20:53:38 -  1.14
+++ dlls/user/edit.c10 Feb 2005 17:49:00 -
@@ -1274,7 +1274,10 @@ static void EDIT_BuildLineDefs_ML(EDITST
rc.top = es->format_rect.top + nstart_line * es->line_height -
(es->y_offset * es->line_height); /* Adjust for 
vertical scrollbar */
rc.bottom = rc.top + es->line_height;
-   rc.left = es->format_rect.left + 
(INT)LOWORD(GetTabbedTextExtentW(dc,
+   if ((es->style & ES_CENTER) || (es->style & ES_RIGHT))
+   rc.left = es->format_rect.left;
+   else
+   rc.left = es->format_rect.left + 
(INT)LOWORD(GetTabbedTextExtentW(dc,
es->text + nstart_index, istart - 
nstart_index,
es->tabs_count, es->tabs)) - 
es->x_offset; /* Adjust for horz scroll */
rc.right = es->format_rect.right;
@@ -1312,7 +1315,27 @@ static void EDIT_BuildLineDefs_ML(EDITST
  */
 static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
 {
-es->text_width = (short)LOWORD(EDIT_EM_PosFromChar(es, strlenW(es->text), 
FALSE));
+   SIZE size;
+   LPWSTR text;
+   HDC dc;
+   HFONT old_font = 0;
+
+   text = EDIT_GetPasswordPointer_SL(es);
+
+   dc = GetDC(es->hwndSelf);
+   if (es->font)
+   old_font = SelectObject(dc, es->font);
+
+   GetTextExtentPoint32W(dc, text, strlenW(text), &size);
+
+   if (es->font)
+   SelectObject(dc, old_font);
+   ReleaseDC(es->hwndSelf, dc);
+
+   if (es->style & ES_PASSWORD)
+   HeapFree(GetProcessHeap(), 0, text);
+
+   es->text_width = size.cx;
 }
 
 /*
@@ -1412,6 +1435,10 @@ static INT EDIT_CharFromPos(EDITSTATE *e
line--;
}
x += es->x_offset - es->format_rect.left;
+   if (es->style & ES_RIGHT)
+   x -= (es->format_rect.right - es->format_rect.left) - 
line_def->width;
+   else if (es->style & ES_CENTER)
+   x -= ((es->format_rect.right - es->format_rect.left) - 
line_def->width) / 2;
if (x >= line_def->width) {
if (after_wrap)
*after_wrap = (line_def->ending == END_WRAP);
@@ -1441,11 +1468,22 @@ static INT EDIT_CharFromPos(EDITSTATE *e
} else {
LPWSTR text;
SIZE size;
+   INT indent;
if (after_wrap)
*after_wrap = FALSE;
x -= es->format_rect.left;
if (!x)
return es->x_offset;
+
+   if (!es->x_offset)
+   {
+   indent = (es->format_rect.right - es->format_rect.left) 
- es->text_width;
+   if (es->style & ES_RIGHT)
+   x -= indent;
+   else if (es->style & ES_CENTER)
+   x -= indent / 2;
+   }
+
text = EDIT_GetPasswordPointer_SL(es);
dc = GetDC(es->hwndSelf);
if (es->font)
@@ -2884,9 +2922,13 @@ static LRESULT EDIT_EM_PosFromChar(EDITS
INT li;
INT x;
INT y = 0;
+   INT w;
+   INT lw = 0;
+   INT ll = 0;
HDC dc;
HFONT old_font = 0;
SIZE size;
+   LINEDEF *line_def;
 
index = min(index, len);
dc = GetDC(es->hw

Re: Text Alignment, how is it handled ?

2005-02-14 Thread Gabriele Giorgetti
Ulrich Czekalla ha scritto:
Hi George,
I haven't heard back from you so I assume you haven't implemented anything
yet. Here is my quick attempt at adding support for ES_RIGHT and ES_CENTER.
Modifying the edit control made me realize how much room there is to
improve the edit control implementation. Of course, my patch makes no
attempt to rewrite any of it ;-)
/Ulrich
 

This patch works without any apparent problem.
Fixes bug 2698.
Regards.