Motif库(C)的水平绘制RowColumn类? [英] Horizontally-Drawn RowColumn Class for Motif Library (C)?

查看:92
本文介绍了Motif库(C)的水平绘制RowColumn类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Motif库进行工作。如果有人不熟悉该库,则可以在这里 https上找到文件列表。 ://packages.ubuntu.com/xenial/amd64/libmotif-dev/filelist ,以及此处的另一个问题 Motif 1.2 X11在ScrolledWindow中使用RowColumn小部件


我的问题是xmRowColumnWidgetClass是垂直绘制的,这意味着它逐列绘制(从左上角开始移动到左下角,然后再右移到下一列,依此类推。)


执行以下操作:

  Widget parentWidget,rowColumn; 

XtAppContext应用;

parentWidget = XtVaAppInitialize(& app, rowColumn,NULL,0,
& argc,argv,NULL,NULL);

然后像这样:

  rowColumn = XtVaCreateManagedWidget( rowcolumn,
xmRowColumnWidgetClass,
parentWidget,
XmNnumColumns,3,
XmNpacking,XmPACK_COLUMN,
XmNspacing,6,
NULL);

(无效)XtVaCreateManagedWidget(按钮1,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮2,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮3,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮4,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮5,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮6,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮7,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮8,
xmPushButtonWidgetClass,rowColumn,NULL);

(无效)XtVaCreateManagedWidget(按钮9,
xmPushButtonWidgetClass,rowColumn,NULL);

所以上面的代码将创建这样的小部件:

 按钮1按钮4按钮7 

按钮2按钮5按钮8

按钮3按钮6按钮9




我的问题是我希望某些项并排,而不是上下排。 p>

作为一种解决方法,我想指定这样的顺序:按钮1,按钮4,按钮7,按钮2,按钮5,按钮8,按钮3,按钮6,按钮9。看起来像这样:

 按钮1按钮2按钮3 

按钮4按钮5按钮6

按钮7按钮8按钮9

但是,如果我要删除按钮或添加新按钮,这搞砸了一切。假设我删除了按钮4在上面的示例中,顺序如下:按钮1,按钮7,按钮2,按钮5,按钮8,按钮3,按钮6,按钮9。

 按钮1按钮5按钮6 

按钮7按钮8按钮9

按钮2按钮3

现在,几乎没有什么应该并排放置。


当您添加新按钮时也会发生此问题:假设我们要在最后添加按钮10:按钮1,按钮4,按钮7,按钮2,按钮5,按钮8,按钮3 ,按钮6,按钮9,按钮10。

 按钮1按钮5按钮9 

按钮4按钮8按钮10

按钮7按钮3

按钮2按钮6

到目前为止,这看起来是最糟糕的,因为添加新按钮会将行的法线增加到4而不是3,这会改变整个布局。




向熟悉此库的任何人


我该如何创建一个xmRowColumnWidgetClass实例,该实例可以水平(逐行)绘制垂直的? (逐列)


或者,如何扩展该库并可能制作一个xmHorRowColumnWidgetClass来实现我想要的功能?




该库的另一组示例:

https://github.com/spartrekus/Motif-C-Examples

https://github.com/spartrekus/Motif-C-Examples/blob/master/rowcol.c

解决方案

要使xmRowColumnWidgetClass实例水平绘制,请在代码中添加 XmNorientation,XmHORIZONTAL

  rowColumn = XtVaCreateManagedWidget( rowcolumn,
xmRowColumnWidgetClass,
parentWidget,
XmNnumColumns ,3,
XmNorientation,XmHORIZONTAL,
XmNpacking,XmPACK_COLUMN,
XmNspacing,6,
NULL);

这使得它逐行绘制,而不是逐列绘制。



XmNnumColumns现在是出于某些原因而不是列数,但这是一个单独的问题,因此上面的代码确实可以回答我的原始问题。


I am using the Motif Library for my job. If anybody is not familiar with this library, you can find a list of files here https://packages.ubuntu.com/xenial/amd64/libmotif-dev/filelist, as well as another question here Motif 1.2 X11 on using RowColumn widget inside a ScrolledWindow.

My issue is that the xmRowColumnWidgetClass is drawn vertically, which means it draws it column by column (starts at top left moving to bottom left, then moves right to the next column, etc.)

Doing something like this:

Widget parentWidget, rowColumn;

XtAppContext app;

parentWidget = XtVaAppInitialize(&app, "rowColumn", NULL, 0,
&argc, argv, NULL, NULL);

and then like this:

rowColumn = XtVaCreateManagedWidget("rowcolumn",
            xmRowColumnWidgetClass,
            parentWidget,
            XmNnumColumns, 3,
            XmNpacking, XmPACK_COLUMN,
            XmNspacing, 6,
            NULL);

(void) XtVaCreateManagedWidget("button 1",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 2",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 3",
xmPushButtonWidgetClass, rowColumn, NULL);
        
(void) XtVaCreateManagedWidget("button 4",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 5",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 6",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 7",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 8",
xmPushButtonWidgetClass, rowColumn, NULL);

(void) XtVaCreateManagedWidget("button 9",
xmPushButtonWidgetClass, rowColumn, NULL);

So the above code would create the Widgets like this:

button 1    button 4    button 7

button 2    button 5    button 8

button 3    button 6    button 9


My problem is that I want certain ones to be side-by-side rather than above-below.

And suppose as a way around this I specify an order like this: button 1, button 4, button 7, button 2, button 5, button 8, button 3, button 6, button 9. That would look like this:

button 1    button 2    button 3

button 4    button 5    button 6

button 7    button 8    button 9

However, if I wanted to remove a button or add a new button, this messes everything up. Let's say I remove the "button 4" from the above example, so the order is like this: button 1, button 7, button 2, button 5, button 8, button 3, button 6, button 9. That would look like this:

button 1    button 5    button 6

button 7    button 8    button 9

button 2    button 3

As you can see, practically nothing that should be side-by-side next to each other is next to each other now.

This problem also happens when you add a new button: Let's say we want to add a button 10 to the end: button 1, button 4, button 7, button 2, button 5, button 8, button 3, button 6, button 9, button 10. This would look like this:

button 1    button 5    button 9

button 4    button 8    button 10

button 7    button 3

button 2    button 6

This by far looks the worst, since adding a new button increases the normal of rows to 4 instead of 3, which changes the entire layout.


To anybody familiar with this library:

How do I create a xmRowColumnWidgetClass instance that draws horizontally (row-by-row) instead of vertically? (column-by-column)

Or, how can I extend this library and possibly make a xmHorRowColumnWidgetClass that does what I want?


Another group of examples of this library:
https://github.com/spartrekus/Motif-C-Examples
https://github.com/spartrekus/Motif-C-Examples/blob/master/rowcol.c

解决方案

To make the xmRowColumnWidgetClass instance draw horizontally, add XmNorientation, XmHORIZONTAL to the code:

rowColumn = XtVaCreateManagedWidget("rowcolumn",
            xmRowColumnWidgetClass,
            parentWidget,
            XmNnumColumns, 3,
            XmNorientation, XmHORIZONTAL,
            XmNpacking, XmPACK_COLUMN,
            XmNspacing, 6,
            NULL);

This makes it draw row-by-row rather than column-by-column.

XmNnumColumns now refers to the number of rows rather than columns for some reason, but this is a separate issue and so the above code does indeed answer my original question.

这篇关于Motif库(C)的水平绘制RowColumn类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆