开发者

wxWidgets and X11 issues in Ubuntu?

开发者 https://www.devze.com 2023-04-05 01:22 出处:网络
I\'m trying to make a simple Dialog Based GUI using wxWidgets. I am using X11/Xlib.h for image capturing (printscreen). Problems start when I change anything in GUI using wxSmith (e.g. drag and 开发者

I'm trying to make a simple Dialog Based GUI using wxWidgets. I am using X11/Xlib.h for image capturing (printscreen). Problems start when I change anything in GUI using wxSmith (e.g. drag and 开发者_开发技巧drop new button) because it automatically changes button names to Button1,Button2...

Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));

Problem is that Button1..5 are already defined in X.h:

/* button names. Used as arguments to GrabButton and as detail in ButtonPress
   and ButtonRelease events.  Not to be confused with button masks above.
   Note that 0 is already defined above as "AnyButton".  */

#define Button1         1
#define Button2         2
#define Button3         3
#define Button4         4
#define Button5         5

Can I somehow modify wxWidgets not to automatically change names or just to add my custom prefix e.g. somethingButton1?


Are you changing the var name in the GUI designer, or editing the cpp file directly?

If you edit stuff between //(*Initialize(PanelName) and //*) in the cpp then any changes you make will be wiped out (not just the change to the button name).

If you are looking at the Resources tab (which you should be if you're using the Drag 'n Drop), below it is the properties of the currently selected button (or other widget). Change the Var name property to myButton1 to change the variable name.


Seems to me that you can simply write

myButton1 = new wxButton(this, ID_BUTTON1, _("About"), ....

I see that you are using wxSmith, a Rapid Application Developer (RAD) plugin for CodeBlocks. This means that you are relying on a computer program to write your code for you, which is something that has never worked well for all the decades of effort.

My advice would be, best first:

  1. Take a deep breath and write your own code. You will learn a lot!

  2. Choose another RAD. There are many available and some should be more sophisticated and adapted to running with X11.

  3. Download the wxSmith code. Do a global find & replace Button1 -> wxSmith_Button1. Rebuild.

0

精彩评论

暂无评论...
验证码 换一张
取 消