It is currently Thu Jun 20, 2013 12:55 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Owner-drawn buttons
PostPosted: Tue May 15, 2012 6:23 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 594
Location: germany
Hello,

Quote:
Any chance for a MacOS adaption?

We will port our client to MacOS, too. If we are finished, I will update the source to work on MacOS, too. Like Bisonte said, it is only about the mouse pointer.

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Mon Jul 16, 2012 3:25 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 594
Location: germany
Hi,

I just updated the initial post with the most recent code. I added rbutton_Hide() function to allow hiding and unhiding rbutton's. If you are using HideGadget() function of PB, the mouse-pointer will still get a hand if you are over such gadget. Using rbutton_Hide() fixes this.

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Wed Feb 06, 2013 3:30 pm 
Offline
New User
New User

Joined: Wed Feb 06, 2013 3:17 pm
Posts: 2
Hello,

I like your code, but I have a little problem

sample code

Code:
; TEST AND EXAMPLE CODE
XIncludeFile "rbutton_include.pbi"

OpenWindow(0, 100, 200, 290, 50, "rButton test window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
SetWindowColor(0, RGB(255, 255, 255))
rbutton_SetFont("Arial", 9, #PB_Font_Bold | #PB_Font_Italic, RGB(255,255,255), -120)
rbutton_Init_OwnerDrawn(80, 30, GetWindowColor(0), RGBA(214,236,255,255), RGBA(0,220,255,255), RGBA(255,255,255,255), RGBA(60,225,137,255),5, 2)
Define regSmall1.i = rbutton_Create(#PB_Any, 0, "open", 10, 10, 0)
Define regSmall2.i = rbutton_Create(#PB_Any, 0, "infos", 105, 10, 0)
rbutton_Init_OwnerDrawn(80, 30, GetWindowColor(0), RGBA(236,214,214,255), RGBA(191,120,120,255), RGBA(255,255,255,255), RGBA(225,60,60,255),5, 2)
Define regSmall3.i = rbutton_Create(#PB_Any, 0, "Quit", 200, 10, 0)

Define Quit.i = 0

Repeat
   Define Event.i = WaitWindowEvent()

   If Event.i = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit.i = 1
   EndIf
   
   If Event.i = #PB_Event_Gadget
      If EventGadget() = regSmall1.i
        File$ = OpenFileRequester("Chose a file", "C:\", "file txt|*.txt",1)
      EndIf
      If EventGadget() = regSmall2.i
         MessageRequester("Infos","Dummy")
      EndIf
      If EventGadget() = regSmall3.i
        Quit.i = 1
      EndIf
   EndIf
   
   rbutton_CheckHover(0)

Until Quit.i = 1

End



first click the save button for example, opens the window OpenFileRequester, close the window and move the cursor over the save button but do not click, the window opens again OpenFileRequester .

for such info button with a window MessageRequester

test on Windows Seven, not tested with Linux

I'm forgetting something in the code?

thank you

sorry for my bad english


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Wed Feb 06, 2013 4:58 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 594
Location: germany
Hi,

you are ignoring some basics: An event might be mouse over, left click, right click etc. In your case, you fire the requester on ALL events (even on mouse over). You should restrict this to left-click:

Code:
; TEST AND EXAMPLE CODE
XIncludeFile "rbutton_include.pbi"
OpenWindow(0, 100, 200, 290, 50, "rButton test window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
SetWindowColor(0, RGB(255, 255, 255))
rbutton_SetFont("Arial", 9, #PB_Font_Bold | #PB_Font_Italic, RGB(255,255,255), -120)
rbutton_Init_OwnerDrawn(80, 30, GetWindowColor(0), RGBA(214,236,255,255), RGBA(0,220,255,255), RGBA(255,255,255,255), RGBA(60,225,137,255),5, 2)
Define regSmall1.i = rbutton_Create(#PB_Any, 0, "open", 10, 10, 0)
Define regSmall2.i = rbutton_Create(#PB_Any, 0, "infos", 105, 10, 0)
rbutton_Init_OwnerDrawn(80, 30, GetWindowColor(0), RGBA(236,214,214,255), RGBA(191,120,120,255), RGBA(255,255,255,255), RGBA(225,60,60,255),5, 2)
Define regSmall3.i = rbutton_Create(#PB_Any, 0, "Quit", 200, 10, 0)

Define Quit.i = 0
Repeat
   Define Event.i = WaitWindowEvent()

   ; I would do this before the handling. Depending on the used event you might want to have hover done before working.
   rbutton_CheckHover(0)

   If Event.i = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit.i = 1
   EndIf
   
   If Event.i = #PB_Event_Gadget
     Define EG.i = EventGadget()
     Define ET.i = EventType()
     If ET.i = #PB_EventType_LeftClick ; somebody clicked the button with left click
       Select EG.i
          Case regSmall1.i
            File$ = OpenFileRequester("Chose a file", "C:\", "file txt|*.txt",1)
          Case regSmall2.i
            MessageRequester("Infos","Dummy")
          Case regSmall3.i
            Quit.i = 1
       EndSelect
     EndIf
   EndIf
Until Quit.i = 1
End


Best

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Wed Feb 06, 2013 5:26 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 213
Location: Uttoxeter UK
Hi kukulkan,

Thanks very much for sharing this wonderful code. :D


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Wed Feb 06, 2013 6:05 pm 
Offline
New User
New User

Joined: Wed Feb 06, 2013 3:17 pm
Posts: 2
Hi kukulkan,

Thank you for your quick response and your explanation, I'll be more careful in the future before asking a question so stupid :?.

I'm going read and reread the documentation PureBasic

Again, thank you for sharing your code

MrPrimus


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Thu Feb 07, 2013 8:19 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 594
Location: germany
Hi Mr. Primus,
MrPrimus wrote:
Hi kukulkan,
Thank you for your quick response and your explanation, I'll be more careful in the future before asking a question so stupid :?.

I dont wanted to sound bugged. Its absolutely ok to ask questions and I'm willing to help. It was not that stupid. No problem :-)

Best,

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Sun Jun 09, 2013 7:12 pm 
Offline
New User
New User

Joined: Sat Jun 08, 2013 11:10 pm
Posts: 1
Hi Kukulkan,

I love your rbutton Gadget. It's the best thing since sliced bread!!! Really Awesome, it gives my little app such a clean, stylish, modern and professional look and feel. However... :wink:

I am trying to add a start/stop toggle a button/s... the button (No icon, "start app" text) starts another app and while this app is running be replaced by a new button (icon, "stop app")

I can switch between hide and show between the two buttons using rbutton_Hide #True and #False. but if i place them over each other, as it were, the button flickers because there is confusion as to which button is getting the mouseover/hover event.

Is there a way to achieve this without the flicker, as it saves valuable space?

PS... it would be awesome if one could use the exact same visual effects other Gadgets, like Tabs of the PanelGadget and preferably not bound to a rectangle so that alpha channels/transparency can be used.


Top
 Profile  
 
 Post subject: Re: Owner-drawn buttons
PostPosted: Mon Jun 10, 2013 6:38 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 594
Location: germany
Hi,

glad that you like it :mrgreen:

Sadly, I dont know the reason. I believe you can update the rbutton_Hide() function with some API (Windows: SendMessage_()) to make it work by disabling the whole gadget. If it does not help, you can try to update the rbutton_CheckHover() function. Maybe the problem is in there?

I'm currently in a big project and therefore I do not have the time to check this. Sorry.

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

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