Page 1 of 1

Buttons with blue background

Posted: Mon Oct 10, 2011 12:17 am
by Shardik
I have found out that a lot of native Apple applications (for example
the TextEdit save dialog or the Printer dialog) use buttons with blue
background which even pulsates adjacent to buttons with white
background. PB always displays the buttons with a white background.
Therefore I want to demonstrate how easy it is to display a button
with blue background or with a pulsing blue background:

Code: Select all

ImportC ""
  HiliteControl(ControlRef.L, HiliteState.L)
  SetControlData(Control.L, ControlPartCode.L, TagName.L, BufferSize.L, *Buffer)
EndImport

#kControlButtonPart = 10
#kControlPushButtonDefaultTag = 'dflt'

DrawDefaultRing.B = #True

If OpenWindow(0, 270, 100, 200, 100, "Customized Buttons")
  ButtonGadget(0, 10, 10, 180, 20, "Standard Button")
  ButtonGadget(1, 10, 40, 180, 20, "Pulsing Button")
  ButtonGadget(2, 10, 70, 180, 20, "Highlighted Button")

  SetControlData(GadgetID(1), #kControlButtonPart, #kControlPushButtonDefaultTag, SizeOf(DrawDefaultRing), @DrawDefaultRing)
  HiliteControl(GadgetID(2), #kControlButtonPart)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Buttons with blue background

Posted: Mon Oct 10, 2011 4:04 am
by J. Baker
Nice and simple. ;)

Re: Buttons with blue background

Posted: Mon Oct 10, 2011 4:21 am
by WilliamL
Yes, it is great!

If I remember right, the normal Mac usage is that hitting the 'pulsating' button is the same as hitting the 'return' key. It's nice to have that programming ability now (to have it pulse).

Re: Buttons with blue background

Posted: Mon Oct 10, 2011 7:57 pm
by Shardik
I have just added a new rectangular button with a Metal style appearence:

Code: Select all

ImportC ""
  HiliteControl(ControlRef.L, HiliteState.L)
  SetControlData(ControlRef.L, ControlPartCode.L, TagName.L, BufferSize.L, *Buffer)
  ShowControl(ControlRef.L)
EndImport

#kControlButtonPart = 10
#kControlPushButtonDefaultTag = 'dflt'
#kControlPushButtonIsTexturedTag = 'metl'

DrawDefaultRing.B = #True
IsTextured.B = #True

If OpenWindow(0, 270, 100, 200, 132, "Customized Buttons")
  ButtonGadget(0, 10, 10, 180, 20, "Standard Button")
  ButtonGadget(1, 10, 40, 180, 20, "Pulsing Button")
  ButtonGadget(2, 10, 70, 180, 20, "Highlighted Button")
  ButtonGadget(3, 10, 98, 180, 22, "Metal Button (rectangular)")

  SetControlData(GadgetID(1), #kControlButtonPart, #kControlPushButtonDefaultTag, SizeOf(DrawDefaultRing), @DrawDefaultRing)
  HiliteControl(GadgetID(2), #kControlButtonPart)
  SetControlData(GadgetID(3), #kControlButtonPart, #kControlPushButtonIsTexturedTag, SizeOf(IsTextured), @IsTextured)
  ShowControl(GadgetID(3))

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Buttons with blue background

Posted: Mon Oct 10, 2011 8:50 pm
by J. Baker
The metal button would be nice for ButtonImageGadget(). ;)