Kaydet (Commit) d6eeb8a4 authored tarafından Caolán McNamara's avatar Caolán McNamara

extract Scan Preview code into a preview widget

instead of scribbling over the parent dialog directly. Doing is this way allows
the .ui-ification to work right.

Change-Id: Ia0c33eae4cd5a4c94896436fe5a5afad8d60a577
üst f188c982
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _SVT_SANEDLG_HRC
#define _SVT_SANEDLG_HRC
#define SCAN_AREA_TOP 17
#define SCAN_AREA_LEFT 8
#define PREVIEW_UPPER_LEFT SCAN_AREA_LEFT
#define PREVIEW_UPPER_TOP SCAN_AREA_TOP + 80
#define PREVIEW_WIDTH 113
#define PREVIEW_HEIGHT 160
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -30,24 +30,13 @@
#include <sane.hxx>
class ScanPreview;
class SaneDlg : public ModalDialog
{
private:
enum DragDirection { TopLeft, Top, TopRight, Right, BottomRight, Bottom,
BottomLeft, Left };
Sane& mrSane;
Bitmap maPreviewBitmap;
Rectangle maPreviewRect;
Point maTopLeft, maBottomRight;
Point maMinTopLeft, maMaxBottomRight;
bool mbDragEnable;
bool mbIsDragging;
bool mbScanEnabled;
bool mbDragDrawn;
DragDirection meDragDirection;
MapMode maMapMode;
Link maOldLink;
......@@ -82,7 +71,7 @@ private:
SvTreeListBox* mpOptionBox;
Window* mpPreview;
ScanPreview* mpPreview;
int mnCurrentOption;
int mnCurrentElement;
......@@ -111,24 +100,14 @@ private:
void EstablishNumericOption();
void EstablishButtonOption();
void DrawRectangles( Point&, Point& );
void DrawDrag();
Point GetPixelPos( const Point& );
Point GetLogicPos( const Point& );
void UpdateScanArea( bool );
// helper
bool SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
public:
SaneDlg( Window*, Sane&, bool );
virtual ~SaneDlg();
virtual short Execute() SAL_OVERRIDE;
void UpdateScanArea( bool );
bool getDoScan() { return doScan;}
};
......
......@@ -190,9 +190,11 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkDrawingArea" id="preview">
<object class="scnlo-ScanPreview" id="preview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
......
......@@ -248,6 +248,10 @@
</properties>
</glade-widget-class>
<glade-widget-class title="Scan Preview" name="scnlo-ScanPreview"
generic-name="Scan Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Token Window" name="swuilo-SwTokenWindow"
generic-name="Token Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment