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();
179 getParent()->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
183 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
192 FXEvent*
event = (FXEvent*)ptr;
193 if (isEnabled() && !(flags & FLAG_PRESSED)) {
194 FXTRACE((200,
"%s::onKeyPress %p keysym = 0x%04x state = %04x\n", getClassName(), (
void*)
this, event->code, event->state));
195 if (event->code == FX::KEY_space || event->code == FX::KEY_KP_Space || event->code == FX::KEY_Return || event->code == FX::KEY_KP_Enter) {
196 flags |= FLAG_PRESSED;
206 FXEvent*
event = (FXEvent*)ptr;
207 if (isEnabled() && (flags & FLAG_PRESSED)) {
208 FXTRACE((200,
"%s::onKeyRelease %p keysym = 0x%04x state = %04x\n", getClassName(), (
void*)
this, event->code, event->state));
209 if (event->code == FX::KEY_space || event->code == FX::KEY_KP_Space || event->code == FX::KEY_Return || event->code == FX::KEY_KP_Enter) {
210 flags &= ~FLAG_PRESSED;
212 getParent()->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
214 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
225 FXTRACE((200,
"%s::onHotKeyPress %p\n", getClassName(), (
void*)
this));
226 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
227 if (isEnabled() && !(flags & FLAG_PRESSED)) {
228 flags |= FLAG_PRESSED;
236 FXTRACE((200,
"%s::onHotKeyRelease %p\n", getClassName(), (
void*)
this));
237 if (isEnabled() && (flags & FLAG_PRESSED)) {
238 flags &= ~FLAG_PRESSED;
240 getParent()->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
242 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
254 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)(FXuval)
myCheck);
264 FXEvent* ev = (FXEvent*)ptr;
265 FXDCWindow dc(
this, ev);
276 dc.setForeground(backColor);
277 dc.fillRectangle(0, 0, width, height);
278 if (!label.empty()) {
279 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
281 dc.setForeground(hiliteColor);
282 dc.drawText(xx + 1, yy + 1, label);
283 if (!accel.empty()) {
284 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel) + 1, yy + 1, accel);
287 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff) + 1, yy + 2, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
289 dc.setForeground(shadowColor);
290 dc.drawText(xx, yy, label);
291 if (!accel.empty()) {
292 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
295 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
298 }
else if (isActive()) {
300 dc.setForeground(selbackColor);
301 dc.fillRectangle(0, 0, width, height);
302 if (!label.empty()) {
303 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
305 dc.setForeground(isEnabled() ? seltextColor : shadowColor);
306 dc.drawText(xx, yy, label);
307 if (!accel.empty()) {
308 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
311 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
316 dc.setForeground(backColor);
317 dc.fillRectangle(0, 0, width, height);
318 if (!label.empty()) {
319 yy = font->getFontAscent() + (height - font->getFontHeight()) / 2;
321 dc.setForeground(textColor);
322 dc.drawText(xx, yy, label);
323 if (!accel.empty()) {
324 dc.drawText(width -
TRAILSPACE - font->getTextWidth(accel), yy, accel);
327 dc.fillRectangle(xx + font->getTextWidth(&label[0], hotoff), yy + 1, font->getTextWidth(&label[hotoff], wclen(&label[hotoff])), 1);
333 yy = (height - 9) / 2;
335 dc.setForeground(backColor);
338 dc.fillRectangle(xx + 1, yy + 1, 8, 8);
339 dc.setForeground(shadowColor);
340 dc.drawRectangle(xx, yy, 9, 9);
345 seg[0].x1 = 2 + (FXshort)xx;
346 seg[0].y1 = 4 + (FXshort)yy;
347 seg[0].x2 = 4 + (FXshort)xx;
348 seg[0].y2 = 6 + (FXshort)yy;
349 seg[1].x1 = 2 + (FXshort)xx;
350 seg[1].y1 = 5 + (FXshort)yy;
351 seg[1].x2 = 4 + (FXshort)xx;
352 seg[1].y2 = 7 + (FXshort)yy;
353 seg[2].x1 = 2 + (FXshort)xx;
354 seg[2].y1 = 6 + (FXshort)yy;
355 seg[2].x2 = 4 + (FXshort)xx;
356 seg[2].y2 = 8 + (FXshort)yy;
357 seg[3].x1 = 4 + (FXshort)xx;
358 seg[3].y1 = 6 + (FXshort)yy;
359 seg[3].x2 = 8 + (FXshort)xx;
360 seg[3].y2 = 2 + (FXshort)yy;
361 seg[4].x1 = 4 + (FXshort)xx;
362 seg[4].y1 = 7 + (FXshort)yy;
363 seg[4].x2 = 8 + (FXshort)xx;
364 seg[4].y2 = 3 + (FXshort)yy;
365 seg[5].x1 = 4 + (FXshort)xx;
366 seg[5].y1 = 8 + (FXshort)yy;
367 seg[5].x2 = 8 + (FXshort)xx;
368 seg[5].y2 = 4 + (FXshort)yy;
371 dc.setForeground(shadowColor);
373 dc.setForeground(textColor);
376 dc.setForeground(shadowColor);
378 dc.drawLineSegments(seg, 6);
384 xx += 5 +
myIcon->getWidth();
387 xx += 5 +
myIcon->getWidth();
405 FXMenuCommand::save(store);
412 FXMenuCommand::load(store);