News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Led plugin

Started by ZinnJonas, September 14, 2010, 09:47:41 PM

Previous topic - Next topic

ZinnJonas


Hi all,

I found an old wxCode LedCtrl and want to integrate this in one of my projects.
This was for me the Reason to read how to write a wxSmithPlugin.

One Single Led is to less for a own Plugin ;D, so i searched for more LEDCtrls
and put them together in these Plugin.

The Ctrls are:

wxLed                ( wxCode)

wxLCDWindow      ( wxCode)

wxLEDPanel         ( wxCode)

wxLEDNumberCtrl  (gizmos)




The Led and the LedPanel, don't like the Proportion flag.
The Led can't be resized it has a fixed size.

The LedPanel can also Load Images and animation and scroll them, but it doesn't work for me with the
current Propgrid.


The Link to the Plug in is:
https://sourceforge.net/projects/wxledplugin/files/wxSmithLed.zip/download

Br
Jonas

MortenMacFly

Quote from: ZinnJonas on September 14, 2010, 09:47:41 PM
I found an old wxCode LedCtrl and want to integrate this in one of my projects.
What are actually your sources for the components? If I look at e.g. the "led" component than on wxCode there is a different version in HEAD (CVS version). Also I didn't find "LedCtrl" on wxCode?! Can you clarify the exact resources including versions your 3rd party components are based on, please?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ZinnJonas

Hi,

first the LedCtrl was mine fault, because the wxCode Led is placed in a folder called LedCtrl on my computer.
LedCtr = wxLed.

wxLed, wxLCDWindow and LedPanel are from the wxCode Site.
wxLEDNumberCtrl was in the wxWidgets contrib folder.

the wxLed source was modified by me, because
so it can communicate on a simple way with wxSmith.

So I changed the Constructor
form
wxLed (wxWindow * parent, wxWindowID id, const char * disabledColor = "000000", const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize);
to
wxLed (wxWindow * parent, wxWindowID id, wxColour disabledColor = wxColour( 00,00,00), wxColour enableColour = wxColour( 00, 255, 00), const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize);

The reason is you don't need the html-Style for the Colors and you can use the
Enable flag from the wxPropgrid to draw the Led on or of.

So I had to change some small things in the other function too.

2 more Function in the source

void Disable( void);
bool IsEnabled( void);


The wxLCDWindow is nearly original
only the header was changed from
<wx/wxprec.h>
to
<wx/wx.h>

wxLEDPanel wasn't changed by me

and wxLEDNumberCtrl,
here I removed all the WXDLLIMPEXP_GIZMOS from the source.

to compile a libwx....a the other .cbp is in the folder ;D

Br
Jonas

p.s:
I'm not a English native so my english isn't the best ;D

Cryogen

#3
 Hey Jonas,

Always good to see another plug-in. :-)

I might be able to have a look for you as well, if I get some time. In the meantime, there are some nice LED controls available in wxSmithKWIC which you could play with. It's available from the wxSmithAddons link below.

Cheers,

 Cryo.
DoxyBlocks: Now in contrib. Cool, baby.
DoxyDocs: [url="http://wxsmithaddons.sourceforge.net/docs/doxyblocks/"]http://wxsmithaddons.sourceforge.net/docs/doxyblocks/[/url]
wxSmith Add-ons: [url="http://wxsmithaddons.sourceforge.net/"]http://wxsmithaddons.sourceforge.net/[/url]
Cryo's Patchorama: [url="http://forums.next.codeblocks.org/index.php/topic,12619.0.html"]http://forums.next.codeblocks.org/index.php/topic,12619.0.html[/url]

ZinnJonas

Hi,

Now the wxSmithLed is Unicode friendly ;D.
And change some Color settings etc.;D

Cryogen i know the KWIC controls, but I can't compile your wxSmithKWIC, because there are to much
you have to change, to make it run.
;D

Br
Jonas

Cryogen

#5
 Hey Jonas,

Quote from: ZinnJonas on September 21, 2010, 04:16:30 PM
Cryogen i know the KWIC controls, but I can't compile your wxSmithKWIC, because there are to much
you have to change, to make it run.
;D


Err, it should build right out of the box. I've tested it and I know Morten runs it and others have, too. What do you think you have to change? What specific problems are you encountering and what are you running on? Also, I checked in some changes over the weekend. you might like to try the latest version and see if your mileage improves.

Thanks,

 Cryo.
DoxyBlocks: Now in contrib. Cool, baby.
DoxyDocs: [url="http://wxsmithaddons.sourceforge.net/docs/doxyblocks/"]http://wxsmithaddons.sourceforge.net/docs/doxyblocks/[/url]
wxSmith Add-ons: [url="http://wxsmithaddons.sourceforge.net/"]http://wxsmithaddons.sourceforge.net/[/url]
Cryo's Patchorama: [url="http://forums.next.codeblocks.org/index.php/topic,12619.0.html"]http://forums.next.codeblocks.org/index.php/topic,12619.0.html[/url]

ZinnJonas

Hi,

My system is Win7 (64Bit), but i use Mingw 32 Bit with wxWidgets 2.8.11 and the newest svn of codeBlocks at the moment(  6620)

the changes are:

Adding wxpropgrid library to wxSmithKWIC and change the path from 
..\wxSmith\propgrid\contrib\include
to
..\..\..\sdk\wxpropgrid\include

wxsangularmeter.cpp:

void wxsAngularMeter::OnAddExtraProperties(wxsPropertyGridManager *Grid)
{
    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(0);
    #else
    Grid->SetTargetPage(0);
    #endif

    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    m_SectorCountId = Grid->Insert(wxT("Needle Colour"), new wxIntProperty(_("Number Of Sectors"), wxPG_LABEL,
    #else
    m_SectorCountId = Grid->Insert(wxT("Needle Colour"), wxIntProperty(_("Number Of Sectors"), wxPG_LABEL,
    #endif
                                                                    (int)m_arrSectors.Count()));
    for(int i = 0; i < (int)m_arrSectors.Count(); i++)
    {
        InsertPropertyForSector(Grid, i);
    }
    wxsWidget::OnAddExtraProperties(Grid);
}

void wxsAngularMeter::OnExtraPropertyChanged(wxsPropertyGridManager *Grid, wxPGId id)
{
    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(0);
    #else
    Grid->SetTargetPage(0);
    #endif
   .....

   // We have to remove some entries
            for(int i = NewValue; i < OldValue; i++)
            {
                #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
                Grid->DeleteProperty(m_arrSectors[i]->id);
                #else
                Grid->Delete(m_arrSectors[i]->id);
                #endif
                delete m_arrSectors[i];
            }
    ....
}

void wxsAngularMeter::InsertPropertyForSector(wxsPropertyGridManager *Grid, int Position)
{
    SectorDesc *Desc = m_arrSectors[Position];
    wxString SectorName = wxString::Format(_("Sector %d Colour"), Position + 1);
    wxString SectorDataName = wxString::Format(_("sector_%d_colour"), Position + 1);

    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Desc->id = Grid->Insert(wxT("Needle Colour"), new wxSystemColourProperty(SectorName, wxPG_LABEL, Desc->colour));
    #else
    Desc->id = Grid->Insert(wxT("Needle Colour"), wxSystemColourProperty(SectorName, wxPG_LABEL, Desc->colour));
    #endif
}

bool wxsAngularMeter::HandleChangeInSector(wxsPropertyGridManager *Grid, wxPGId id, int Position)
{

......
if( Grid->GetPropertyValueType( id) == _T("wxColourPropertyValue"))
{
wxColourPropertyValue* pcolval = wxDynamicCast(Grid->GetPropertyValueAsWxObjectPtr(id), wxColourPropertyValue);
Desc->colour = pcolval->m_colour;
}
Changed = true;
....

wxsangularregulator.cpp:

void wxsAngularRegulator::OnAddExtraProperties(wxsPropertyGridManager *Grid)
{
    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(0);
    #else
    Grid->SetTargetPage(0);
    #endif

    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    m_TagCountId = Grid->Insert(wxT("External Circle Colour"), new wxIntProperty(_("Number Of Tags"), wxPG_LABEL,
    #else
    m_TagCountId = Grid->Insert(wxT("External Circle Colour"), wxIntProperty(_("Number Of Tags"), wxPG_LABEL,
    #endif
                                                                    (int)m_arrTags.Count()));
....
}

void wxsAngularRegulator::OnExtraPropertyChanged(wxsPropertyGridManager *Grid, wxPGId id)
{
    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(0);
    #else
    Grid->SetTargetPage(0);
    #endif
.....
            // We have to remove some entries
            for(int i = NewValue;i < OldValue;i++)
            {
                #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
                Grid->DeleteProperty(m_arrTags[i]->id);
                #else
                Grid->Delete(m_arrTags[i]->id);
                #endif
                delete m_arrTags[i];
            }
...
}

void wxsAngularRegulator::InsertPropertyForTag(wxsPropertyGridManager *Grid, int Position)
{
    TagDesc *Desc = m_arrTags[Position];
    wxString sTagName = wxString::Format(_("Tag %d Value"), Position + 1);

    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Desc->id = Grid->Insert(wxT("External Circle Colour"), new wxIntProperty(sTagName, wxPG_LABEL, Desc->val));
    #else
    Desc->id = Grid->Insert(wxT("External Circle Colour"), wxIntProperty(sTagName, wxPG_LABEL, Desc->val));
    #endif
}



This change nearly by all the Files.

lcdclock and lcddisplay runs without changes but the bmpswitch won't work until today,
i will look at your source later;D

One Problem i can't change, at the moment, if you select one ctrl and put it in your window it isn't drawn until you resize it.
Some of the contrlos don't like to be resized like the Linearregulator and the AngularRegulator.

Br
Jonas

MortenMacFly

...some additional stuff for wxLed:
This:

    if( LedMatrixSize.X = -1)
        LedMatrixSize.X = 4;
    if( LedMatrixSize.Y = -1)
        LedMatrixSize.Y = 4;
    if( LedMatrix.X = -1)
        LedMatrix.X = 65;
    if( LedMatrix.Y = -1)
        LedMatrix.Y = 9;

Doesn't look good to me. It should read:

    if( LedMatrixSize.X [b]==[/b] -1)
        LedMatrixSize.X = 4;
    if( LedMatrixSize.Y [b]==[/b] -1)
        LedMatrixSize.Y = 4;
    if( LedMatrix.X [b]==[/b] -1)
        LedMatrix.X = 65;
    if( LedMatrix.Y [b]==[/b] -1)
        LedMatrix.Y = 9;

I found this at least at two positions. Be careful not to mix C++ with another language's syntax!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ZinnJonas

Hi Morten,

Thank you, yes i forgot the == and you need this only at one position ;D

ZinnJonas

I've added SVN support:


svn co https://wxledplugin.svn.sourceforge.net/svnroot/wxledplugin/trunk/wxSmithLed

Cryogen


Hey Jonas,

Quote from: ZinnJonas on September 22, 2010, 01:32:19 PM
My system is Win7 (64Bit), but i use Mingw 32 Bit with wxWidgets 2.8.11 and the newest svn of codeBlocks at the moment(  6620)

the changes are:

Adding wxpropgrid library to wxSmithKWIC and change the path from 
..\wxSmith\propgrid\contrib\include
to
..\..\..\sdk\wxpropgrid\include

wxsangularmeter.cpp:

void wxsAngularMeter::OnAddExtraProperties(wxsPropertyGridManager *Grid)
{
    #if wxCHECK_VERSION(2, 9, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)


Yes! My bad. I didn't realise until last weekend that I hadn't checked it in. I changed it when the propgrid version used by wxSmith changed. My apologies. That's why you need to get the latest SVN. It's fixed now.

Quote from: ZinnJonas on September 22, 2010, 01:32:19 PM
One Problem i can't change, at the moment, if you select one ctrl and put it in your window it isn't drawn until you resize it.
Some of the contrlos don't like to be resized like the Linearregulator and the AngularRegulator.

I see what you mean. That's not quite right. It's that the default control size is very small. It is drawn, there's just not much to see until you make it bigger. I spent some time looking into it but, as I recall, didn't find a way to change the default size at the time. Also, who's to say what the default size should be? All the same I'd prefer it to be a bit bigger, as well.

Cheers.
DoxyBlocks: Now in contrib. Cool, baby.
DoxyDocs: [url="http://wxsmithaddons.sourceforge.net/docs/doxyblocks/"]http://wxsmithaddons.sourceforge.net/docs/doxyblocks/[/url]
wxSmith Add-ons: [url="http://wxsmithaddons.sourceforge.net/"]http://wxsmithaddons.sourceforge.net/[/url]
Cryo's Patchorama: [url="http://forums.next.codeblocks.org/index.php/topic,12619.0.html"]http://forums.next.codeblocks.org/index.php/topic,12619.0.html[/url]

ZinnJonas

Hey after a long time a added a new Led a state Led, which can enter different states, and u can define for each state an other color.

i had added it to the svn path above, and also write 2 patches for wxSmithContribItems ( wxSmithStateLed.patch) and wxContribItems (wxLepPatch.patch)

best regrades zinnjonas

MortenMacFly

Quote from: ZinnJonas on February 25, 2013, 04:32:17 AM
best regrades zinnjonas
Thanks - I'll try to take care... :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

Quote from: ZinnJonas on February 25, 2013, 04:32:17 AM
i had added it to the svn path above, and also write 2 patches for wxSmithContribItems ( wxSmithStateLed.patch) and wxContribItems (wxLepPatch.patch)
Seem the files wxsStateLed{.cpp/.h} are missing from wxsmith contib items -> does not compile this way. :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ZinnJonas

sorry you are right ...