SetIcon draws icon offset vertically from desired location
Posted: Fri Dec 01, 2017 7:11 pm
I am trying to draw a wxStaticBitmap on my wxFrame. My wxStaticBitmap is a circle that can be colored either red, yellow, or green, so I have three xpm files, each a circle the same size but a different color. The wxStaticBitmap gets drawn in the correct location on the wxFrame the first time. However, every time I call SetIcon to change the color of the circle, instead of simply replacing the current xpm image with the new xpm image, a new little circle is drawn directly above the previous circle, so I have n + 1 circles. The more times I click to change the color, the more circles appear on the screen, all moving up from the previous icon. I don't want new circles. I only want one, and I want it in the lower left corner of the screen. Here is a screen shot of this:
What I did to make the circle: I created a wxBoxSizer. I set the wxALL, wxLEFT, wxRIGHT, wxTOP, wxBOTTOM, wxALIGN_BOTTOM wxBoxSizer Sizer Flags true. All the other wxBoxSizer Flags are false. Proportion = 0.
Inside the wxBoxSizer, I created a wxStaticBitmap. I set the wxALIGN_LEFT and wxALIGN_BOTTOM wxStaticBitmap Sizer Flags to true. All the other wxStaticBitmap Sizer Flags are false. Proportion = 1.
I change the value of the wxStaticBitmap during the course of execution, but it only gets updated in two lines of the code: once in the constructor, and once in a procedure called Display_Text_in_Status_Field. See MainFrame.cpp below. If you need anything else, please ask.
How do I make the circle get drawn in the correct location?
I looked at http://docs.wxwidgets.org/3.0/classwx_s ... itmap.html, but I didn't see a "SetPosition" or "MoveTo" or similar command. I thought setting the Sizer Flags would do the job. They work for everything else.
I am using Windows 10, Codelite version 11.0.1, and wxCrafter.
Thanks!
Colleen
What I did to make the circle: I created a wxBoxSizer. I set the wxALL, wxLEFT, wxRIGHT, wxTOP, wxBOTTOM, wxALIGN_BOTTOM wxBoxSizer Sizer Flags true. All the other wxBoxSizer Flags are false. Proportion = 0.
Inside the wxBoxSizer, I created a wxStaticBitmap. I set the wxALIGN_LEFT and wxALIGN_BOTTOM wxStaticBitmap Sizer Flags to true. All the other wxStaticBitmap Sizer Flags are false. Proportion = 1.
I change the value of the wxStaticBitmap during the course of execution, but it only gets updated in two lines of the code: once in the constructor, and once in a procedure called Display_Text_in_Status_Field. See MainFrame.cpp below. If you need anything else, please ask.
How do I make the circle get drawn in the correct location?
I looked at http://docs.wxwidgets.org/3.0/classwx_s ... itmap.html, but I didn't see a "SetPosition" or "MoveTo" or similar command. I thought setting the Sizer Flags would do the job. They work for everything else.
I am using Windows 10, Codelite version 11.0.1, and wxCrafter.
Thanks!
Colleen