Can any one confirm, please.
Tested on:
MacBook Pro - Mavericks PB 5.22 LTS - Does not appear to work.
Windows 7 64 bit with PB 5.22 LTS - Works
Linux Mint 16 64 bit with PB 5.22 LTS - Works
Window 7 64 bit with PB 5.30 Beta 2 - Works
Code: Select all
; As we embedded xml directly in the source, the encoding of special characters will vary if we are in unicode mode or not.
; So ensure to use the correct one. This is not needed if the XML is read from an external file or directly included
; with IncludeBinary.
;
CompilerIf #PB_Compiler_Unicode
#XmlEncoding = #PB_UTF8
CompilerElse
#XmlEncoding = #PB_Ascii
CompilerEndIf
#Dialog = 0
#Xml = 0
Runtime Enumeration Gadget
#ListView
#GeneralContainer
#EditorContainer
#BackupContainer
EndEnumeration
Structure SliderData
Len.w
Text$
PixelWidth.W
PicsPerPixel.w
LSpaces.w
RSpaces.w
EndStructure
Runtime Procedure EventSlider()
Protected Slider.SliderData
Static PPos.w, Picxx.w
Width = GadgetWidth(10)
Select EventType()
Case #PB_EventType_MouseLeave
StartDrawing(CanvasOutput(10))
Box(0,0,Width,25,$ffffff)
DrawText(70,3,"Choose approximate picture with mouse - click To Select",0,$fefefe)
SetGadgetAttribute(10,#PB_Canvas_Cursor,#PB_Cursor_Default)
StopDrawing()
ProcedureReturn
Case #PB_EventType_MouseEnter
StartDrawing(CanvasOutput(10))
Box(0,0,Width,25,$ffffff)
SetGadgetAttribute(10,#PB_Canvas_Cursor,#PB_Cursor_Cross)
StopDrawing()
Case #PB_EventType_LeftClick
Debug "Picture: " + Str(Picxx)
SetGadgetAttribute(10,#PB_Canvas_Clip,0)
EndSelect
HalfWay = Width >> 1
PPos = GetGadgetAttribute(10,#PB_Canvas_MouseX)
StartDrawing(CanvasOutput(10))
SetGadgetAttribute(10,#PB_Canvas_Clip,0)
Picxx = (4855 * PPos) / Width
If PPos <= 0
Picxx = 1
EndIf
If PPos < 20
SetGadgetAttribute(10,#PB_Canvas_Clip,1)
EndIf
If PPos >= Width - 20
SetGadgetAttribute(10,#PB_Canvas_Clip,1)
EndIf
If PPos >= Width
Picxx = 4855
EndIf
T$ = " " + Str(Picxx) + " "
Tlen = TextWidth(T$)
MidTlen = Tlen >> 1
If PPos > HalfWay
St = PPos - 26 - Tlen
Else
St = PPos + 20
EndIf
Box(0,0,Width,25,$ffffff)
RoundBox(St,3,6 + TextWidth(T$),20,5,5,$ceccca)
DrawText(St + 3,5,T$,0,$ffffff)
StopDrawing()
EndProcedure
XML$ = "<window id='0' name='test' text='Photograph Cataloguer' minwidth='auto' minheight='auto' " +
"flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
"<hbox>" +
" <vbox>" +
" <container id='#GeneralContainer' width='520' height='650' >" +
" <vbox>" +
" <canvas text='editor' id='10' width='520' height='25' onEvent='EventSlider()' flags='#PB_Canvas_Keyboard | #PB_Canvas_ClipMouse'>" +
" </canvas>" +
" <empty height='105' />" +
" <canvas text='Canvas' id='11' width='520' height='520'>" +
" </canvas>" +
" </vbox>" +
" </container>" +
" </vbox>" +
" <vbox expand='item:1'>" +
" <container id='#xContainer' width='650' height='650'>" +
" <frame text='Editor'>" +
" </frame>" +
" </container>" +
" </vbox>" +
"</hbox>" +
"</window>"
If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
Debug "Canvas dimensions: " + Str(GadgetWidth(10)) + "," + Str(GadgetHeight(10))
StartDrawing(CanvasOutput(10))
Box(0,0,Width,25,$ffffff)
DrawText(70,3,"Choose approximate picture with mouse - click To Select",0,$fefefe)
StopDrawing()
Repeat
;Debug Str(WindowMouseX(0)) + " - " + Str(WindowMouseY(0))
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf