////////////////////////////////////////////////////////////////////////////
// Name:        stc.h
// Purpose:     A wxWindows implementation of Scintilla.  This class is the
//              one meant to be used directly by wx applications.  It does not
//              derive directly from the Scintilla classes, and in fact there
//              is no mention of Scintilla classes at all in this header.
//              This class delegates all method calls and events to the
//              Scintilla objects and so forth.  This allows the use of
//              Scintilla without polluting the namespace with all the
//              classes and itentifiers from Scintilla.
//
// Author:      Robin Dunn
//
// Created:     13-Jan-2000
// RCS-ID:      $Id$
// Copyright:   (c) 2000 by Total Control Software
// Licence:     wxWindows license
/////////////////////////////////////////////////////////////////////////////

#ifndef __stc_h__
#define __stc_h__


#include <wx/wx.h>

//----------------------------------------------------------------------
// BEGIN generated section.  The following code is automatically generated
//       by gen_iface.py.  Do not edit this file.  Edit stc.h.in instead
//       and regenerate

%(VALUES)s

// END of generated section
//----------------------------------------------------------------------
// Others

#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | (1 << wxSTC_MARKNUM_FOLDEROPEN))



//----------------------------------------------------------------------

class  ScintillaWX;                      // forward declare
class  WordList;
struct SCNotification;


extern const wxChar* wxSTCNameStr;

//----------------------------------------------------------------------

class wxStyledTextCtrl : public wxControl {
public:

#ifdef SWIG
    wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
                     const wxPoint& pos = wxDefaultPosition,
                     const wxSize& size = wxDefaultSize, long style = 0,
                     const char* name = "styledtext");
#else
    wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
                     const wxPoint& pos = wxDefaultPosition,
                     const wxSize& size = wxDefaultSize, long style = 0,
                     const wxString& name = wxSTCNameStr);
#endif


#ifndef SWIG
    ~wxStyledTextCtrl();
#endif

//----------------------------------------------------------------------
// BEGIN generated section.  The following code is automatically generated
//       by gen_iface.py.  Do not edit this file.  Edit stc.h.in instead
//       and regenerate

%(METHOD_DEFS)s

// END of generated section
//----------------------------------------------------------------------
// Others...


    // Returns the line number of the line with the caret.
    int GetCurrentLine();

    // Extract style settings from a spec-string which is composed of one or
    // more of the following comma separated elements:
    //
    //      bold                    turns on bold
    //      italic                  turns on italics
    //      fore:#RRGGBB            sets the foreground colour
    //      back:#RRGGBB            sets the background colour
    //      face:[facename]         sets the font face name to use
    //      size:[num]              sets the font size in points
    //      eol                     turns on eol filling
    //      underline               turns on underlining
    //
    void StyleSetSpec(int styleNum, const wxString& spec);



    // Set style size, face, bold, italic, and underline attributes from
    // a wxFont's attributes.
    void StyleSetFont(int styleNum, wxFont& font);



    // Set all font style attributes at once.
    void StyleSetFontAttr(int styleNum, int size,
                          const wxString& faceName,
                          bool bold, bool italic,
                          bool underline);



    // Perform one of the operations defined by the wxSTC_CMD_* constants.
    void CmdKeyExecute(int cmd);



    // Set the left and right margin in the edit area, measured in pixels.
    void SetMargins(int left, int right);


    // Retrieve the start and end positions of the current selection.
#ifdef SWIG
    void GetSelection(int* OUTPUT, int* OUTPUT);
#else
    void GetSelection(int* startPos, int* endPos);
#endif

    // Retrieve the point in the window where a position is displayed.
    wxPoint PointFromPosition(int pos);


    // Scroll enough to make the given line visible
    void ScrollToLine(int line);


    // Scroll enough to make the given column visible
    void ScrollToColumn(int column);

//----------------------------------------------------------------------


#ifndef SWIG
private:
    // Event handlers
    void OnPaint(wxPaintEvent& evt);
    void OnScrollWin(wxScrollWinEvent& evt);
    void OnSize(wxSizeEvent& evt);
    void OnMouseLeftDown(wxMouseEvent& evt);
    void OnMouseMove(wxMouseEvent& evt);
    void OnMouseLeftUp(wxMouseEvent& evt);
    void OnMouseRightUp(wxMouseEvent& evt);
    void OnMouseWheel(wxMouseEvent& evt);
    void OnChar(wxKeyEvent& evt);
    void OnKeyDown(wxKeyEvent& evt);
    void OnLoseFocus(wxFocusEvent& evt);
    void OnGainFocus(wxFocusEvent& evt);
    void OnSysColourChanged(wxSysColourChangedEvent& evt);
    void OnEraseBackground(wxEraseEvent& evt);
    void OnMenu(wxCommandEvent& evt);
    void OnListBox(wxCommandEvent& evt);


    // Turn notifications from Scintilla into events
    void NotifyChange();
    void NotifyParent(SCNotification* scn);

    long SendMsg(int msg, long wp=0, long lp=0);

private:
    DECLARE_EVENT_TABLE()
    DECLARE_CLASS(wxStyledTextCtrl)

    ScintillaWX*        m_swx;
    wxStopWatch         m_stopWatch;


    friend class ScintillaWX;
    friend class Platform;
#endif
};

//----------------------------------------------------------------------

class wxStyledTextEvent : public wxCommandEvent {
public:
    wxStyledTextEvent(wxEventType commandType=0, int id=0);
    ~wxStyledTextEvent() {}

    void SetPosition(int pos)        { m_position = pos; }
    void SetKey(int k)               { m_key = k; }
    void SetModifiers(int m)         { m_modifiers = m; }
    void SetModificationType(int t)  { m_modificationType = t; }
    void SetText(const char* t)      { m_text = t; }
    void SetLength(int len)          { m_length = len; }
    void SetLinesAdded(int num)      { m_linesAdded = num; }
    void SetLine(int val)            { m_line = val; }
    void SetFoldLevelNow(int val)    { m_foldLevelNow = val; }
    void SetFoldLevelPrev(int val)   { m_foldLevelPrev = val; }
    void SetMargin(int val)          { m_margin = val; }
    void SetMessage(int val)         { m_message = val; }
    void SetWParam(int val)          { m_wParam = val; }
    void SetLParam(int val)          { m_lParam = val; }

    int  GetPosition() const         { return m_position; }
    int  GetKey()  const             { return m_key; }
    int  GetModifiers() const        { return m_modifiers; }
    int  GetModificationType() const { return m_modificationType; }
    wxString GetText() const         { return m_text; }
    int  GetLength() const           { return m_length; }
    int  GetLinesAdded() const       { return m_linesAdded; }
    int  GetLine() const             { return m_line; }
    int  GetFoldLevelNow() const     { return m_foldLevelNow; }
    int  GetFoldLevelPrev() const    { return m_foldLevelPrev; }
    int  GetMargin() const           { return m_margin; }
    int  GetMessage() const          { return m_message; }
    int  GetWParam() const           { return m_wParam; }
    int  GetLParam() const           { return m_lParam; }

    bool GetShift() const;
    bool GetControl() const;
    bool GetAlt() const;

    void CopyObject(wxObject& obj) const;

#ifndef SWIG
private:
    DECLARE_DYNAMIC_CLASS(wxStyledTextEvent)

    int  m_position;
    int  m_key;
    int  m_modifiers;

    int  m_modificationType;    // wxEVT_STC_MODIFIED
    wxString m_text;
    int  m_length;
    int  m_linesAdded;
    int  m_line;
    int  m_foldLevelNow;
    int  m_foldLevelPrev;

    int  m_margin;              // wxEVT_STC_MARGINCLICK

    int  m_message;             // wxEVT_STC_MACRORECORD
    int  m_wParam;
    int  m_lParam;
#endif
};

#ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES()
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1653)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1654)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1655)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1656)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1658)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1659)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662)
    DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663)
END_DECLARE_EVENT_TYPES()
#else
    enum {
        wxEVT_STC_CHANGE,
        wxEVT_STC_STYLENEEDED,
        wxEVT_STC_CHARADDED,
        wxEVT_STC_UPDATEUI,
        wxEVT_STC_SAVEPOINTREACHED,
        wxEVT_STC_SAVEPOINTLEFT,
        wxEVT_STC_ROMODIFYATTEMPT,
        wxEVT_STC_DOUBLECLICK,
        wxEVT_STC_MODIFIED,
        wxEVT_STC_KEY,
        wxEVT_STC_MACRORECORD,
        wxEVT_STC_MARGINCLICK,
        wxEVT_STC_NEEDSHOWN,
        wxEVT_STC_POSCHANGED
    };
#endif



#ifndef SWIG
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);

#define EVT_STC_CHANGE(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_STYLENEEDED(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_CHARADDED(id, fn)        DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_UPDATEUI(id, fn)         DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTLEFT(id, fn)    DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_ROMODIFYATTEMPT(id, fn)  DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DOUBLECLICK(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MODIFIED(id, fn)         DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_KEY(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MACRORECORD(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MARGINCLICK(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_NEEDSHOWN(id, fn)        DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_POSCHANGED(id, fn)       DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),

#endif

//----------------------------------------------------------------------
//----------------------------------------------------------------------
#endif