How to remove the "default button" border? - c++

When you have a GtkButton in GTK and it is the default for some window (will be activated when you press Enter), a tiny border is draw around it to inform the user that the button is the default button. How to remove this border ?
I already tried: default-border and default-outside-border style properties.

After hours finding for this, I've discovered it:
gtk_button_set_relief(GTK_BUTTON(button_widget), GTK_RELIEF_HALF);
GTK should have a gallery showing how this changes the button behavior.

Related

How to avoid conflit between MenuItemImage & MenuItemSprite in Cocos2d-x 3.15.1

First I'll explain what I want to do before seeing the code, the user can click to the PLAY Button and after click, a popup Menu is displayed, the Menu contain 2 MenuItemSprite for play with bot or friend, for the MenuItemImage it's to display a small background around 2 MenuItemSprite.
The problem is when I want to click on a MenuItemSprite inside the Menu, nothing is happening, but when I set enable the Background to false all is okay without any problem, But I don't want this solution because I have inside another background (almost transparent). If the user click to this background, he can hide automatically the Menu, so I said set enable the background to false it'll give another problem conflit between Background (Window) and background (Menu).
Code :
//Background (Scene)
background=Sprite::create(BACKGROUND);
background->setPosition(SonarCocosHelper::UI::GetScreenCenter());
background->setOpacity(0);
this->addChild(background,1);
//Background Menu
MenuItemImage * overlayWindowItem=MenuItemImage::create(GAME_OVER_WINDOW,GAME_OVER_WINDOW,GAME_OVER_WINDOW,NULL);
//overlayWindowItem->setEnabled(false);
//FRIEND ITEM
MenuItemSprite * friendItem=MenuItemSprite::create(Sprite::create(FRIEND_BUTTON), Sprite::create(FRIEND_BUTTON),CC_CALLBACK_1(MenuScene::goToPlay,this));
friendItem->setTag(PLAY_WITH_FRIEND);
friendItem->setPosition(Vec2(-overlayWindowItem->getContentSize().width/4,friendItem->getPositionY()));
//BOT ITEM
MenuItemSprite * botItem=MenuItemSprite::create(Sprite::create(BOT_BUTTON), Sprite::create(BOT_BUTTON),CC_CALLBACK_1(MenuScene::goToPlay,this));
botItem->setTag(PLAY_WITH_BOT);
botItem->setPosition(Vec2(overlayWindowItem->getContentSize().width/4,botItem->getPositionY()));
//menu
menu=Menu::create(overlayWindowItem,friendItem,botItem,NULL);
menu->setPosition(Vec2(SonarCocosHelper::UI::GetScreenCenter().x,SonarCocosHelper::UI::GetScreenCenter().y+screenSize.height));
this->addChild(menu,1);
How I can avoid conflit between MenuItemImage & MenuItemSprite, I want to click on MenuItemSprite, MenuItemImage is just a background.
Thank you,
As I can see in your code, why are you taking overlayWindowItem as MenuItemImage? You are not calling any function (Set to NULL in your code).
Simply take GAME_OVER_WINDOW as an sprite. Please correct me if I am telling anything wrong.

MFC VC++: How to remove blank space between the Window caption and Client area

I am developing a desktop app using MFC. The following image shows the current state of the app's window top part. The area marked in red is unnecessary and I want to remove it.
How can I remove that space or atleast change the color to match the rest of the window background?
More Info:
The App is using Ribbon UI. I have added the App button programmatically in onCreate of CMainFrame. Is it the bar that holds the Ribbon categories? I tried SetMenubarState(AFX_MVS_HIDDEN) thinking it was the menu bar, but that didn't work. Just changing its color is also acceptable.
Update:
I have managed to change the color of that ribbon strip, and removed the caption bar I used for showing the 'add' button. Now I need to figure out how to place the 'Add' button on the right side of the ribbon strip.

Qt: Disable a Push Button without turning it gray

I need to make a checkable Push Button in Qt 4.8 that when is checked it becomes disabled.
The problem that I have is that the button turns gray and I need to keep it with the same color always. I have two questions for two possibles paths to follow:
1) Is there a way to disable the gray out effect when I use button.setEnabled(false)?
2) Is there a way to hook the click event so I can "simulate" the disabled property?
Thanks in advance!
[Edit] To give a little context, I have two push buttons that should toggle each other and that's why I need to prevent clicking on a pressed button.
Try button.blockSignals(true). You could also overwrite the look of the button when its disabled with a Qt style sheet.
To give a little context, I have two push buttons that should toggle
each other and that's why I need to prevent clicking on a pressed
button.
You should use QButtonGroup instead.
The only way that the button should be unchecked is when the user
checks the other button...
From doc:
In an exclusive group, the user cannot uncheck the currently checked
button by clicking on it; instead, another button in the group must be
clicked to set the new checked button for that group.
For disabling toolbutton and put icon of your choice instead of turning into grey
you have to load icon creating QPixmap object say qpm,
create QIcon object say icon
icon.addPixmap(qpm,QIcon::Disabled,QIcon::On) this line will show icon
setIcon on toolbutton
setStyleSheet
When enabling Toolbutton just change
3. icon.addPixmap(qpm,QIcon::Normal,QIcon::On)

How to catch GTK focus state in gtkrc?

GTK+ 2.x has the follow states: NORMAL, PRELIGHT, ACTIVE, INSENSITIVE, SELECTED for use in GTK themes and I can do things like...
bg[NORMAL] = "#f6f6f6"
.. to change background color when in NORMAL state.
Also, I can change the background image of a button (when the mouse is over it) by changing the PRELIGHT state image.
But I was not able to find a way to change the button background when the user cycle the focus using the TAB arrow (ie. when a dashed rectangle appears around the button). I want to do this using themes in gtkrc, is this possible ?
I don't think so. The RC file documentation doesn't even mention "focus", so I don't think it's possible to theme that in this way.

How to SetFocus to a CButton so that the border and focus dotted line are visible?

I created a simple dialog-based application, and in the default CDialog added three buttons (by drag-and-dropping them) using the Visual Studio editor.
The default OK and Cancel buttons are there too.
I want to set the focus to button 1 when I click button 3.
I set the property Flat to true in the properties for muy buttons.
I coded this:
void CbuttonfocusDlg::OnBnClickedButton3()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_BUTTON1)->SetFocus();
Invalidate();
}
But the boder in button1 is never drawn. The caret (the dotted line indicating focus) is only drawn if I pressed TAB any time before clicking button 3.
I want the button to look exactly as it looks after I click it. Showing the dotted line inside the button programatically, would be a plus.
What I want:
What I get:
Use WM_NEXTDLGCTL.
See Reymond Chen's "How to set focus in a dialog box":
void SetDialogFocus(HWND hdlg, HWND hwndControl)
{
SendMessage(hdlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, TRUE);
}
By calling UpdateWindow, the button is being redrawn before the focus change can take effect. The Invalidate should be sufficient by itself, the window will get repainted when everything settles down.
This draws the thick border around the button:
static_cast<CButton*>(GetDlgItem(IDC_BUTTON1))->SetButtonStyle(BS_DEFPUSHBUTTON);
A more elegant way to do this would be to define a CButton member variable in CbuttonfocusDlg and associate it to the IDC_BUTTON1 control, and then calling
this->m_myButton.SetButtonStyle(BS_DEFPUSHBUTTON);
This makes the button to which I'm setting the focus the default button, but note that when the focus goes to a control (inside the dialog) that is not a button, the default button is once more the original default button set in the dialog resource, in this case the "Ok" button.
I am following Joel's suggestion. But slightly different with the API used in that link, my one is :
PostMessage(WM_NEXTDLGCTL, (WPARAM)(pwnd->GetSafeHwnd()), TRUE);