20const char* vk_to_string(
int vk_code)
24 case kVK_HELP:
return "VK_HELP";
25 case kVK_BACK:
return "VK_BACK";
26 case kVK_TAB:
return "VK_TAB";
27 case kVK_CLEAR:
return "VK_CLEAR";
28 case kVK_RETURN:
return "VK_RETURN";
29 case kVK_SHIFT:
return "VK_SHIFT";
30 case kVK_CONTROL:
return "VK_CONTROL";
31 case kVK_MENU:
return "VK_MENU";
32 case kVK_PAUSE:
return "VK_PAUSE";
33 case kVK_CAPITAL:
return "VK_CAPITAL";
34 case kVK_ESCAPE:
return "VK_ESCAPE";
35 case kVK_SPACE:
return "VK_SPACE";
36 case kVK_PRIOR:
return "VK_PAGE_UP";
37 case kVK_NEXT:
return "VK_PAGE_DOWN";
38 case kVK_END:
return "VK_END";
39 case kVK_HOME:
return "VK_HOME";
40 case kVK_LEFT:
return "VK_LEFT";
41 case kVK_UP:
return "VK_UP";
42 case kVK_RIGHT:
return "VK_RIGHT";
43 case kVK_DOWN:
return "VK_DOWN";
44 case kVK_SELECT:
return "VK_SELECT";
45 case kVK_PRINT:
return "VK_PRINT";
46 case kVK_INSERT:
return "VK_INSERT";
47 case kVK_DELETE:
return "VK_DELETE";
48 case kVK_NUMPAD0:
return "VK_NUMPAD0";
49 case kVK_NUMPAD1:
return "VK_NUMPAD1";
50 case kVK_NUMPAD2:
return "VK_NUMPAD2";
51 case kVK_NUMPAD3:
return "VK_NUMPAD3";
52 case kVK_NUMPAD4:
return "VK_NUMPAD4";
53 case kVK_NUMPAD5:
return "VK_NUMPAD5";
54 case kVK_NUMPAD6:
return "VK_NUMPAD6";
55 case kVK_NUMPAD7:
return "VK_NUMPAD7";
56 case kVK_NUMPAD8:
return "VK_NUMPAD8";
57 case kVK_NUMPAD9:
return "VK_NUMPAD9";
58 case kVK_MULTIPLY:
return "VK_MULTIPLY";
59 case kVK_ADD:
return "VK_ADD";
60 case kVK_SEPARATOR:
return "VK_SEPARATOR";
61 case kVK_SUBTRACT:
return "VK_SUBTRACT";
62 case kVK_DECIMAL:
return "VK_DECIMAL";
63 case kVK_DIVIDE:
return "VK_DIVIDE";
64 case kVK_F1:
return "VK_F1";
65 case kVK_F2:
return "VK_F2";
66 case kVK_F3:
return "VK_F3";
67 case kVK_F4:
return "VK_F4";
68 case kVK_F5:
return "VK_F5";
69 case kVK_F6:
return "VK_F6";
70 case kVK_F7:
return "VK_F7";
71 case kVK_F8:
return "VK_F8";
72 case kVK_F9:
return "VK_F9";
73 case kVK_F10:
return "VK_F10";
74 case kVK_F11:
return "VK_F11";
75 case kVK_F12:
return "VK_F12";
76 case kVK_F13:
return "VK_F13";
77 case kVK_F14:
return "VK_F14";
78 case kVK_F15:
return "VK_F15";
79 case kVK_F16:
return "VK_F16";
80 case kVK_F17:
return "VK_F17";
81 case kVK_F18:
return "VK_F18";
82 case kVK_F19:
return "VK_F19";
83 case kVK_F20:
return "VK_F20";
84 case kVK_F21:
return "VK_F21";
85 case kVK_F22:
return "VK_F22";
86 case kVK_F23:
return "VK_F23";
87 case kVK_F24:
return "VK_F24";
88 case kVK_NUMLOCK:
return "VK_NUMLOCK";
89 case kVK_SCROLL:
return "VK_SCROLL";
90 case kVK_RETURN|0x8000:
return "ENTER";
91 default:
return "Unknown VK code";
105 mStr.Set(
"Press a key...");
119 g.
DrawText(
IText(
static_cast<float>((rand() % 30) + 10), COLOR_WHITE), mStr.Get(), mX, mY);
125 g.
FillRect(COLOR_BLACK, mRECT, &BLEND_05);
141 mStr.SetFormatted(64,
"MouseDown: L:%i, R:%i, A:%i, C:%i. S:%i", mod.L, mod.R, mod.A, mod.C, mod.S);
147 mStr.SetFormatted(64,
"MouseUp: L:%i, R:%i, A:%i, C:%i. S:%i", mod.L, mod.R, mod.A, mod.C, mod.S);
153 mStr.Set(vk_to_string(key.VK));
155 if(strcmp(mStr.Get(),
"Unknown VK code")==0)
166 void StrUpdated(
float x,
float y)
177 bool mNewText =
false;
This file contains the base IControl implementation, along with some base classes for specific types ...
The lowest level base class of an IGraphics control.
void StartAnimation(int duration)
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
void SetAnimation(IAnimationFunction func)
Set the animation function.
The lowest level base class of an IGraphics context.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
void ResumeLayer(ILayerPtr &layer)
If a layer already exists, continue drawing to it.
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
ILayerPtr EndLayer()
End an IGraphics layer.
Control to test keyboard input.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
bool OnKeyDown(float x, float y, const IKeyPress &key) override
Implement this method to respond to a key down event on this control.
BEGIN_IPLUG_NAMESPACE BEGIN_IGRAPHICS_NAMESPACE void DefaultAnimationFunc(IControl *pCaller)
An animation function that just calls the caller control's OnEndAnimation() method at the end of the ...
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.
IText is used to manage font and text/text entry style for a piece of text on the UI,...