]> git.lyx.org Git - lyx.git/blobdiff - src/screen.C
remove more forms.h cruft
[lyx.git] / src / screen.C
index eb8b55d536b78f9904a30a13f7d6f280376e0cd0..2b17cb9ac9659d5aa6a8f784b5b1080c7ee8a8f5 100644 (file)
 #include "Painter.h"
 #include "WorkArea.h"
 #include "buffer.h"
+#include "BufferView.h"
 #include "font.h"
 #include "insets/insettext.h"
 #include "ColorHandler.h"
+#include "language.h"
 
 using std::max;
 using std::min;
 
-static
+namespace {
+
 GC createGC()
 {
        XGCValues val;
@@ -45,6 +48,8 @@ GC createGC()
                         | GCLineWidth | GCLineStyle , &val);
 }
 
+} // namespace anon
+
 
 // Constructor
 LyXScreen::LyXScreen(WorkArea & o)
@@ -63,9 +68,15 @@ LyXScreen::LyXScreen(WorkArea & o)
 }
 
 
+LyXScreen::~LyXScreen()
+{
+       XFreeGC(fl_get_display(), gc_copy);
+}
+
 void LyXScreen::setCursorColor() 
 {
-       if (!lyxColorHandler) return;
+       if (!lyxColorHandler.get()) return;
 
        GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
        
@@ -106,7 +117,7 @@ void LyXScreen::DrawFromTo(LyXText * text, BufferView * bv,
        int y_text = text->first + y1;
    
        // get the first needed row 
-       Row * row = text->GetRowNearY(y_text);
+       Row * row = text->getRowNearY(y_text);
        // y_text is now the real beginning of the row
    
        int y = y_text - text->first;
@@ -116,13 +127,8 @@ void LyXScreen::DrawFromTo(LyXText * text, BufferView * bv,
                LyXText::text_status st = bv->text->status;
                do {
                        bv->text->status = st;
-#if 0
-                       text->GetVisibleRow(owner.owner(), y + y_offset,
-                                           x_offset, row, y + text->first);
-#else
-                       text->GetVisibleRow(bv, y + y_offset,
+                       text->getVisibleRow(bv, y + y_offset,
                                            x_offset, row, y + text->first);
-#endif
                } while (bv->text->status == LyXText::CHANGED_IN_DRAW);
                bv->text->status = st;
                y += row->height();
@@ -151,13 +157,8 @@ void LyXScreen::DrawOneRow(LyXText * text, BufferView * bv, Row * row,
                LyXText::text_status st = bv->text->status;
                do {
                        bv->text->status = st;
-#if 0
-                       text->GetVisibleRow(owner.owner(), y, x_offset, row,
-                                           y + text->first);
-#else
-                       text->GetVisibleRow(bv, y, x_offset, row,
+                       text->getVisibleRow(bv, y, x_offset, row,
                                            y + text->first);
-#endif
                } while (bv->text->status == LyXText::CHANGED_IN_DRAW);
                bv->text->status = st;
        }
@@ -224,17 +225,10 @@ void LyXScreen::ShowCursor(LyXText const * text, BufferView const * bv)
 {
        if (!cursor_visible) {
                Cursor_Shape shape = BAR_SHAPE;
-#if 0
-               if (text->real_current_font.language() !=
-                   owner.owner()->buffer()->params.language
-                   || text->real_current_font.isVisibleRightToLeft()
-                   != owner.owner()->buffer()->params.language->RightToLeft())
-#else
                if (text->real_current_font.language() !=
                    bv->buffer()->params.language
                    || text->real_current_font.isVisibleRightToLeft()
                    != bv->buffer()->params.language->RightToLeft())
-#endif
                        shape = (text->real_current_font.isVisibleRightToLeft())
                                ? REVERSED_L_SHAPE : L_SHAPE;
                ShowManualCursor(text, text->cursor.x(), text->cursor.y(),
@@ -459,22 +453,22 @@ void LyXScreen::ToggleSelection(LyXText * text, BufferView * bv,
                                int y_offset, int x_offset)
 {
        // only if there is a selection
-       if (!text->selection) return;
+       if (!text->selection.set()) return;
 
        int const bottom = min(
-               max(static_cast<int>(text->sel_end_cursor.y()
-                                    - text->sel_end_cursor.row()->baseline()
-                                    + text->sel_end_cursor.row()->height()),
+               max(static_cast<int>(text->selection.end.y()
+                                    - text->selection.end.row()->baseline()
+                                    + text->selection.end.row()->height()),
                    text->first),
                static_cast<int>(text->first + owner.height()));
        int const top = min(
-               max(static_cast<int>(text->sel_start_cursor.y() -
-                                    text->sel_start_cursor.row()->baseline()),
+               max(static_cast<int>(text->selection.start.y() -
+                                    text->selection.start.row()->baseline()),
                    text->first),
                static_cast<int>(text->first + owner.height()));
 
        if (kill_selection)
-               text->selection = 0;
+               text->selection.set(false);
        DrawFromTo(text, bv, top - text->first, bottom - text->first,
                   y_offset, x_offset);
        expose(0, top - text->first,