55 FXIMPLEMENT(
MFXMenuCheckIcon, FXMenuCommand, MFXMenuCheckIconMap, ARRAYNUMBER(MFXMenuCheckIconMap))
62 FXMenuCommand(p, (text + "\t" + shortcut + "\t" + info).c_str(), NULL, tgt, sel, opts),
65 myBoxColor(getApp()->getBackColor()) {
74 tw = font->getTextWidth(label.text(), label.length());
77 aw = font->getTextWidth(accel.text(), accel.length());
94 if (!label.empty() || !accel.empty()) {
95 th = font->getFontHeight() + 5;
175 FXbool active = isActive();
184 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
193 FXEvent*
event = (FXEvent*)ptr;
194 if (isEnabled() && !(flags & FLAG_PRESSED)) {
195 FXTRACE((200,
"%s::onKeyPress %p keysym = 0x%04x state = %04x\n", getClassName(), (
void*)
this, event->code, event->state));
196 if (event->code == FX::KEY_space || event->code == FX::KEY_KP_Space || event->code == FX::KEY_Return || event->code == FX::KEY_KP_Enter) {
197 flags |= FLAG_PRESSED;
207 FXEvent*
event = (FXEvent*)ptr;
208 if (isEnabled() && (flags & FLAG_PRESSED)) {
209 FXTRACE((200,
"%s::onKeyRelease %p keysym = 0x%04x state = %04x\n", getClassName(), (
void*)
this, event->code, event->state));
210 if (event->code == FX::KEY_space || event->code == FX::KEY_KP_Space || event->code == FX::KEY_Return || event->code == FX::KEY_KP_Enter) {
211 flags &= ~FLAG_PRESSED;
213 getParent()->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
215 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
226 FXTRACE((200,
"%s::onHotKeyPress %p\n", getClassName(), (
void*)
this));
227 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
228 if (isEnabled() && !(flags & FLAG_PRESSED)) {
229 flags |= FLAG_PRESSED;
237 FXTRACE((200,
"%s::onHotKeyRelease %p\n", getClassName(), (
void*)
this));
238 if (isEnabled() && (flags & FLAG_PRESSED)) {
239 flags &= ~FLAG_PRESSED;
241 getParent()->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
243 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
255 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
265 FXEvent* ev = (FXEvent*)ptr;
266 FXDCWindow dc(
this, ev);
277 dc.setForeground(backColor);
278 dc.fillRectangle(0, 0, width, height);
279 if (!label.empty()) {
280 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
282 dc.setForeground(hiliteColor);
283 dc.drawText(xx + 1, yy + 1, label);
284 if (!accel.empty()) {
285 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel) + 1, yy + 1, accel);
288 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff) + 1, yy + 2, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
290 dc.setForeground(shadowColor);
291 dc.drawText(xx, yy, label);
292 if (!accel.empty()) {
293 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
296 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
299 }
else if (isActive()) {
301 dc.setForeground(selbackColor);
302 dc.fillRectangle(0, 0, width, height);
303 if (!label.empty()) {
304 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
306 dc.setForeground(isEnabled() ? seltextColor : shadowColor);
307 dc.drawText(xx, yy, label);
308 if (!accel.empty()) {
309 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
312 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
317 dc.setForeground(backColor);
318 dc.fillRectangle(0, 0, width, height);
319 if (!label.empty()) {
320 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
322 dc.setForeground(textColor);
323 dc.drawText(xx, yy, label);
324 if (!accel.empty()) {
325 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
328 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
334 yy = (height - 9) / 2;
336 dc.setForeground(backColor);
339 dc.fillRectangle(xx + 1, yy + 1, 8, 8);
340 dc.setForeground(shadowColor);
341 dc.drawRectangle(xx, yy, 9, 9);
346 seg[0].x1 = 2 + (FXshort)xx;
347 seg[0].y1 = 4 + (FXshort)yy;
348 seg[0].x2 = 4 + (FXshort)xx;
349 seg[0].y2 = 6 + (FXshort)yy;
350 seg[1].x1 = 2 + (FXshort)xx;
351 seg[1].y1 = 5 + (FXshort)yy;
352 seg[1].x2 = 4 + (FXshort)xx;
353 seg[1].y2 = 7 + (FXshort)yy;
354 seg[2].x1 = 2 + (FXshort)xx;
355 seg[2].y1 = 6 + (FXshort)yy;
356 seg[2].x2 = 4 + (FXshort)xx;
357 seg[2].y2 = 8 + (FXshort)yy;
358 seg[3].x1 = 4 + (FXshort)xx;
359 seg[3].y1 = 6 + (FXshort)yy;
360 seg[3].x2 = 8 + (FXshort)xx;
361 seg[3].y2 = 2 + (FXshort)yy;
362 seg[4].x1 = 4 + (FXshort)xx;
363 seg[4].y1 = 7 + (FXshort)yy;
364 seg[4].x2 = 8 + (FXshort)xx;
365 seg[4].y2 = 3 + (FXshort)yy;
366 seg[5].x1 = 4 + (FXshort)xx;
367 seg[5].y1 = 8 + (FXshort)yy;
368 seg[5].x2 = 8 + (FXshort)xx;
369 seg[5].y2 = 4 + (FXshort)yy;
372 dc.setForeground(shadowColor);
374 dc.setForeground(textColor);
377 dc.setForeground(shadowColor);
379 dc.drawLineSegments(seg, 6);
385 xx += 5 +
myIcon->getWidth();
388 xx += 5 +
myIcon->getWidth();
406 FXMenuCommand::save(store);
413 FXMenuCommand::load(store);