锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / C++开源英语 / 具有各种UI组件的类似DevStudio的应用程序
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

具有各种UI组件的类似DevStudio的应用程序

Introduction

In this article, I will present an academic application WinCalcCT I recently developed as a software product of my research. It accepts min-max functions description files (which I will explain shortly) and then computes the cycle time vectors of the min-max functions on request. This application utilizes MFC’s document/view architecture. Since min-max functions description files (*.mmf) are text files, the view class (CWCTView) largely implements what a text editor needs to have. However, like *.cpp files, there is a syntax, albeit much simpler, for *.mmf files, so we need a syntax coloring editor. In addition, we need a place to display the computation results, and that is the output window. Moreover, as we apparently don’t want to freeze the user interface while computing, multithreading is needed. All these features are now implemented in WinCalcCT.在本文中,我将介绍我最近开发的一个学术应用程序WinCalcCT,作为我研究的软件产品。它接受min-max函数描述文件(我将在稍后解释),然后根据请求计算min-max函数的循环时间向量。该应用程序使用MFC的文档/视图架构。由于min-max函数描述文件(* .mmf)是文本文件,因此视图类(CWCTView)主要实现文本编辑器需要具有的内容。但是,与* .cpp文件一样,* .mmf有一种语法,虽然文件简单得多,所以我们需要一个语法着色编辑器。另外,我们需要一个显示计算结果的地方,那就是输出窗口。此外,由于我们显然不希望在计算时冻结用户界面,因此需要多线程。所有这些功能现在都在实现WinCalcCT。

WinCalcCT, with the above features, is quite like a greatly simplified Microsoft Developer Studio, and, with this in mind, I have tried to make the appearance of the UI components in WinCalcCT as DevStudio-like as I can. I fortunately need not do this from scratch since there have been several classes designed by other authors that I can reuse.WinCalcCT具有上述功能,就像一个大大简化的Microsoft Developer Studio,并且考虑到这一点,我试图尽可能地将UI组件的外观WinCalcCT 变成DevStudio。幸运的是,我不需要从头开始这样做,因为我可以重复使用其他作者设计的几个类。

It is my conjecture that many MFC developers will welcome my application because often times they would be assigned similar tasks and my source code could then provide a good starting point.我猜想许多MFC开发人员会欢迎我的应用程序,因为他们经常被分配类似的任务,我的源代码可以提供一个很好的起点。

Background

This application stems from my previous research “On Discrete Event Systems Modelled by Min-Max Functions”. An example of a 2-dimensional min-max function is F[x1,x2]=[min(x1+2,max(x2,x1+4)), max(x1-3,x2)]. A central performance measure of such systems (or functions) is their cycle time vector, or simply cycle time, which indicates their throughput. Mathematically, given a min-max function F, its cycle time exists and is unique. An efficient, and arguably the only realized algorithm was designed by the present author and was published in a scholarly journal (see readme.txt in the source package for details).此应用程序源于我之前的研究“由Min-Max函数建模的离散事件系统”。二维最小 - 最大函数的示例是F [x1,x2] = [min(x1 + 2,max(x2,x1 + 4)),max(x1-3,x2)]。这种系统(或功能)的中心性能测量是它们的循环时间向量,或简单的循环时间,它表示它们的吞吐量。在数学上,给定最小 - 最大函数F,其循环时间存在且是唯一的。一个有效的,可以说是唯一实现的算法是由本作者设计的,并发表在一个学术期刊上(详见源程序包中的readme.txt)。

The Syntax Coloring Editor语法着色编辑器

Aside from syntax coloring, this version of WinCalcCT text editor supports keyboard editing, text scrolling, caret showing, selection processing and showing, clipboard cut/copy/paste, text find, and so on. My next task is to add text replace and edit undo and redo.

Worth a mention is that the class CWCTView is derived from CView instead of CEditView or CRichEditViewas many people would expect. CEditView is not a choice because it does not support syntax coloring, and although CRichEditView does support syntax coloring, I found the text in a CRichEditView quite ugly. In fact, Microsoft Visual Studio itself took the same approach as I did, you can confirm this by using Spy++.

除语法着色外,此版本的WinCalcCT 文本编辑器还支持键盘编辑,文本滚动,插入符号显示,选择处理和显示,剪贴板剪切/复制/粘贴,文本查找等。我的下一个任务是添加文本替换并编辑撤消和重做。

值得一提的是,这个CWCTView类派生自CView, 不是人们所期望的CEditView或CRichEditView 。CEditView 不是一个选择,因为它不支持语法着色,虽然CRichEditView 支持语法着色,但我发现文本CRichEditView 非常难看。实际上,Microsoft Visual Studio本身采用了与我相同的方法,您可以通过使用Spy ++来确认这一点。

It is believed that my implementation of syntax coloring is very unique. Usually, there is an analyzing (or parsing, against the syntax) phase before the rendering of the text. In WinCalcCT, there is no independent analyzing phase and there is even no data structure representing analyzed or parsed text. This is not to say that this is a better approach, but I can at least argue that this simplifies code writing and could be a viable choice if the syntax is line-based instead of block-based, as for most assembly languages and many script languages.据信我的语法着色实现非常独特。通常,在呈现文本之前存在分析(或解析,反对语法)阶段。在WinCalcCT,没有独立的分析阶段,甚至没有表示分析或解析文本的数据结构。这并不是说这是一种更好的方法,但我至少可以说这简化了代码编写,如果语法是基于行的而不是基于块的,那么可能是一个可行的选择,就像大多数汇编语言和许多脚本一样语言。

CWCTView currently does not support displaying a tab character as four or eight spaces and regarding the spaces as a single editing unit. This is because in our context the feature is not needed. It may involve a fair amount of work to add this feature.CWCTView 目前不支持将制表符显示为四个或八个空格,并将空格作为单个编辑单位。这是因为在我们的上下文中不需要该功能。添加此功能可能需要相当多的工作。

snap.png

The Output Window输出窗口

A truly Windows output window is very handy and useful, and many people want it. WinCalcCT's output window is designed to display read-only text messages. New output strings are appended to the old content. Using the output window is as easy as using printf() for the character console. In the main thread, to display a string str in the output window, one needs only write:一个真正的Windows输出窗口非常方便和有用,很多人都想要它。WinCalcCT的输出窗口用于显示只读文本消息。新输出字符串将附加到旧内容。使用输出窗口就像使用printf() 字符控制台一样简单。在主线程中,要string str在输出窗口中显示一个,只需要写:


AfxGetMainWnd()->SendMessage(WM_USER_NEW_OUTPUT, 0, (LPARAM)(LPCSTR)str) 

In WinCalcCT, output strings are issued from the worker thread, so a pointer to the application's main window object needs to be included in the thread parameters.

The non-client portion (or the frame) of the output window is based on the CSizingControlBar class by Cristi Posea. However, I have made several modifications to the code to make the frame much more DevStudio-like and look more professional. Code for the client portion of the output window is my own work. It did not take me much time, since it virtually needs only a subset of the features of CWCTView.

在WinCalcCT输出字符串中,输出字符串是从工作线程发出的,因此指向应用程序主窗口对象的指针需要包含在线程参数中。

输出窗口的非客户端部分(或框架)基于CSizingControlBar Cristi Posea 的类。但是,我对代码进行了一些修改,使框架更像DevStudio,看起来更专业。输出窗口的客户端部分的代码是我自己的工作。它并没有花太多时间,因为它实际上只需要一部分功能CWCTView。

Other Useful UI Components其他有用的UI组件

The DevStudio-like toolbar in WinCalcCT is a slight modification of the CToolBarEx class written by Joerg Koenig. The DevStudio-like status bar is basically my own work based on CStatusBar, though I owe inspirations to many other status bar authors. I used Chris Maunder's progress bar without any modification.类似DevStudio的工具栏WinCalcCT 是对CToolBarEx Joerg Koenig所写的类的略微修改。类似DevStudio的状态栏基本上是我自己的工作CStatusBar,虽然我欠许多其他状态栏作者的灵感。我使用了Chris Maunder的进度条而没有任何修改。

Multithreaded Computing多线程计算

The relevant code for worker thread creation and synchoronization between the main thread and the worker thread is largely based on Jeff Prosise’s book “Programming Windows with MFC”. I have added code to deal with the situation where the user attempts to close a document when it is in the course of computing.主线程和工作线程之间的工作线程创建和同步化的相关代码主要基于Jeff Prosise的书“使用MFC进行Windows开发”。我添加了代码来处理用户在计算过程中尝试关闭文档的情况。

Using the Code使用代码

The CWCTView class is not meant for derivation, developers can copy the relevant code to their own code file. Note that although CWCTView is based on CView, nearly all of its user-interface features still hold even if it is based on CWnd.

To use the output window, be sure to include OutputFrm.cppOutputWnd.cppOutputWndCaret.cpp, and OutputWndScroll.cpp in your project, and create the output window in the OnCreate method of the main frame window.

The CDevStatusBar class is also not meant for derivation. Developers are expected to have a fair understanding of my code to reuse it.

该CWCTView 类不是特意派生,开发人员可以将相关代码复制到自己的代码文件。请注意,尽管CWCTView基于此,但即使基于此功能CView,其几乎所有用户界面功能仍然保留CWnd。

要使用输出窗口,请确保在项目中包含OutputFrm.cppOutputWnd.cppOutputWndCaret.cppOutputWndScroll.cpp,并OnCreate 在主框架窗口的方法中创建输出窗口。

该CDevStatusBar 类也并不意味着派生。期望开发人员对我的代码有一个公平的理解,以便重用它。

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内