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

📄 q_application.html

📁 QCurses使用手册 QCurses使用手册
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>欢迎光临 QCurses 函数库主页</title>
<link href="css/qcurses.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
	font-family: 宋体;
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style7 {font-family: "黑体"}
.style9 {color: #FFFFFF}
.style10 {color: #000000}
.style11 {color: #FF0000}
-->
</style></head>

<body>
<table width="100%" height="0"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="25" bgcolor="EFEFEF">■ <span class="style10">Q_Application</span> 程序类</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>      
      <table width="600" border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
          <td valign="top" bgcolor="EFEFEF">     <p>功能介绍:</p>
          <p>程序类定义,以后所有的程序都从这个类派生,使得编辑出的程序简单明了。</p></td>
        </tr>
    </table>      
      <br>
      <table width="600" border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
          <td valign="top" bgcolor="EFEFEF"><p>函数、变量:</p>
            <table width="90%"  border="0" align="center" cellpadding="5" cellspacing="1">
              <tr bgcolor="#333333">
                <td width="69%"><div align="center" class="style9">函数、变量声明</div></td>
                <td width="31%"><div align="center" class="style9">功能,含义</div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td valign="top"><p class="style10">Q_Application(char *appname)</p>
                <p class="style10">参数:程序名称</p>
                </td>
                <td><div align="center"><span class="style10">构造函数</span></div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td><p class="style10">int POPWin(char *str,char *cap)</p>
                <p class="style10">参数:<br>
                  显示的字符串,弹出窗口标题</p></td>
                <td><div align="center">弹出一个确认窗口</div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td><p>void KeyGo(int &amp;NowSelect, int &amp;Keys, int MaxActive)</p>
                <p>参数:<br>
                  当前的控件选择
, 控件的返回值,最大移动控件数</p>
                <p class="style11">说明:<br>
                这个函数很重要,以后要想控制在每隔控件之间来回移动,就需要这个函数进行控制,举起可以参看下面的例子。</p></td>
                <td><div align="center">控制控件之间的切换</div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td>char *AppName()</td>
                <td><div align="center">返回当前程序名</div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td>virtual bool Run()</td>
                <td><div align="center"><span class="style10">虚拟程序运行函数</span></div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td>virtual void End()</td>
                <td><div align="center">虚拟程序结束函数<br>
                  程序执行完毕后<br>
                  必须执行这个函数
                </div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td><p class="style10">void GetKey()</p>
                </td>
                <td><div align="center"><span class="style10">在窗口取值放入NowKey</span></div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td><span class="style10">char *_AppName</span></td>
                <td><div align="center"><span class="style10">当前程序名称</span></div></td>
              </tr>
              <tr bgcolor="#CCCCCC">
                <td><p class="style10">long get_file_size(char *filename)</p>
                <p class="style10">参数:要得知大小的文件名</p></td>
                <td><div align="center"><span class="style10">获得一个文件的大小</span></div></td>
              </tr>              <tr bgcolor="#CCCCCC">
                <td><p class="style10">bool RunCommand(char *Command,...)</p>
                <p class="style10">参数:执行命令的字符串,比如 RunCommand(&quot;ls &gt;P&quot;)</p></td>
                <td><div align="center"><span class="style10">执行一个命令</span></div></td>
              </tr>              <tr bgcolor="#CCCCCC">
                <td><span class="style10"></span></td>
                <td><div align="center"><span class="style10"></span></div></td>
              </tr>              <tr bgcolor="#CCCCCC">
                <td><span class="style10"></span></td>
                <td><div align="center"><span class="style10"></span></div></td>
              </tr>
            </table>            
            <p>&nbsp;              </p>
          </td>
        </tr>
      </table>      
      <br>
      <table width="600" border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
          <td valign="top" bgcolor="EFEFEF"><p>演示例子:</p>
            <p>#include &quot;qcurses.hpp&quot;</p>
            <p>class _MyApp :public Q_Application<br>
{<br>
  public:<br>
    _MyApp():Q_Application(&quot;Test Program &quot;){ }<br>
    bool Run();<br>
};<br>
//---------------------------------------------------------------------------------<br>
bool _MyApp::Run()<br>
{<br>
  int BreakKey = 0; //循环断点<br>
  int NowSelect=0; //当前选择的控件<br>
  int Keys=0; //当前键值<br>
  WINDOW *WINDOW = newwin(24,80,0,0);<br>
  Q_Window *Form1 = new Q_Window(WINDOW,24,80,0,0,true,COLOR_WHITE,COLOR_BLUE);<br>
  Form1-&gt;SetCaption(&quot;New Qcurses Test &quot;,COLOR_MAGENTA,COLOR_WHITE);<br>
  Form1-&gt;xBorder(2);<br>
  Form1-&gt;xBorder(4);</p>
            <p>   //声明一个列表项<br>
    Q_Items ItemList;<br>
    ItemList.push_back(&quot;I't dog &quot;);<br>
    ItemList.push_back(&quot;I't cat &quot;);<br>
    ItemList.push_back(&quot;I't pig &quot;);<br>
    ItemList.push_back(&quot;I't man &quot;);<br>
    ItemList.push_back(&quot;I't woman &quot;);</p>
            <p>  Q_Label *Label1 = new Q_Label(Form1-&gt;GetHandle(),20,5,30,COLOR_WHITE,COLOR_BLACK);<br>
    Q_Edit *Edit1 = new Q_Edit(Form1-&gt;GetHandle(),15,5,4,COLOR_BLACK,COLOR_CYAN,4);<br>
    Q_List *List1 = new Q_List(Form1-&gt;GetHandle(),6,30,7,4,true,COLOR_BLACK,COLOR_CYAN);</p>
            <p>   List1-&gt;Add(&quot;welcome111&quot;);<br>
    List1-&gt;Add(&quot;welcome222&quot;);<br>
    List1-&gt;Add(&quot;welcome333&quot;);<br>
    List1-&gt;Add(&quot;welcome444&quot;);<br>
    List1-&gt;Add(&quot;welcome555&quot;);<br>
    List1-&gt;Add(&quot;welcome666&quot;);<br>
    List1-&gt;Add(&quot;welcome777&quot;);</p>
            <p>  Q_RadioGroup *RadioGroup = new Q_RadioGroup(Form1-&gt;GetHandle(),7,30,15,2,COLOR_BLACK,COLOR_CYAN,ItemList,false);<br>
    RadioGroup-&gt;SetCaption(&quot;Your Selection &quot;,COLOR_BLACK,COLOR_CYAN);</p>
            <p>   while (BreakKey==0)<br>
    {<br>
      KeyGo(NowSelect,Keys,2); //其中 2 为case的最后一个值<br>
      switch (NowSelect)<br>
      {<br>
       case 0:<br>
        Keys=RadioGroup-&gt;Get();<br>
        break;<br>
  <br>
       case 1:<br>
        Keys=List1-&gt;Get();<br>
        break;<br>
  <br>
       case 2:<br>
        Edit1-&gt;Set(List1-&gt;GetValue());<br>
        Keys=Edit1-&gt;Get();<br>
        if(strcmp(Edit1-&gt;ReturnValue(),&quot;quit&quot;)==0)<br>
           BreakKey=1;<br>
        Label1-&gt;Set(4,&quot;%s&quot;,Edit1-&gt;ReturnValue());<br>
        break;<br>
      }<br>
    }<br>
    delete RadioGroup;<br>
    delete List1; <br>
    delete Edit1;<br>
    delete Label1;<br>
    delete Form1; <br>
    delwin(WINDOW);<br>
    return true; <br>
  }<br>
  //---------------------------------------------------------------------------------<br>              
  int main()<br>
              {<br>
                _MyApp *App = new _MyApp();<br>
                App-&gt;Run();<br>
                App-&gt;End();<br>
                delete App;<br>
                return 0;<br>
              }<br>
              <br>
            </p>
            <p> 说明:</p>
            <p>编译 g++ ./libqcurses.so main.cpp -o ctest -lcurses</p>
            <p>此例子将实现以下效果:运行后,在EDIT控件中输入 quit 退出程序</p>
            <p align="center"><img src="images/qapp/1.jpg" width="460" height="425"><br>
              <br>
            </p></td>
        </tr>
      </table>
      </td>
  </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

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