Page 1 of 2

Right-To-Left language support?!

Posted: Mon May 15, 2006 7:16 pm
by Pantcho!!
Hello All.
I think i am missing somthing here.
I have this application i want to code in Hebrew which is a right to left language, and it finally hit me - the menus are in the wrong position
the problem is with menus, listicongadget and all those gadgets .
Now i dont know what to do, i cant make the application in english.

Is there anyway i can make the whole app in a LOCAL mode?!

Please if you know anything in the subject write a comment, anything helpful will do.

Thank you.

Pantcho.

Posted: Mon May 15, 2006 7:59 pm
by Num3
Have your tried to compiles with the unicode option ?
Dunno if it fixes it, but it's a possible solution!

Posted: Mon May 15, 2006 11:53 pm
by Pantcho!!
The language fonts are okey, you can put any font you wish to any gadget of course but it is the position of the menus.
For example if a windows menu is diaplayed in the top left corner of the window in localized applications the menu start in the right top window corner.
2nd example is ListIconGadget which in localized languages the first field you enter like "field1" + chr(10) + "field2" the field2 if presented first because of the localization of the app.

there must be a way, even a suggestion will be nice.

Thank you.

Posted: Tue May 16, 2006 12:14 am
by dagcrack
You guys also use left scrollbars right?

Posted: Tue May 16, 2006 10:56 am
by Pantcho!!
Yes, all software made in my hebrew language are in oppsite directions.
I personally never program in my mother language, but when you do know to programming but you cant localize it, that is very distrubing
there for i searched and downloaded a few examples and screen shot them.

ListIconGadget Example:
Image

ListViewGadget Example:
Image

And most important MenuBar example:
Image

ANY help/thoughts/advices will be great.

Thank you.
Pantcho.

Posted: Tue May 16, 2006 12:04 pm
by va!n
@pantcho:
is this waht you are looking for? (same for windows?)

Code: Select all

; -------- by va!n --------

#MB_RIGHT      = $80000
#MB_RTLREADING = $100000

MessageBox_(0,"Test","Text from right to left",#MB_RIGHT|#MB_RTLREADING  )
MessageBox_(0,"Test","Text from right to left",#MB_RIGHT )

Posted: Tue May 16, 2006 12:12 pm
by Pantcho!!
YES! awesome for a simple messagebox! but what about all other gadgets???? :P

Posted: Tue May 16, 2006 12:22 pm
by va!n
@pantcho:
afaik its not so easy to do with PB commands, because stuff like scrollbar on left are API constants you have to use and i dont know if there is an easy way using SendMessage_ or something like this to change the flags of a window/control. when having next days some more time, i will try what i can do for you to solve the problem.

Posted: Tue May 16, 2006 1:05 pm
by Rings
no support at all ;)
Only for Listview via Tabstops
For Other gadgets , i would prefer using Spaces in front of strings

Code: Select all

;;
; Right align with gadgets
; first atempt for ListView with tabstops
;
; done by  Siegfried.Rings 2 use in Purebasic (c) 2006
;
;

Procedure GadgetAlignRight(Gadget)

hwndListview= GadgetID(Gadget);get hwnd for gadget
result=SendMessage_(hwndListview,#LB_SETTABSTOPS,0,0) ;first set 2 NULL


;now calculate the distance from left 2 right
rc.RECT
GetClientRect_(hwndListview, @rc)
hDC = GetDC_(hwndListview)
If hDC 
  hFont = SendMessage_(hwndListview, #WM_GETFONT, 0, 0)
  hFontOld = SelectObject_(hDC, hFont)
  sChars.s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
  sz.size
  If GetTextExtentPoint32_(hDC, sChars, Len(sChars), sz) 
   cxAvLBChar = sz\cx / Len(sChars)
   cxDlgBase = GetDialogBaseUnits_() 
   cxDlgBase =cxDlgBase & $FFFF
   CalcPixelsPerDlgUnit.f = (2 * cxAvLBChar) / cxDlgBase
  EndIf
  SelectObject_(hDC, hFontOld)
  ReleaseDC_(hwndListview, hDC)
EndIf
If CalcPixelsPerDlgUnit=0 
 ProcedureReturn
EndIf
value= - ((rc\Right - rc\Left)/CalcPixelsPerDlgUnit)
result=SendMessage_(hwndListview,#LB_SETTABSTOPS,1,@value);set tabstop
InvalidateRect_(hwndListview,0,-1);invalidate winbdow 2 redraw
EndProcedure



  If OpenWindow(0, 0, 0, 270, 240, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    #Listview=0
   
    ListViewGadget(#Listview, 10, 10, 250, 120,#LBS_USETABSTOPS);note the additional flag !
    For a = 1 To 500
      AddGadgetItem (#Listview, -1, Chr(9) + "Item " + Str(a) + " of the Listview")   ; 
    Next
    SetGadgetState(0, 9)    
    GadgetAlignRight(#Listview)
    
    #Button=1
    ButtonGadget(#Button, 10, 130, 180, 30, "right Button",#PB_Button_Right) 
   
    #Text=2
    TextGadget(#Text, 10, 170, 180, 30, "right text",#PB_Text_Right) 
    
    #Checkbox=3
    CheckBoxGadget(#Checkbox,10, 200, 180, 30, "right Checkbox",#PB_CheckBox_Right)
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf


Posted: Tue May 16, 2006 1:48 pm
by thefool
Rings wrote:no support at all ;)
Absolutely untrue..

Code: Select all

SetWindowLong_(GadgetID(Listview_0),#GWL_EXSTYLE,#WS_EX_LAYOUTRTL|0)
this will set your listview scollbar to the left, and all text to the right. (Like its supposed to be when its RTL)

for the window:

Code: Select all

SetWindowLong_(WindowID(window_0),#GWL_EXSTYLE,#WS_EX_LAYOUTRTL | 0);#WS_EX_TOOLWINDOW)
  SetWindowPos_(WindowID(window_0), 0, -1 , -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_NOZORDER  | #SWP_FRAMECHANGED | #SWP_SHOWWINDOW) 

Posted: Tue May 16, 2006 2:32 pm
by Pantcho!!
Thanks Rings for you detailed example! i apperciate it alot!

And va!n to you too

and damn big thanks to thefool!! for showing it is possible.

I posted a little code in the tricks and tips

http://www.purebasic.fr/english/viewtopic.php?t=21840

Pantcho.

Posted: Tue May 16, 2006 8:35 pm
by Dare2
Very useful information, thanks!


BTW, is that constant "WS_EX_LAYOUTRTL" anywhere in your SDK and if so, how did you find it?

Posted: Tue May 16, 2006 9:10 pm
by thefool
Dare2; check ApiViewer!

Posted: Tue May 16, 2006 10:21 pm
by Dare2
thefool wrote:Dare2; check ApiViewer!
Okay, found it. Checked it out. Just had a quick look and looks magic! Thanks! :)

Posted: Wed May 17, 2006 7:40 am
by Rings
thefool wrote:
Rings wrote:no support at all ;)
Absolutely untrue..
that should only mean that i do not support my code :)