?? q_application.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> </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 &NowSelect, int &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("ls >P")</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> </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 "qcurses.hpp"</p>
<p>class _MyApp :public Q_Application<br>
{<br>
public:<br>
_MyApp():Q_Application("Test Program "){ }<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->SetCaption("New Qcurses Test ",COLOR_MAGENTA,COLOR_WHITE);<br>
Form1->xBorder(2);<br>
Form1->xBorder(4);</p>
<p> //聲明一個列表項<br>
Q_Items ItemList;<br>
ItemList.push_back("I't dog ");<br>
ItemList.push_back("I't cat ");<br>
ItemList.push_back("I't pig ");<br>
ItemList.push_back("I't man ");<br>
ItemList.push_back("I't woman ");</p>
<p> Q_Label *Label1 = new Q_Label(Form1->GetHandle(),20,5,30,COLOR_WHITE,COLOR_BLACK);<br>
Q_Edit *Edit1 = new Q_Edit(Form1->GetHandle(),15,5,4,COLOR_BLACK,COLOR_CYAN,4);<br>
Q_List *List1 = new Q_List(Form1->GetHandle(),6,30,7,4,true,COLOR_BLACK,COLOR_CYAN);</p>
<p> List1->Add("welcome111");<br>
List1->Add("welcome222");<br>
List1->Add("welcome333");<br>
List1->Add("welcome444");<br>
List1->Add("welcome555");<br>
List1->Add("welcome666");<br>
List1->Add("welcome777");</p>
<p> Q_RadioGroup *RadioGroup = new Q_RadioGroup(Form1->GetHandle(),7,30,15,2,COLOR_BLACK,COLOR_CYAN,ItemList,false);<br>
RadioGroup->SetCaption("Your Selection ",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->Get();<br>
break;<br>
<br>
case 1:<br>
Keys=List1->Get();<br>
break;<br>
<br>
case 2:<br>
Edit1->Set(List1->GetValue());<br>
Keys=Edit1->Get();<br>
if(strcmp(Edit1->ReturnValue(),"quit")==0)<br>
BreakKey=1;<br>
Label1->Set(4,"%s",Edit1->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->Run();<br>
App->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 + -