Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / July 2005



Tip: Looking for answers? Try searching our database.

Newbie Question on Pushbuttons

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Elliott Dixon - 24 Jul 2005 13:29 GMT
I'm writing in Carbon using Xcode 2. I use several push buttons (created in
Resorcerer) on each of several views in a single window (I use tabs to
transfer from view to view). Each view has a different color background and
contains editable fields set up via Text Edit for user input. My problem is
that I would like to designate a default pushbutton for each view, but I
can't get rid of the white background surrounding the default pushbutton
(the one that pulsates). It became apparent to me as I kept experimenting
that the default pushbutton must be constantly redrawing itself in order to
create the blue pulsating animation effect, because I can get rid of the
white background in the other pushbuttons simply by temporarily changing the
window's background color with calls to RGBBackColor just before they are
drawn, but for a default pushbutton, I realized that its definition function
is apparently called continuously which therefore includes redrawing
continually the background color of the window it's in. However, I can't
simply change the window's background color to the color of my view because
I need to keep the white background for the text fields. Is there a way to
control a default pushbutton's background color without having to write an
entirely new CDEF? One clue I came across was to define a custom user pane,
which has a tag to control the background color. But will using this really
control the background color of the pulsating pushbutton itself? Will the
loop it enters go to the background color of the user pane, or will it still
utilize only the window's background color? Is there even a simpler, more
direct way to resolve this, even if the user pane approach will work? Maybe
there's more up to date info of which I am simply unaware. Any help would be
much appreciated.

ECDixon
David Phillip Oster - 27 Jul 2005 04:38 GMT
> Is there even a simpler, more direct way to resolve this?

Yes, create your window form a nib, turn on "compositing" for the window
in Interface builder. Before you show the window, color it with:

SetWindowContentColor(theWindow, &myColorRGB);

At least in 10.4, which is as much as I tested, things work correctly,
and that is all you need to do.

Signature

David Phillip Oster

Elliott Dixon - 27 Jul 2005 10:00 GMT
David,
Thanks for taking the time to think about my question and test your proposed
solution. My problem is further complicated in that I am working with a
non-rectangular custom window set up with CreateCustomWindow. Also I have
not converted *yet* to using the Carbon Event Mgr, as I am still using
WaitNextEvent. So your suggestion of creating a nib window probably won't
work for me for my current project, as my understanding is that Carbon nib
resources require using the Carbon Event Mgr. Also I don't yet know how to
recreate a custom window as a nib. Perhaps I can study about how to use the
function you recommended, SetWindowContentColor, in a different way, but any
further suggestions are welcomed.

ECDixon

On 7/26/05 8:38 PM, in article
oster-19C3AC.20384726072005@newssvr14-ext.news.prodigy.com, "David Phillip
Oster" <oster@ieee.org> wrote:

>> Is there even a simpler, more direct way to resolve this?
>
[quoted text clipped - 5 lines]
> At least in 10.4, which is as much as I tested, things work correctly,
> and that is all you need to do.
David Phillip Oster - 27 Jul 2005 16:43 GMT
...
> My problem is further complicated in that I am working with a
> non-rectangular custom window set up with CreateCustomWindow. Also I have
[quoted text clipped - 5 lines]
> function you recommended, SetWindowContentColor, in a different way, but any
> further suggestions are welcomed.

Lookup SetControlColorProc(). It is specifically designed for passing in
a UPP to a pointer to a procedure for drawing the background array of a
control.

Signature

David Phillip Oster

Elliott Dixon - 30 Jul 2005 06:56 GMT
> Lookup SetControlColorProc(). It is specifically designed for passing in
> a UPP to a pointer to a procedure for drawing the background array of a
> control.

Thanks for the suggestion, David. That routine appears to be deprecated,
although it is still available (but not recommended). In the reference guide
for this API, under Carbon Porting Notes, it says "instead of specifying a
callback to redraw your background, you should make the background a control
and then embed your other controls within it". So I guess I'm back to
needing to set up a user pane and embed my pushbuttons within it. In either
case I'd have to write a routine at some stage to set the background color.
Do you, or anyone else reading this, know of any sample code, or willing to
provide me with the steps required, that would assist me in writing the
function to set the background color of such a user pane once I've created
it? I've found some info in K.J. Bricknell's book, "Carbon Programming", but
the section that discusses writing functions for a user pane assumes that
the reader is already well acquainted with how to go about writing such
functions, so he only provides the constants SetControlData() would require
(which in my case is kControlUserPaneBackgroundProcTag) once the function is
written. How do I define a user pane function that would simply set its
background color???? (I did see an API which I think was called
SetUpControlBackground(). I guess that at some point in my function I would
call this, but none of its parameters requires a color, so I'm still
confused.)

ECDixon
James W. Walker - 27 Jul 2005 17:18 GMT
>  Also I have
> not converted *yet* to using the Carbon Event Mgr, as I am still using
> WaitNextEvent.

It is perfectly possible to use some Carbon Events in a program that
uses WaitNextEvent.
Elliott Dixon - 30 Jul 2005 06:58 GMT
> It is perfectly possible to use some Carbon Events in a program that
> uses WaitNextEvent.

Thanks for clarifying this, I'd always thought it was an either-or choice.
This new understanding will open up new possibilities for my app.

ECDixon
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.