//buttonx.h

#ifndef TButtonEx_H_Included
#define TButtonEx_H_Included
#include "source/glyphdib.h"

class TButtonEx : public TGlyphDib
{
  public:
    TButtonEx(TWindow*        parent,
                 int             id,
                 const char far* text,
                 int X, int Y, int W, int H,
                 bool            isDefault = false,
                 TModule*        module = 0);

    TButtonEx(TWindow* parent, int resourceId, TModule* module = 0);
   ~TButtonEx();

    void   BX_InitVars();   //Initialize a bunch of flags are (denoted by BX_ prefix)

                          //default:    //meaning
    bool   BX_Flat;        //=false       true means button is normally flat, on mouse move it will have border
    bool   BX_FlatAlways;  //=false      true means button is always flat
    bool   BX_Focus;        //=false      true means button will have a focus rectangle when it has focus
    void   BX_SetMenu(int);              //valid menu resource id means button can have it's own menu
    void   BX_SetCursor(int);            //valid cursor resource id means button can have it's own cursor
    int    BX_Menu;        //=0          valid menu resource id means button can have it's own menu id, messages are sent to parent

    bool    BX_TextOnGlyph;
    TColor   BX_ColorText;
    TColor   BX_ColorTextNegative;
    TColor   BX_ColorBk;
    TColor   BX_ColorBkNegative;

    void  MapColors(TDib *dib,TGlyphType type);

    bool  BX_GadgetBorder;//=false      true means button will have a thiner gadget border
    bool  BX_ThinBorder;  //=false      true means button will have a very thin border
    bool  BX_UpdateParent;//=false      true means let the parent know when mouse enters and leaves the button

    bool   ButtonNegative();
    bool   ButtonDown();
    bool   ButtonDisabled();
    bool   ButtonFocus();

    bool   MouseIsIn;
    void   MouseEnter();
    void   MouseLeave();
    bool  WasPushed;

 protected:
    void   EvKeyUp(uint,uint,uint);
    void   EvKeyDown(uint,uint,uint);
    void   EvExitMenuLoop(bool);
    void  SendNotificationEx();

    void  PaintFace(TDC&, TRect&);
    void  PaintButton(TDC&);
    void   PaintFrame(TDC&, TRect&);
    void   PaintFocusRect(TDC&, const TRect&);

    void   EvMouseMove(uint, TPoint&);
    void   EvLButtonUp(uint, TPoint&);
    void   EvLButtonDown(uint, TPoint&);
    DECLARE_RESPONSE_TABLE(TButtonEx);
};
#endif