Drawing a disabled control

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Drawing a disabled control

Esteban A. Maringolo-2
Hi,

        I'm building ownerdraw buttons.
        By now, i can handle the three common states of a button: Released
(normal), Pressed, and Hover (the mouse is over).

        But when the button is disabled I don't know how to get notified about
this. I've redefined #isEnabled: to achieve this, but i'm asking here to
know if there is another "Dolphin way"* of doing this.

* With this i mean: "The way this kind of windows interfacing is done in
Dolphin".

        Best regards.

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Schwab,Wilhelm K
Esteban,

>     I'm building ownerdraw buttons.
>     By now, i can handle the three common states of a button: Released
> (normal), Pressed, and Hover (the mouse is over).
>
>     But when the button is disabled I don't know how to get notified
> about this. I've redefined #isEnabled: to achieve this, but i'm asking
> here to know if there is another "Dolphin way"* of doing this.
>
> * With this i mean: "The way this kind of windows interfacing is done in
> Dolphin".

The "Dolphin way" is to enable/disable/check/uncheck commands rather
than UI elements; see #queryCommand:.  That way, any toolbar buttons as
well as context menu and menu bar items are all affected in one shot.

I'm not sure, but I suspect you might have come up with the ideal
solution.  You might also want to think about checked/unchecked state;
it would probably appear to be pressed when checked???

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Chris Uppal-3
In reply to this post by Esteban A. Maringolo-2
Esteban A. Maringolo wrote:

> I'm building ownerdraw buttons.
> By now, i can handle the three common states of a button: Released
> (normal), Pressed, and Hover (the mouse is over).
>
> But when the button is disabled I don't know how to get notified about
> this. I've redefined #isEnabled: to achieve this, but i'm asking here to
> know if there is another "Dolphin way"* of doing this.

Can you just call #isEnabled from your owner-draw code ?  Rather than keeping
track of the state explicitly yourself, just ask the button when you need to.

Granted, View>>isEnabled is private, but I can't think of any reason why it
should be.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Esteban A. Maringolo-2
In reply to this post by Schwab,Wilhelm K
Bill Schwab escribió:

>>     I'm building ownerdraw buttons.
>>     By now, i can handle the three common states of a button: Released
>> (normal), Pressed, and Hover (the mouse is over).
>>
>>     But when the button is disabled I don't know how to get notified
>> about this. I've redefined #isEnabled: to achieve this, but i'm asking
>> here to know if there is another "Dolphin way"* of doing this.
>>
>> * With this i mean: "The way this kind of windows interfacing is done
>> in Dolphin".

> The "Dolphin way" is to enable/disable/check/uncheck commands rather
> than UI elements; see #queryCommand:.  That way, any toolbar buttons as
> well as context menu and menu bar items are all affected in one shot.

Yes... it's working that way, because my OwnerDrawButton is a
PushButton subclass. So it fits in the command query strategy.
But what I want is to get notified when the command "must be"
disabled. In de default behavior my button draws disabled very
similar to the released state. I want a diferent drawing for the
disabled, as different as in WinXP buttons.

> I'm not sure, but I suspect you might have come up with the ideal
> solution.  You might also want to think about checked/unchecked state;
> it would probably appear to be pressed when checked???

They're only two state push buttons, not designed to work as a
toggle one.

Thanks.


--
Esteban A. Maringolo
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Martin Rubi
In reply to this post by Esteban A. Maringolo-2
Hellow, Esteban.

I don't know how your are handling the drawing, but if you do it in the
wmDrawItem event, you can do something like this

-----

YourButton>>wmDrawItem: message wParam: wParam lParam: lParam
"Private - A part with SbtOwnerRedraw has been asked to redraw itself.
Oblige this request.
Answer true."

| drawItemStruct hDC |

drawItemStruct := DRAWITEMSTRUCT fromAddress: lParam.
hDC := ExternalHandle fromInteger: drawItemStruct hDC.
self paint: (self selectBitmap: drawItemStruct) on: (Canvas withNonOwnedDC:
hDC).
self drawFocus: drawItemStruct.
^true

YourButton>>selectBitmap: aDRAWITEMSTRUCT
"Answer what bitmap to show, depending on the button state
/* Owner draw actions */
#define ODA_DRAWENTIRE 0x0001
#define ODA_SELECT 0x0002
#define ODA_FOCUS 0x0004
/* Owner draw state */
#define ODS_SELECTED 0x0001
#define ODS_GRAYED 0x0002
#define ODS_DISABLED 0x0004
#define ODS_CHECKED 0x0008
#define ODS_FOCUS 0x0010
#if(WINVER >= 0x0400)
#define ODS_DEFAULT 0x0020
#define ODS_COMBOBOXEDIT 0x1000
#endif /* WINVER >= 0x0400 */
#if(WINVER >= 0x0500)
#define ODS_HOTLIGHT 0x0040
#define ODS_INACTIVE 0x0080
#endif /* WINVER >= 0x0500 */ "

| isDisabled isDown |

isDown := aDRAWITEMSTRUCT itemState allMask: 1.
isDisabled := aDRAWITEMSTRUCT itemState allMask: 4.
isDown ifTrue: [^self downBitmap].
isDisabled ifTrue: [^self disabledBitmap].
^self flatBitmap

-----

That its, I let windows and Dolphin handle the state, and I just do the
painting.

Hope it helps.
Best regards.

Martin Rubi

"Esteban A. Maringolo" <[hidden email]> escribió en el mensaje
news:[hidden email]...

> Hi,
>
> I'm building ownerdraw buttons.
> By now, i can handle the three common states of a button: Released
> (normal), Pressed, and Hover (the mouse is over).
>
> But when the button is disabled I don't know how to get notified about
> this. I've redefined #isEnabled: to achieve this, but i'm asking here to
> know if there is another "Dolphin way"* of doing this.
>
> * With this i mean: "The way this kind of windows interfacing is done in
> Dolphin".
>
> Best regards.
>
> --
> Esteban.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Schwab,Wilhelm K
In reply to this post by Esteban A. Maringolo-2
Esteban,

>> The "Dolphin way" is to enable/disable/check/uncheck commands rather
>> than UI elements; see #queryCommand:.  That way, any toolbar buttons
>> as well as context menu and menu bar items are all affected in one shot.
>
>
> Yes... it's working that way, because my OwnerDrawButton is a PushButton
> subclass. So it fits in the command query strategy.
> But what I want is to get notified when the command "must be" disabled.
> In de default behavior my button draws disabled very similar to the
> released state.

Who/what is responsible for invalidating/updating the button's client
area?  From Martin's post, it looks as though windows does it, and it
sends a WM_DRAWITEM message.  Are you working within that framework?


 > I want a diferent drawing for the disabled, as different
> as in WinXP buttons.

If I understand you, that is not unique to XP; Windows has been graying
disabled items since the dark ages.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Drawing a disabled control

Esteban A. Maringolo-2
Bill Schwab escribió:
> Esteban,
>
>>> The "Dolphin way" is to enable/disable/check/uncheck commands rather
>>> than UI elements; see #queryCommand:.  That way, any toolbar buttons
>>> as well as context menu and menu bar items are all affected in one shot.

>> Yes... it's working that way, because my OwnerDrawButton is a
>> PushButton subclass. So it fits in the command query strategy.
>> But what I want is to get notified when the command "must be"
>> disabled. In de default behavior my button draws disabled very similar
>> to the released state.

> Who/what is responsible for invalidating/updating the button's client
> area?  From Martin's post, it looks as though windows does it, and it
> sends a WM_DRAWITEM message.  Are you working within that framework?

Yes, it's being done through WM_DRAWITEM message.

>> I want a diferent drawing for the disabled, as different
>> as in WinXP buttons.

> If I understand you, that is not unique to XP; Windows has been graying
> disabled items since the dark ages.

Yes, of course, previous to windows indeed.
What I mean is the notably "visually" difference between the enabled and
disabled states under default "Luna theme" in WinXP. I.e. the disabled
is flat and faded, and the enabled is raised and colorful.

Best regards.

--
Esteban.