Page 1 of 1

Help equivalent win api code to mac & linux

Posted: Tue Nov 05, 2013 12:13 am
by Zebuddi123
Hi to all

Could some kind soul help me with translating this small win api code to equivalent for mac and linux

Code: Select all

  For a=1 To lv_selected_pos
              SetScrollPos_(GadgetID(ListIcon_0),#SB_VERT,a,#True)
              SendMessage_(GadgetID(ListIcon_0),#WM_VSCROLL,#SB_LINEDOWN,0)
            Next a
to scroll the last selected element of a listview to the top element of the list after a refresh ie: cleargadgetitems(gadget) and re-populate

and the equivalent of #es_centre for the string gadget


Thanks

Zebuddi. :)

Re: Help equivalent win api code to mac & linux

Posted: Tue Nov 05, 2013 7:07 pm
by Shardik
If looking for cross-platform code using platform-specific API functions you may take a look into this posting in which I have collected links to a lot of examples. There you would have found already an example on how to right align a text in the StringGadget. I have modified it below to center the text:

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  ImportC ""
    gtk_entry_set_alignment(Entry.I, XAlign.F)
  EndImport
CompilerEndIf

OpenWindow(0, 100, 100, 280, 70, "StringGadget with centered text", #PB_Window_SystemMenu)
StringGadget(0, 20, 20, 240, 21, "Centered text")

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Linux
    gtk_entry_set_alignment(GadgetID(0), 0.5)
  CompilerCase #PB_OS_MacOS
    CocoaMessage(0, GadgetID(0), "setAlignment:", 2)
  CompilerCase #PB_OS_Windows
    If OSVersion() > #PB_OS_Windows_XP
      SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) & $FFFFFFFC | #ES_CENTER) 
    Else
      StringGadget(0, 60, 20, 150, 21, "Centered text", #ES_CENTER)
    EndIf
CompilerEndSelect

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
You will find another link to a ListIconGadget example which ensures the visibility of a selected line or scrolls it to the center of the ListIconGadget. It would be nice if you could post a simple runnable Windows example which demonstrates exactly what you want to achieve and I will try to add the Linux and MacOS part...

It would be nice and helpful if a mod or admin would move my above mentioned posting from the Mac OSX subforum to the Tricks 'n' Tips subforum (and ideally even make it sticky)... :P