User forums > Using Code::Blocks

Configure dialog icon issue when clicked

(1/4) > >>

ollydbg:
Hi, I have three screen shots below, the first one is that a plugin icon is not selected, so the gray icon is shown, the second one is one mouse click, so that a color icon is shown, the third one is when after another mouse click, the icon show in a shadow. My question is: Does the third one is the expected behavior? I see no difference between the second and the third. But I'd say that an color icon with shadow is not very good, what do you think?

First icon:

Second icon:

Third icon:


Thanks.

ollydbg:

--- Code: ---void EditorConfigurationDlg::UpdateListbookImages()
{
    wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
    int sel = lb->GetSelection();
    // set page images according to their on/off status
    for (size_t i = 0; i < IMAGES_COUNT + m_PluginPanels.GetCount(); ++i)
    {
        lb->SetPageImage(i, (i * 2) + (sel == (int)i ? 0 : 1));
    }

    // the selection colour is ruining the on/off effect,
    // so make sure no item is selected ;)
    // (only if we have icons showing)
    if (GetSettingsIconsStyle(lb->GetListView()) != sisNoIcons)
        lb->GetListView()->Select(sel, false);

    // update the page title
    wxString label = lb->GetPageText(sel);
    // replace any stray & with && because label makes it an underscore
    while (label.Replace(_T(" & "), _T(" && ")))
        ;
    XRCCTRL(*this, "lblBigTitle", wxStaticText)->SetLabel(label);
    XRCCTRL(*this, "pnlTitleInfo", wxPanel)->Layout();
}

void EditorConfigurationDlg::OnPageChanged(wxListbookEvent& event)
{
    // update only on real change, not on dialog creation
    if (event.GetOldSelection() != -1 && event.GetSelection() != -1)
    {
        UpdateListbookImages();
    }
}
--- End code ---
I believe the code above have some issue. :)

oBFusCATed:

--- Quote from: ollydbg on April 08, 2013, 11:30:32 am ---I believe the code above have some issue. :)

--- End quote ---
Fix it then...

ollydbg:
When the page changes, in the function void EditorConfigurationDlg::OnPageChanged(wxListbookEvent& event), there is some code snippet called, which "de-select" the icon.

--- Code: ---    if (GetSettingsIconsStyle(lb->GetListView()) != sisNoIcons)
        lb->GetListView()->Select(sel, false);

--- End code ---

But when the user click on the icon again, no On Page changed event will be sent, so the icon is select by default(so you see the third screen shot). Is there any way to change this? I guess it should be done in EVT_LIST_ITEM_SELECTED(id, func) of the wxListCtrl class, but is that possible? I have no idea.

ollydbg:
This is the patch to fix such issue, it just hook the list item select event and deselect it to avoid showing the shadow, any comments?


--- Code: ---Index: editorconfigurationdlg.cpp
===================================================================
--- editorconfigurationdlg.cpp (revision 8972)
+++ editorconfigurationdlg.cpp (working copy)
@@ -282,6 +282,7 @@
     lb->AssignImageList(images);
     int sel = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/environment/settings_size"), 0);
     SetSettingsIconsStyle(lb->GetListView(), (SettingsIconsStyle)sel);
+    lb->GetListView()->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EditorConfigurationDlg::ListItemSelected), NULL, this);
 
     // add all plugins configuration panels
     AddPluginPanels();
@@ -299,6 +300,9 @@
 
 EditorConfigurationDlg::~EditorConfigurationDlg()
 {
+    wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
+    lb->GetListView()->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EditorConfigurationDlg::ListItemSelected), NULL, this);
+
     if (m_Theme)
         delete m_Theme;
 
@@ -361,6 +365,14 @@
     XRCCTRL(*this, "pnlTitleInfo", wxPanel)->Layout();
 }
 
+void EditorConfigurationDlg::ListItemSelected(wxListEvent& event)
+{
+    wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
+    int sel = lb->GetSelection();
+    lb->GetListView()->Select(sel, false);
+    event.Skip();
+}
+
 void EditorConfigurationDlg::OnPageChanged(wxListbookEvent& event)
 {
     // update only on real change, not on dialog creation
Index: editorconfigurationdlg.h
===================================================================
--- editorconfigurationdlg.h (revision 8972)
+++ editorconfigurationdlg.h (working copy)
@@ -50,6 +50,7 @@
         void EndModal(int retCode);
     private:
         void OnPageChanged(wxListbookEvent& event);
+        void ListItemSelected(wxListEvent& event);
         void AddPluginPanels();
         void UpdateListbookImages();
         void CreateColoursSample();


--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version