It is currently Mon Mar 27, 2017 7:15 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Possible bug - Canvas Clip Mouse doesn't clip
PostPosted: Fri Jun 06, 2014 7:52 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1360
Location: Uttoxeter, UK
In the code below #PB_Canvas_ClipMouse and #PB_Canvas_Clip do not seem to work.
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:
 ; 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
 

 

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Possible bug - Canvas Clip Mouse doesn't clip
PostPosted: Fri Jun 06, 2014 8:40 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1930
Location: USA
It says in the manual that #PB_Canvas_ClipMouse is not supported on OS X.

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.6.8 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: XP SP3 / AMD 64 4000+ / 1GB DDR / ATI 9250


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: Possible bug - Canvas Clip Mouse doesn't clip
PostPosted: Fri Jun 06, 2014 11:27 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1360
Location: Uttoxeter, UK
@J Baker,

Thank you very much.

I did read the manual. Don't know how I missed this. :oops:

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Possible bug - Canvas Clip Mouse doesn't clip
PostPosted: Fri Jun 06, 2014 5:48 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1930
Location: USA
davido wrote:
@J Baker,

Thank you very much.

I did read the manual. Don't know how I missed this. :oops:

No worries, there's a lot to read. ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.6.8 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: XP SP3 / AMD 64 4000+ / 1GB DDR / ATI 9250


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: Possible bug - Canvas Clip Mouse doesn't clip
PostPosted: Thu Dec 29, 2016 11:55 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Jun 21, 2011 10:39 am
Posts: 325
J. Baker wrote:
It says in the manual that #PB_Canvas_ClipMouse is not supported on OS X.
:cry:

Is this a restriction by Mac OS-X or can we still do it via some API call?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye