/**************************************************************************

    This file is part of Xclass95, a Win95-looking GUI toolkit.
    Copyright (C) 1996, 1997 David Barth, Hector Peraza.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

**************************************************************************/

#ifndef __OXTEXTVIEW_H
#define __OXTEXTVIEW_H

#include <stdio.h>

#include "OXView.h"
#include "OText.h"

#define UNCHANGED       -1
#define MARGIN           3

class OXTextView : public OXView {
protected:
  XFontStruct *_font;
  GC _gc, _gc_marked;
  OText *_text, *_clipboard;
  bool marked_from_x, marked_from_y;
  virtual void DrawRegion(int x, int y, int w, int h);
  virtual void Mark(long xPos, long yPos);
  virtual void UnMark();
  virtual _OXTextView();
public:

  OXTextView(OXWindow *parent, int w, int h, long id, unsigned int sboptions=0);
  OXTextView(OXWindow *parent, int w, int h, long id, OText *text, unsigned int sboptions=0);
  OXTextView(OXWindow *parent, int w, int h, long id, char *string, unsigned int sboptions=0);

 virtual ~OXTextView();
 virtual bool IsSaved() { _isSaved = _text->IsSaved(); return _isSaved;}
 virtual long ToObjXCoord(long xCoord, long line);
 virtual long ToObjYCoord(long yCoord);
 virtual long ToScrXCoord(long xCoord, long line);
 virtual long ToScrYCoord(long yCoord);
 virtual void AdjustWidth();
  friend class OXClient;
  virtual bool  LoadFile(char *fname, long startpos = 0, long length = -1);
  virtual void Clear();
  virtual bool Copy();
  virtual bool SelectAll();
  virtual bool Search(char *string, bool direction, bool caseSensitive);  
  virtual long  ReturnHeighestColHeight()  { return _text->RowCount()*_scrollVal.y; }
  virtual long  ReturnLongestLineWidth();   
  virtual long  ReturnLineLength(long line) {return _text->GetLineLength(line);}
  virtual long  ReturnLongestLine() {return _text->GetLongestLine();}
  virtual long  ReturnLineCount() { return _text->RowCount();}
  virtual int HandleSelectionRequest (XSelectionRequestEvent *event);

  virtual void SetText(OText *text);
  virtual void AddText(OText *text);
  virtual void AddLine(char *string);
  OText *GetText(){return _text;}
};

#endif // __OXTEXTVIEW_H
