//
// Copyright (C) 1999-2004 Toshikaz Hirabayashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// TOSHIKAZ HIRABAYASHI BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// Except as contained in this notice, the name of Toshikaz Hirabayashi shall
// not be used in advertising or otherwise to promote the sale, use or other
// dealings in this Software without prior written authorization from
// Toshikaz Hirabayashi.

#ifndef WSCNWBASE_H
#define WSCNWBASE_H

#include <WScom.h>
#include <WSCbase.h>

#define WSCnwbase_VER  1000
class WSCnwbase :public WSCbase{

  private:
  protected:
    char*     _user_string;
    long      _user_value;
    short     _x;
    short     _y;
    short     _fore_color;
    short     _blink_color;
    WSCushort _w;
    WSCushort _h;

#ifdef WS_USE_MOUSE_IMAGE
    short          _mouse_img;
#endif
    unsigned short _anchor_top;
    unsigned short _anchor_bottom;
    unsigned short _anchor_left;
    unsigned short _anchor_right;
    unsigned  _anchor_top_use:1;
    unsigned  _anchor_bottom_use:1;
    unsigned  _anchor_left_use:1;
    unsigned  _anchor_right_use:1;
    unsigned  _blink_rate:4;
    unsigned  _bl_refreshing:1;
    unsigned  _bl_fl:1;
    unsigned  _tw_fl:1;
	unsigned  _blinking:1;
    unsigned  _mouse_enter:1;
    unsigned  _out_side_mouse_press:1;
    unsigned  _out_side_mouse_release:1;
    unsigned  _out_side_mouse_move:1;
    unsigned  _mouse_grabed:1;
    unsigned  _anchor_under_refreshing:1;

    WSMFpropertyDef(WSNname,      char*,      _instance_name);
    WSMFpropertyDef(WSNuserString,      char*,          _user_string);
    WSMFpropertyDef(WSNuserValue,       long,           _user_value );
    WSMFpropertyDef(WSNblinkRefreshing, WSCbool,        _bl_refreshing );
    WSMFpropertyDef(WSNvis,             WSCbool,        _vis    );
    WSMFpropertyDef(WSNdet,             WSCbool,        _sensitive     );
    WSMFpropertyDef(WSNx,          short,          _x        );
    WSMFpropertyDef(WSNy,          short,          _y        );
    WSMFpropertyDef(WSNwidth,      WSCushort, _w        );
    WSMFpropertyDef(WSNheight,     WSCushort, _h        );
    WSMFpropertyDef(WSNforeColor,  short,          _fore_color);
    WSMFpropertyDef(WSNblinkFlag,  WSCbool,        _bl_fl    );
    WSMFpropertyDef(WSNtwinBlink,  WSCbool,        _tw_fl    );
    WSMFpropertyDef(WSNblinkColor, short,          _blink_color);
    WSMFpropertyDef(WSNblinkRate,  WSCuchar,       _blink_rate  );
    WSMFpropertyDef(WSNanchorTop,     WSCushort,      _anchor_top  );
    WSMFpropertyDef(WSNanchorBottom,  WSCushort,      _anchor_bottom  );
    WSMFpropertyDef(WSNanchorLeft,    WSCushort,      _anchor_left  );
    WSMFpropertyDef(WSNanchorRight,   WSCushort,      _anchor_right  );
    WSMFpropertyDef(WSNanchorTopFlag,     WSCbool,      _anchor_top_use  );
    WSMFpropertyDef(WSNanchorBottomFlag,  WSCbool,      _anchor_bottom_use  );
    WSMFpropertyDef(WSNanchorLeftFlag,    WSCbool,      _anchor_left_use  );
    WSMFpropertyDef(WSNanchorRightFlag,   WSCbool,      _anchor_right_use  );
    WSMFpropertyDef(WSNexport,   WSCbool,      _export_  );

#ifdef WS_USE_MOUSE_IMAGE
    WSMFpropertyDef(WSNmouseImg,   short,          _mouse_img);
#endif

    virtual long _device_initialize();
  public:
    WSCnwbase(WSCbase*,char*);
    virtual ~WSCnwbase();

    virtual void onChildAdded(WSCbase* );

    virtual long clear();
    virtual long redraw();
    virtual long cdraw();
    virtual long execEventProc(long ev,void*);
    virtual long addProcedure(WSCprocedure*);
    virtual void setScaleOffsetPtr(double*);
    virtual void setXOffsetPtr(short*);
    virtual void setYOffsetPtr(short*);
    virtual void update();
    virtual void _adjust_for_anchors(WSCushort,WSCushort);

//    long clearArea();
//    long getGeometry(short*,short*,WSCushort*,WSCushort*);
//    long setGeometry(short,short,WSCushort,WSCushort);

    long    getBlinkRate();
//	void    setBlinkFore(WSCbool);
    WSCbool getBlinkRefresh();

    void  setOutSideMousePress(WSCbool);
    void  setOutSideMouseMove(WSCbool);
    void  setOutSideMouseRelease(WSCbool);
    void  setMouseGrabed(WSCbool);
    WSCbool getOutSideMouseMove();
    WSCbool getOutSideMouseRelease();
    WSCbool getOutSideMousePress();
    WSCbool getMouseGrabed();

    WSMFguiClassDef(WSCnwbase,WSCbase);
	WSMFsetUseDevice(nwDev);
    WSMFversionDef(WSCnwbase);
};
#endif
