aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/fltkpreview.cc7
-rw-r--r--dw/fltkpreview.hh1
-rw-r--r--dw/fltkviewport.cc84
-rw-r--r--dw/fltkviewport.hh1
-rw-r--r--dw/layout.cc10
-rw-r--r--dw/layout.hh1
-rw-r--r--dw/types.hh2
-rw-r--r--dw/view.hh5
8 files changed, 56 insertions, 55 deletions
diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc
index 79269bd5..7096420f 100644
--- a/dw/fltkpreview.cc
+++ b/dw/fltkpreview.cc
@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#include "../lout/msg.h"
#include "fltkpreview.hh"
#include "fltkmisc.hh"
@@ -103,6 +103,11 @@ void FltkPreview::scrollTo (int x, int y)
scrollY = y;
}
+void FltkPreview::scroll (dw::core::ScrollCommand cmd)
+{
+ MSG_ERR("FltkPreview::scroll not implemented\n");
+}
+
void FltkPreview::setViewportSize (int width, int height,
int hScrollbarThickness,
int vScrollbarThickness)
diff --git a/dw/fltkpreview.hh b/dw/fltkpreview.hh
index 2464db89..13db2811 100644
--- a/dw/fltkpreview.hh
+++ b/dw/fltkpreview.hh
@@ -34,6 +34,7 @@ public:
int getHScrollbarThickness ();
int getVScrollbarThickness ();
void scrollTo (int x, int y);
+ void scroll (dw::core::ScrollCommand cmd);
void setViewportSize (int width, int height,
int hScrollbarThickness, int vScrollbarThickness);
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc
index db784c09..8dc5b2a2 100644
--- a/dw/fltkviewport.cc
+++ b/dw/fltkviewport.cc
@@ -225,6 +225,15 @@ int FltkViewport::handle (int event)
}
switch(event) {
+ case ::fltk::KEY:
+ /* Tell fltk we want to receive KEY events as SHORTCUTs.
+ * As we don't know the exact keybindings set by the user, we ask
+ * for all of them (except TabKey to keep navigation between form
+ * widgets). */
+ if (::fltk::event_key() != TabKey)
+ return 0;
+ break;
+
case ::fltk::FOCUS:
/** \bug Draw focus box. */
return 1;
@@ -279,60 +288,6 @@ int FltkViewport::handle (int event)
case ::fltk::LEAVE:
mouse_x = mouse_y = -1;
break;
-
- case ::fltk::KEY:
- /* tell fltk we want to receive these KEY events as SHORTCUT */
- switch (::fltk::event_key()) {
- case PageUpKey:
- case PageDownKey:
- case SpaceKey:
- case DownKey:
- case UpKey:
- case RightKey:
- case LeftKey:
- case HomeKey:
- case EndKey:
- return 0;
- }
- break;
-
- case ::fltk::SHORTCUT:
- switch (::fltk::event_key()) {
- case PageUpKey:
- case 'b':
- case 'B':
- scroll (0, -vscrollbar->pagesize ());
- return 1;
-
- case PageDownKey:
- case SpaceKey:
- scroll (0, vscrollbar->pagesize ());
- return 1;
-
- case DownKey:
- scroll (0, (int) vscrollbar->linesize ());
- return 1;
-
- case UpKey:
- scroll (0, (int) -vscrollbar->linesize ());
- return 1;
-
- case RightKey:
- scroll ((int) hscrollbar->linesize (), 0);
- return 1;
-
- case LeftKey:
- scroll ((int) -hscrollbar->linesize (), 0);
- return 1;
-
- case HomeKey:
- scrollTo (scrollX, 0);
- return 1;
-
- case EndKey:
- scrollTo (scrollX, canvasHeight); /* gets adjusted in scrollTo () */
- return 1;
- }
}
return FltkWidgetView::handle (event);
@@ -419,6 +374,27 @@ void FltkViewport::scroll (int dx, int dy)
scrollTo (scrollX + dx, scrollY + dy);
}
+void FltkViewport::scroll (core::ScrollCommand cmd)
+{
+ if (cmd == core::SCREEN_UP_CMD) {
+ scroll (0, -vscrollbar->pagesize ());
+ } else if (cmd == core::SCREEN_DOWN_CMD) {
+ scroll (0, vscrollbar->pagesize ());
+ } else if (cmd == core::LINE_UP_CMD) {
+ scroll (0, (int) -vscrollbar->linesize ());
+ } else if (cmd == core::LINE_DOWN_CMD) {
+ scroll (0, (int) vscrollbar->linesize ());
+ } else if (cmd == core::LEFT_CMD) {
+ scroll ((int) -hscrollbar->linesize (), 0);
+ } else if (cmd == core::RIGHT_CMD) {
+ scroll ((int) hscrollbar->linesize (), 0);
+ } else if (cmd == core::TOP_CMD) {
+ scrollTo (scrollX, 0);
+ } else if (cmd == core::BOTTOM_CMD) {
+ scrollTo (scrollX, canvasHeight); /* gets adjusted in scrollTo () */
+ }
+}
+
void FltkViewport::setViewportSize (int width, int height,
int hScrollbarThickness,
int vScrollbarThickness)
diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh
index 0e53c5be..38f9310d 100644
--- a/dw/fltkviewport.hh
+++ b/dw/fltkviewport.hh
@@ -60,6 +60,7 @@ public:
int getHScrollbarThickness ();
int getVScrollbarThickness ();
void scroll(int dx, int dy);
+ void scroll(dw::core::ScrollCommand cmd);
void scrollTo (int x, int y);
void setViewportSize (int width, int height,
int hScrollbarThickness, int vScrollbarThickness);
diff --git a/dw/layout.cc b/dw/layout.cc
index 27b155e3..2d350a05 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -248,6 +248,16 @@ void Layout::detachView (View *view)
*/
}
+void Layout::scroll(ScrollCommand cmd)
+{
+ for (typed::Iterator <View> it = views->iterator (); it.hasNext (); ) {
+ View *view = it.getNext ();
+
+ if (view->usesViewport ())
+ view->scroll(cmd);
+ }
+}
+
/**
* \brief Scrolls all viewports, so that the region [x, y, width, height]
* is seen, according to hpos and vpos.
diff --git a/dw/layout.hh b/dw/layout.hh
index 29e6ba56..b9ba46e5 100644
--- a/dw/layout.hh
+++ b/dw/layout.hh
@@ -159,6 +159,7 @@ public:
void scrollTo (HPosition hpos, VPosition vpos,
int x, int y, int width, int height);
+ void scroll (ScrollCommand);
void setAnchor (const char *anchor);
/* View */
diff --git a/dw/types.hh b/dw/types.hh
index 4687c7fc..4ebe9490 100644
--- a/dw/types.hh
+++ b/dw/types.hh
@@ -30,6 +30,8 @@ enum VPosition
VPOS_NO_CHANGE
};
+enum ScrollCommand {SCREEN_UP_CMD, SCREEN_DOWN_CMD, LINE_UP_CMD, LINE_DOWN_CMD,
+ LEFT_CMD, RIGHT_CMD, TOP_CMD, BOTTOM_CMD};
/*
* Different "layers" may be highlighted in a widget.
diff --git a/dw/view.hh b/dw/view.hh
index cd88b790..876c7fe3 100644
--- a/dw/view.hh
+++ b/dw/view.hh
@@ -80,6 +80,11 @@ public:
virtual void scrollTo (int x, int y) = 0;
/**
+ * \brief Scroll the viewport as commanded.
+ */
+ virtual void scroll (ScrollCommand) { };
+
+ /**
* \brief Set the viewport size.
*
* Does not have to be implemented, when usesViewport returns false.