Author Topic: Led plugin  (Read 20553 times)

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Led plugin
« on: September 14, 2010, 09:47:41 pm »

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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Led plugin
« Reply #1 on: September 15, 2010, 08:34:10 am »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #2 on: September 15, 2010, 12:58:27 pm »
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
Code
wxLed (wxWindow * parent, wxWindowID id, const char * disabledColor = "000000", const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize);
to
Code
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
Code
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

Offline Cryogen

  • Regular
  • ***
  • Posts: 260
Re: Led plugin
« Reply #3 on: September 20, 2010, 12:57:07 am »
 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.
« Last Edit: September 20, 2010, 12:59:55 am by Cryogen »

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #4 on: September 21, 2010, 04:16:30 pm »
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

Offline Cryogen

  • Regular
  • ***
  • Posts: 260
Re: Led plugin
« Reply #5 on: September 22, 2010, 04:59:08 am »
 Hey Jonas,

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.
« Last Edit: September 22, 2010, 05:12:02 am by Cryogen »

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #6 on: September 22, 2010, 01:32:19 pm »
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:
Code
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Led plugin
« Reply #7 on: September 23, 2010, 08:17:38 am »
...some additional stuff for wxLed:
This:
Code
    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:
Code
    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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #8 on: September 23, 2010, 12:39:54 pm »
Hi Morten,

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

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #9 on: September 23, 2010, 01:09:53 pm »
I've added SVN support:

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

Offline Cryogen

  • Regular
  • ***
  • Posts: 260
Re: Led plugin
« Reply #10 on: September 24, 2010, 03:31:13 am »

 Hey Jonas,

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:
Code
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.

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.

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #11 on: February 25, 2013, 04:32:17 am »
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Led plugin
« Reply #12 on: February 27, 2013, 07:53:32 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Led plugin
« Reply #13 on: February 28, 2013, 01:57:29 pm »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZinnJonas

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Led plugin
« Reply #14 on: March 14, 2013, 05:19:50 am »
sorry you are right ...