简体   繁体   English

在X11上编辑框

[英]Edit box on X11

Is there any way to have a simple edit box in plain X11 C or C++ code? 有什么办法可以用纯X11 C或C ++代码创建一个简单的编辑框?

By "plain X11 C or C++ code" I mean creating the control on a XCreateSimpleWindow created window as the CreateWindow("edit"..) equivalent in Win32 API. 通过“普通X11 C或C ++代码”,我的意思是在XCreateSimpleWindow创建的窗口上创建控件,作为Win32 API中的CreateWindow("edit"..)等效项。

If not, what are my options to have a simple edit box with the minimum amount of dependencies (ie no Qt please) for a simple edit box input dialog? 如果没有,那么对于一个简单的编辑框输入对话框,有一个具有最小依赖项(即,请不要Qt)的简单编辑框的选项是什么?

Plain X11 doesn't have such functionality - It is a low-level windowing toolkit (opening and maintaining windows, receiving input events, drawing to windows). Plain X11没有这种功能-这是一个低级的窗口工具包 (打开和维护窗口,接收输入事件,绘制到窗口)。

In case you are prepared to write such an edit window from the available primitives, you are fine. 如果您准备根据可用的原语编写这样的编辑窗口,则可以。 If not, you need to use some toolkit that does it for you. 如果不是,则需要使用一些工具包来为您完成此任务。 The simplest and most lightweight one providing such functions would probably be Athena widgets (in case you are not particularily choosy about look and feel). 提供此类功能的最简单,最轻便的组件可能是Athena小部件(以防您不特别选择外观和风格)。

X11 is a very low level protocol. X11是一个非常低级的协议。 It provides the ability to create individual windows, draw on them, and receive individual input events, and nothing more. 它提供了创建单个窗口,在其上绘制并接收单个输入事件的功能,仅此而已。 That's it. 而已。

The job of providing high level user interface, like edit boxes, is for higher level toolkits, like Qt or Gtk. 提供高级用户界面(如编辑框)的工作是针对高级工具箱(如Qt或Gtk)的。 Those are the most common toolkits. 这些是最常见的工具箱。 There are a few less-popular ones too. 也有一些不太受欢迎的。

But the bottom line is that there are no "edit controls" of any kind, that you get with Xlib, the library you're using to talk X11 protocol. 但最重要的是,您没有使用Xlib来获得的任何“编辑控件”,Xlib是您用来谈论X11协议的库。 If the only dependency you want is Xlib, then it's up to you to actually implement the edit control, using your own code. 如果您想要的唯一依赖项是Xlib,则取决于您实际使用自己的代码来实现编辑控件。 If you don't want to use any common font handling libraries, like fontconfig and freetype, you will have to write the code to enumerate the X server's built-in fonts, handle keyboard input, and draw your edit control. 如果您不想使用任何常见的字体处理库,例如fontconfig和freetype,则必须编写代码以枚举X服务器的内置字体,处理键盘输入并绘制编辑控件。 Just the job of translating the somewhat obscure keyboard encodings used in X11 into something usable, like UTF-8 or unicode, will take a few hundreds of lines of code. 将X11中使用的有些晦涩的键盘编码转换成可用的东西(如UTF-8或unicode)的工作仅需要几百行代码。

So the answer here is: use Qt or Gtk. 所以这里的答案是:使用Qt或Gtk。

作为X小部件的低级替代,您可以使用Xaw库,Motif库或Xforms库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM