//
// Copyright (C) 1999-2004 WideStudio Development Team
//
// 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
// WIDESTUDIO DEVELOPMENT TEAM 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 WideStudio Development Team
// shall not be used in advertising or otherwise to promote the sale, use or
// other dealings in this Software without prior written authorization from
// WideStudio Development Team.

#ifndef WSDMACFORMDEV_H
#define WSDMACFORMDEV_H

#include <WSDwindowDev.h>
#include <Carbon/Carbon.h>

class WSDmacFormDev               :public WSDwindowDev {
  private:
  protected:
//    GC       _gc;
//    Pixmap   _pixmap;
//    WindowRef   _pixm;
//    Widget   _widget;
//    Widget   _pwidget;
//    ControlRef _cntl;
    WindowRef _pwin;
    WSCrect _rect;
    WSCpoint _top_left;
    WSClistData _child_list;
    WSDmacFormDev* _parent;
    RGBColor _fgc;
    RGBColor _bgc;
    short    _bg;
    short    _bg_pix;
    WSCushort _mno;
    WSDmacFormDev* _mouse_press_target;
    WSDmacFormDev* _mouse_move_target;
    WSCbool _is_win;

virtual long createWindow();
virtual long createPixmap(); //call for Expose only...
virtual long destroyWindow();
virtual long destroyPixmap();
virtual long createContext();
virtual long destroyContext();

static pascal OSStatus _handle_events_(EventHandlerCallRef, EventRef, void*);

#if 0 //XXZZ
static  void _evh_expose(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_resize(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_btn_press(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_btn_release(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_mouse_move(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_mouse_in(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_mouse_out(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_delete(Widget,XtPointer,XEvent*,WSCbool*);
static  void _evh_delete2(Widget,void*,void*);
static  void _evh_dummy(Widget,XtPointer,XEvent*,WSCbool*);
#endif //XXZZ
//    long    setPixmap(Pixmap);
//    long    setPixmap(WindowRef);
//    void    setWidget(Widget);
//    long    setGC(GC);
    long setBaseWindow(WindowRef);

virtual void _copy_area(long x,long y,WSCulong w,WSCulong h,long dx,long dy,WSCuchar fl);
virtual void _setup_pixmap(short x,short y,WSCushort w,WSCushort h,short bg,short img_no);
virtual void _clear_area( long x,long y,WSCulong w,WSCulong h);

   WSDmacFormDev* getParentAreaDev();

  public:
    WSDmacFormDev();
    virtual ~WSDmacFormDev();
    virtual long setVisible(WSCbool fl);
    virtual long setValue(long kind,void*);
    virtual long getDeviceResource();
    virtual long getWindowResource();
    virtual long getContextResource();
    virtual long getSpecialResource();
    virtual WSDdev* getEventParentDev();

//    Widget  getWidget();
//    Pixmap  getPixmap();
//    Window  getWindow();
//    GC      getGC();
    virtual WindowRef getBaseWindow();
//    ControlRef getParentControl();
//    ControlRef getControl();
//    WindowRef getPixmap();
    WSCushort getMouseNo();

  virtual long raise();
  virtual long lower();
  virtual long resize_execute(long,long);
  virtual long move_execute(long,long);
  virtual long expose_execute(WSCrect*);
  virtual long mouse_press_execute(WSCpoint*);
  virtual long mouse_release_execute(WSCpoint*);
  virtual long mouse_entered_execute(WSCpoint*);
  virtual long mouse_leaved_execute();
  virtual long mouse_moved_execute(WSCpoint*);
  virtual long mouse_dragged_execute(WSCpoint*);

  WSDmacFormDev* getChildByPoint(short x,short y);

  long addChild(WSDmacFormDev*);
  long delChild(WSDmacFormDev*);
  virtual void getGeometry(long*,long*,long*,long*);
  virtual void getVaridArea(long*,long*,long*,long*);
  virtual void getAbsoluteGeometry(long*,long*,long*,long*);
  virtual void getAbsoluteVaridArea(long*,long*,long*,long*);
  virtual long beginDraw(short x,short y,WSCushort w,WSCushort h,
                         WSCbool absolute,WSCbool scaling = True);
  WSMFclassDef(WSDmacFormDev,WSDwindowDev);
};
#endif
 
