1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Qwt User's Guide: qwt_event_pattern.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>qwt_event_pattern.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009
00010 <span class="preprocessor">#include <qevent.h></span>
00011 <span class="preprocessor">#include "qwt_event_pattern.h"</span>
00012
<a name="l00019"></a><a class="code" href="class_qwt_event_pattern.html#a0">00019</a> <a class="code" href="class_qwt_event_pattern.html#a0">QwtEventPattern::QwtEventPattern</a>():
00020 d_mousePattern(MousePatternCount),
00021 d_keyPattern(KeyPatternCount)
00022 {
00023 <a class="code" href="class_qwt_event_pattern.html#a3">initKeyPattern</a>();
00024 <a class="code" href="class_qwt_event_pattern.html#a2">initMousePattern</a>(3);
00025 }
00026
<a name="l00028"></a><a class="code" href="class_qwt_event_pattern.html#a1">00028</a> <a class="code" href="class_qwt_event_pattern.html#a1">QwtEventPattern::~QwtEventPattern</a>()
00029 {
00030 }
00031
<a name="l00038"></a><a class="code" href="class_qwt_event_pattern.html#a2">00038</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a2">QwtEventPattern::initMousePattern</a>(<span class="keywordtype">int</span> numButtons)
00039 {
00040 d_mousePattern.resize(MousePatternCount);
00041
00042 <span class="keywordflow">switch</span>(numButtons)
00043 {
00044 <span class="keywordflow">case</span> 1:
00045 {
00046 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect1, Qt::LeftButton);
00047 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect2, Qt::LeftButton, Qt::ControlButton);
00048 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect3, Qt::LeftButton, Qt::AltButton);
00049 <span class="keywordflow">break</span>;
00050 }
00051 <span class="keywordflow">case</span> 2:
00052 {
00053 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect1, Qt::LeftButton);
00054 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect2, Qt::RightButton);
00055 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect3, Qt::LeftButton, Qt::AltButton);
00056 <span class="keywordflow">break</span>;
00057 }
00058 <span class="keywordflow">default</span>:
00059 {
00060 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect1, Qt::LeftButton);
00061 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect2, Qt::RightButton);
00062 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect3, Qt::MidButton);
00063 }
00064 }
00065 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < 3; i++ )
00066 {
00067 <a class="code" href="class_qwt_event_pattern.html#a4">setMousePattern</a>(MouseSelect4 + i,
00068 d_mousePattern[MouseSelect1 + i].button,
00069 d_mousePattern[MouseSelect1 + i].state | Qt::ShiftButton);
00070 }
00071 }
00072
<a name="l00078"></a><a class="code" href="class_qwt_event_pattern.html#a3">00078</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a3">QwtEventPattern::initKeyPattern</a>()
00079 {
00080 d_keyPattern.resize(KeyPatternCount);
00081
00082 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeySelect1, Qt::Key_Return);
00083 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeySelect2, Qt::Key_Space);
00084 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyAbort, Qt::Key_Escape);
00085
00086 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyLeft, Qt::Key_Left);
00087 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyRight, Qt::Key_Right);
00088 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyUp, Qt::Key_Up);
00089 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyDown, Qt::Key_Down);
00090
00091 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyRedo, Qt::Key_Plus);
00092 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyUndo, Qt::Key_Minus);
00093 <a class="code" href="class_qwt_event_pattern.html#a5">setKeyPattern</a>(KeyHome, Qt::Key_Escape);
00094 }
00095
<a name="l00105"></a><a class="code" href="class_qwt_event_pattern.html#a4">00105</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a4">QwtEventPattern::setMousePattern</a>(uint pattern, <span class="keywordtype">int</span> button, <span class="keywordtype">int</span> state)
00106 {
00107 <span class="keywordflow">if</span> ( pattern < d_mousePattern.count() )
00108 {
00109 d_mousePattern[int(pattern)].button = button;
00110 d_mousePattern[int(pattern)].state = state;
00111 }
00112 }
00113
<a name="l00123"></a><a class="code" href="class_qwt_event_pattern.html#a5">00123</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a5">QwtEventPattern::setKeyPattern</a>(uint pattern, <span class="keywordtype">int</span> key, <span class="keywordtype">int</span> state)
00124 {
00125 <span class="keywordflow">if</span> ( pattern < d_keyPattern.count() )
00126 {
00127 d_keyPattern[int(pattern)].key = key;
00128 d_keyPattern[int(pattern)].state = state;
00129 }
00130 }
00131
<a name="l00133"></a><a class="code" href="class_qwt_event_pattern.html#a6">00133</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a4">QwtEventPattern::setMousePattern</a>(<span class="keyword">const</span> QwtArray<MousePattern> &pattern)
00134 {
00135 d_mousePattern = pattern;
00136 }
00137
<a name="l00139"></a><a class="code" href="class_qwt_event_pattern.html#a7">00139</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_event_pattern.html#a5">QwtEventPattern::setKeyPattern</a>(<span class="keyword">const</span> QwtArray<KeyPattern> &pattern)
00140 {
00141 d_keyPattern = pattern;
00142 }
00143
00145 <span class="keyword">const</span> QwtArray<QwtEventPattern::MousePattern> &
<a name="l00146"></a><a class="code" href="class_qwt_event_pattern.html#a8">00146</a> <a class="code" href="class_qwt_event_pattern.html#a8">QwtEventPattern::mousePattern</a>()<span class="keyword"> const</span>
00147 <span class="keyword"></span>{
00148 <span class="keywordflow">return</span> d_mousePattern;
00149 }
00150
00152 <span class="keyword">const</span> QwtArray<QwtEventPattern::KeyPattern> &
<a name="l00153"></a><a class="code" href="class_qwt_event_pattern.html#a9">00153</a> <a class="code" href="class_qwt_event_pattern.html#a9">QwtEventPattern::keyPattern</a>()<span class="keyword"> const</span>
00154 <span class="keyword"></span>{
00155 <span class="keywordflow">return</span> d_keyPattern;
00156 }
00157
<a name="l00159"></a><a class="code" href="class_qwt_event_pattern.html#a10">00159</a> QwtArray<QwtEventPattern::MousePattern> &<a class="code" href="class_qwt_event_pattern.html#a8">QwtEventPattern::mousePattern</a>()
00160 {
00161 <span class="keywordflow">return</span> d_mousePattern;
00162 }
00163
<a name="l00165"></a><a class="code" href="class_qwt_event_pattern.html#a11">00165</a> QwtArray<QwtEventPattern::KeyPattern> &<a class="code" href="class_qwt_event_pattern.html#a9">QwtEventPattern::keyPattern</a>()
00166 {
00167 <span class="keywordflow">return</span> d_keyPattern;
00168 }
00169
<a name="l00183"></a><a class="code" href="class_qwt_event_pattern.html#a12">00183</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_event_pattern.html#a12">QwtEventPattern::mouseMatch</a>(uint pattern, <span class="keyword">const</span> QMouseEvent *e)<span class="keyword"> const</span>
00184 <span class="keyword"></span>{
00185 <span class="keywordtype">bool</span> ok = FALSE;
00186
00187 <span class="keywordflow">if</span> ( e && pattern < d_mousePattern.count() )
00188 ok = <a class="code" href="class_qwt_event_pattern.html#a12">mouseMatch</a>(d_mousePattern[<span class="keywordtype">int</span>(pattern)], e);
00189
00190 <span class="keywordflow">return</span> ok;
00191 }
00192
<a name="l00207"></a><a class="code" href="class_qwt_event_pattern.html#b0">00207</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_event_pattern.html#a12">QwtEventPattern::mouseMatch</a>(<span class="keyword">const</span> MousePattern &pattern,
00208 <span class="keyword">const</span> QMouseEvent *e)<span class="keyword"> const</span>
00209 <span class="keyword"></span>{
00210 <span class="keywordflow">return</span> (e->button() == pattern.button) &&
00211 ((e->state() & Qt::KeyButtonMask) == (pattern.state & Qt::KeyButtonMask));
00212 }
00213
<a name="l00227"></a><a class="code" href="class_qwt_event_pattern.html#a13">00227</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_event_pattern.html#a13">QwtEventPattern::keyMatch</a>(uint pattern, <span class="keyword">const</span> QKeyEvent *e)<span class="keyword"> const</span>
00228 <span class="keyword"></span>{
00229 <span class="keywordtype">bool</span> ok = FALSE;
00230
00231 <span class="keywordflow">if</span> ( e && pattern < d_keyPattern.count() )
00232 ok = <a class="code" href="class_qwt_event_pattern.html#a13">keyMatch</a>(d_keyPattern[<span class="keywordtype">int</span>(pattern)], e);
00233
00234 <span class="keywordflow">return</span> ok;
00235 }
00236
<a name="l00251"></a><a class="code" href="class_qwt_event_pattern.html#b1">00251</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_event_pattern.html#a13">QwtEventPattern::keyMatch</a>(
00252 <span class="keyword">const</span> KeyPattern &pattern, <span class="keyword">const</span> QKeyEvent *e)<span class="keyword"> const</span>
00253 <span class="keyword"></span>{
00254 <span class="keywordflow">return</span> (e->key() == pattern.key) &&
00255 ((e->state() & Qt::KeyButtonMask) == (pattern.state & Qt::KeyButtonMask));
00256 }
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:20 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|