⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fg__x11adaptor_8cpp-source.html

📁 《道法自然》书的源码FishGUI,一个跨平台的界面库
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00138 }00139 00140 <span class="comment">//##ModelId=40925CB001FE</span><a name="l00141"></a><a class="code" href="classFG__X11Adaptor.html#a3">00141</a> <span class="keywordtype">void</span> <a class="code" href="classFG__X11Adaptor.html#a3">FG_X11Adaptor::SetXpmPath</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * pPath)00142 {00143     <span class="keywordtype">char</span> * env = getenv(<span class="stringliteral">"HOME_FISHGUI"</span>);00144     <span class="keywordflow">if</span> (env)00145     {00146         strcpy(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, env);00147         <span class="keywordflow">if</span> (<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>[strlen(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>) - 1] == <span class="charliteral">'/'</span>)00148             <a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>[strlen(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>) - 1] = 0;00149     }00150     <span class="keywordflow">else</span>00151     {00152         <span class="keywordflow">if</span> (pPath[0] == <span class="charliteral">'/'</span>)00153         {00154             strcpy(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, pPath);00155         }00156         <span class="keywordflow">else</span>00157         {00158             getcwd(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, MAXPATHLEN);00159             strcat(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, <span class="stringliteral">"/"</span>);00160             strcat(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, pPath);00161         }00162     00163         <span class="keywordtype">char</span> * pFishGUI = strstr(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, <span class="stringliteral">"FishGUI"</span>);00164         <span class="keywordflow">if</span> (! pFishGUI)00165         {00166             printf(<span class="stringliteral">"找不到位图目录'FishGUI/X11_Xpm'\n"</span>);00167             exit(0);00168         }00169         <span class="keywordtype">char</span> * pEnd = strstr(pFishGUI, <span class="stringliteral">"/"</span>);00170         <span class="keywordflow">if</span> (! pEnd)00171         {00172             printf(<span class="stringliteral">"找不到位图目录'FishGUI/X11_Xpm'\n"</span>);00173             exit(0);00174         }00175         * pEnd = 0;00176     }00177     strcat(<a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, <span class="stringliteral">"/X11_Xpm"</span>);00178 }00179     00180 <span class="comment">//##ModelId=40925CB00226</span><a name="l00181"></a><a class="code" href="classFG__X11Adaptor.html#a4">00181</a> <span class="keywordtype">void</span> <a class="code" href="classFG__X11Adaptor.html#a4">FG_X11Adaptor::DrawBitmap</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * pBmpName, <span class="keyword">const</span> <span class="keywordtype">short</span> x1, <span class="keyword">const</span> <span class="keywordtype">short</span> y1)00182 {00183     <span class="keywordtype">char</span> name[MAXPATHLEN + 1];00184     sprintf(name, <span class="stringliteral">"%s/%s.xpm"</span>, <a class="code" href="classFG__X11Adaptor.html#r3">XpmPath</a>, pBmpName);00185     00186     m_pDraw-&gt;<a class="code" href="classFG__OSDrawInterface.html#a9">DrawBitmap</a>(name, x1, y1);00187 }00188     00189 <span class="comment">//##ModelId=3F6EB0010005</span><a name="l00190"></a><a class="code" href="classFG__X11Adaptor.html#d0">00190</a> <span class="keywordtype">void</span> <a class="code" href="classFG__X11Adaptor.html#d0">FG_X11Adaptor::process_event</a>(XEvent report)00191 {00192         <span class="keywordflow">switch</span>(report.type)00193         {00194             <span class="keywordflow">case</span> Expose:00195                 {00196                 <a class="code" href="structFG__Message.html">FG_Message</a> Msg(<a class="code" href="group__Utility.html#gga12a19">FG_MSG_DRAW</a>);00197                 <a class="code" href="group__OSAdaptor.html#ga1">FG_GetAdaptor</a>()-&gt;<a class="code" href="classFG__OSAdaptor.html#a2">SendMsg</a>(&amp; Msg);00198             }00199                 <span class="keywordflow">break</span>;00200                 <span class="keywordflow">case</span> KeyPress:00201                     {00202                 KeySym key = XLookupKeysym(&amp; report.xkey, 0);00203                 <a class="code" href="structFG__Message.html">FG_Message</a> Msg(<a class="code" href="group__Utility.html#gga12a20">FG_MSG_KEY</a>, <a class="code" href="group__Utility.html#gga13a29">FKS_DOWN</a>);00204                 <span class="keywordflow">if</span> (key &gt;= <span class="charliteral">'0'</span> &amp;&amp; key &lt;= <span class="charliteral">'9'</span>)00205                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = key;00206                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key &gt;= <span class="charliteral">'a'</span> &amp;&amp; key &lt;= <span class="charliteral">'z'</span>)00207                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = key - <span class="charliteral">'a'</span> + <span class="charliteral">'A'</span>;00208                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Return)00209                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga12">FVK_ENTER</a>;00210                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Left)00211                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga14">FVK_LEFT</a>;00212                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Right)00213                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga15">FVK_RIGHT</a>;00214                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Delete)00215                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga13">FVK_DELETE</a>;00216                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Tab)00217                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga16">FVK_TAB</a>;00218                 <a class="code" href="group__OSAdaptor.html#ga1">FG_GetAdaptor</a>()-&gt;<a class="code" href="classFG__OSAdaptor.html#a2">SendMsg</a>(&amp; Msg);00219             }00220                         <span class="keywordflow">break</span>;00221 00222                 <span class="keywordflow">case</span> KeyRelease:00223                     {00224                         KeySym key = XLookupKeysym(&amp; report.xkey, 0);00225                 <a class="code" href="structFG__Message.html">FG_Message</a> Msg(<a class="code" href="group__Utility.html#gga12a20">FG_MSG_KEY</a>, <a class="code" href="group__Utility.html#gga13a30">FKS_UP</a>);00226                 <span class="keywordflow">if</span> (key &gt;= <span class="charliteral">'0'</span> &amp;&amp; key &lt;= <span class="charliteral">'9'</span>)00227                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = key;00228                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key &gt;= <span class="charliteral">'a'</span> &amp;&amp; key &lt;= <span class="charliteral">'z'</span>)00229                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = key - <span class="charliteral">'a'</span> + <span class="charliteral">'A'</span>;00230                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Return)00231                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga12">FVK_ENTER</a>;00232                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Left)00233                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga14">FVK_LEFT</a>;00234                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Right)00235                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga15">FVK_RIGHT</a>;00236                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Delete)00237                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga13">FVK_DELETE</a>;00238                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == XK_Tab)00239                     Msg.<a class="code" href="structFG__Message.html#o4">lData</a> = <a class="code" href="group__Virtual__Key.html#ga16">FVK_TAB</a>;00240                 <a class="code" href="group__OSAdaptor.html#ga1">FG_GetAdaptor</a>()-&gt;<a class="code" href="classFG__OSAdaptor.html#a2">SendMsg</a>(&amp; Msg);00241             }00242                         <span class="keywordflow">break</span>;00243 00244                 <span class="keywordflow">case</span> ButtonPress:00245                         <span class="keywordflow">if</span> (report.xbutton.button == 1)00246                         {00247                 <a class="code" href="structFG__Message.html">FG_Message</a> Msg(<a class="code" href="group__Utility.html#gga12a21">FG_MSG_MOUSE</a>, <a class="code" href="group__Utility.html#gga14a32">FMS_LBUTTONDOWN</a>);00248                 Msg.<a class="code" href="structFG__Message.html#o5">Point</a>.<a class="code" href="structFG__Point.html#o0">x</a> = (<a class="code" href="group__Utility.html#ga1">WORD</a>)report.xbutton.x;00249                 Msg.<a class="code" href="structFG__Message.html#o5">Point</a>.<a class="code" href="structFG__Point.html#o1">y</a> = (<a class="code" href="group__Utility.html#ga1">WORD</a>)report.xbutton.y;00250                 <a class="code" href="group__OSAdaptor.html#ga1">FG_GetAdaptor</a>()-&gt;<a class="code" href="classFG__OSAdaptor.html#a2">SendMsg</a>(&amp; Msg);00251                         }00252                         <span class="keywordflow">break</span>;00253 00254                 <span class="keywordflow">case</span> ButtonRelease:00255                         <span class="keywordflow">if</span> (report.xbutton.button == 1)00256                         {00257                 <a class="code" href="structFG__Message.html">FG_Message</a> Msg(<a class="code" href="group__Utility.html#gga12a21">FG_MSG_MOUSE</a>, <a class="code" href="group__Utility.html#gga14a33">FMS_LBUTTONUP</a>);00258                 Msg.<a class="code" href="structFG__Message.html#o5">Point</a>.<a class="code" href="structFG__Point.html#o0">x</a> = (<a class="code" href="group__Utility.html#ga1">WORD</a>)report.xbutton.x;00259                 Msg.<a class="code" href="structFG__Message.html#o5">Point</a>.<a class="code" href="structFG__Point.html#o1">y</a> = (<a class="code" href="group__Utility.html#ga1">WORD</a>)report.xbutton.y;00260                 <a class="code" href="group__OSAdaptor.html#ga1">FG_GetAdaptor</a>()-&gt;<a class="code" href="classFG__OSAdaptor.html#a2">SendMsg</a>(&amp; Msg);00261                         }00262                         <span class="keywordflow">break</span>;00263 00264                 <span class="keywordflow">default</span>:00265                         <span class="keywordflow">break</span>;00266         }00267 }00268 </pre></div><hr><center>由 DoxyGen 1.3.6 于 Wed Jun 9 22:34:41 2004 生成<br>版权所有 (C) 2003,2004 王咏武</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -