Home » Community » Newbie corner » How to get rect of small square of OptionBox (Custom OptionBox Ctrl)
| Re: How to get rect of small square of OptionBox [message #62064 is a reply to message #62062] |
Mon, 21 September 2026 19:01   |
Oblivion
Messages: 1284 Registered: August 2007
|
Senior Contributor |
|
|
Hi,
One way (usually something like this, if you want to build your own ctrl...)
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
Point pos = Null;
bool pressed = false;
Rect target = Null;
MyApp()
{
Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 400, 400);
}
void Paint(Draw& w) override
{
w.DrawRect(GetView(), Black());
w.DrawRect(target, pressed ? Green() : target.Contains(pos) ? Red() : White());
}
void Layout() override
{
Rect r = GetView();
target = r.CenterRect(r.GetSize() / 4);
}
void LeftDown(Point pt, dword) override
{
SetCapture();
pressed = target.Contains(pt);
Refresh();
}
void LeftUp(Point pt, dword) override
{
ReleaseCapture();
pressed = false;
Refresh();
}
void MouseMove(Point pt, dword) override
{
pos = pt;
Refresh();
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
TerminalCtrl package https://github.com/ismail-yilmaz/Terminal
|
|
|
|
Goto Forum:
Current Time: Wed Sep 30 04:03:24 GMT+2 2026
Total time taken to generate the page: 0.00614 seconds
|