openmohaa/code/uilib/uimledit.h

87 lines
2.7 KiB
C
Raw Normal View History

2016-03-27 11:49:47 +02:00
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
2024-01-01 15:57:44 +01:00
#pragma once
2016-03-27 11:49:47 +02:00
typedef struct selectionpoint_s {
2024-01-01 15:57:44 +01:00
int line;
int column;
2016-03-27 11:49:47 +02:00
} selectionpoint_t;
typedef struct selection_s {
2024-01-01 15:57:44 +01:00
selectionpoint_s begin;
selectionpoint_s end;
2016-03-27 11:49:47 +02:00
} selection_t;
typedef struct dragState_s {
2024-01-01 15:57:44 +01:00
UIPoint2D lastPos;
2016-03-27 11:49:47 +02:00
} dragState_t;
2024-01-01 15:57:44 +01:00
class UIMultiLineEdit : public UIWidget
{
2016-03-27 11:49:47 +02:00
protected:
2024-01-01 15:57:44 +01:00
selection_s m_selection;
dragState_s m_dragState;
UList<str> m_lines;
UIVertScroll *m_vertscroll;
mouseState_t m_mouseState;
bool m_shiftForcedDown;
bool m_edit;
bool m_changed;
2016-03-27 11:49:47 +02:00
public:
2024-01-01 15:57:44 +01:00
CLASS_PROTOTYPE(UIMultiLineEdit);
2016-03-27 11:49:47 +02:00
protected:
2024-01-01 15:57:44 +01:00
void FrameInitialized(void) override;
void PointToSelectionPoint(UIPoint2D& p, selectionpoint_t& sel);
str& LineFromLineNumber(int num, bool resetpos);
void EnsureSelectionPointVisible(selectionpoint_t& point);
void BoundSelectionPoint(selectionpoint_t& point);
void SortSelection(selectionpoint_t **topsel, selectionpoint_t **botsel);
void UpdateCvarEvent(Event *ev);
void SetEdit(Event *ev);
bool IsSelectionEmpty(void);
2016-03-27 11:49:47 +02:00
public:
2024-01-01 15:57:44 +01:00
UIMultiLineEdit();
void Draw(void) override;
qboolean KeyEvent(int key, unsigned int time) override;
void CharEvent(int ch) override;
UIPoint2D getEndSelPoint(void);
void MouseDown(Event *ev);
void MouseUp(Event *ev);
void MouseDragged(Event *ev);
void Scroll(Event *ev);
void DragTimer(Event *ev);
void SizeChanged(Event *ev);
void setData(const char *data);
void getData(str& data);
void Empty(void);
void CopySelection(void);
void PasteSelection(void);
void DeleteSelection(void);
void setChanged(bool b);
bool IsChanged(void);
2016-03-27 11:49:47 +02:00
};