r3 - 10 Feb 2006 - 10:37:25 - ReidEllisYou are here: OSAF >  Journal Web  >  MimiYin > MarkUpBarForDotSeven > MarkupBarImplementationNotes
I'm looking at making the buttons at the top of the sidebar (which area is known as "the markup bar"). I looked at wxWidgets and wxPython, and I think the best approach is to just make a new Python class that inherits from wx.BitmapButton and adds functionality.

Multiple States

The first feature required is having more than one normal "state". That is, when the button is not being pressed or disabled or what have you, it needs to have different representations. For example, the "mail" button need to represent the states of "this item can be turned into an email item" and "this item *is* an email item". This is multiplied by the usual "pressed" and "disabled" versions of each state.

I figure this is the easiest part to implement, as I can just subclass wx.BitmapButton and store a series of bitmaps, with a setState() method to set which bitmap to use at any particular moment. It's a pretty thin wrapper around just calling the SetBitmap{Disabled,Focus,Selected} methods of wxBitmapButton.

Note that John warned me that there is a bug for Windows where wxBitmapButton can peg the CPU if you're not careful - it seems to continually redraw the button. I could see how that could happen if there was some sort of loop in the bitmap-changing logic combined with the refresh logic. I will keep an eye out for that.

Roll-Over

The second feature is to have roll-over state, so that when the mouse moves over the button, it is drawn in some higlighted manner, common to today's applications.

The obvious way to implement this is to use BEGIN_EVENT_TABLE et al to add support for the wxMouseEvents EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW. I'm not sure if the "WINDOW' mentioned means the window the control is in, or the control itself. If the former, then it may require using EVT_MOTION instead, and checking for entering/leaving the control manually.

Menus

The third feature, which is not an immediate requirement is to have a menu drop down, presumably if the button is clicked and held long enough (like the "back" button in most browsers), or perhaps a specific area of the button is clicked (perhaps a small down-arrow tothe right?), or just if the button has items to display in a menu (like folders in a browsers link bar). This obviously need more thinking.

-- ReidEllis - 07 Feb 2006


Status

I'm writing up WhereIsEverything to track my process of learning how to modify Chandler's architecture.

-- ReidEllis - 10 Feb 2006



Feedback

Robin writes in email:

It sounds reasonable, although you might run into some little quirks or differences on the different platforms. Another possiblity you might want to look at is to derive from one of the classes in the wx.lib.buttons module. Those are completly generic, but if you don't need or want to completely replace any native LnF? that the wx.BitpmapButton is providing it may make it a bit easier since they are pure python code. You'll also get more control if you need it, for example instead of just swapping bitmaps and relying the wx.BitmapButton to do the display, you can completely override the drawing of the generic button.

For your EVT_ENTER/LEAVE_WINDOW question, if the events are bound to the bitmap button then they should be emitted when the mouse enters/leaves the button. (Although this might be one of the quirks that you could run into...)

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.