<html><head>
<script>
 (function () {
  var swapper = function (a,r,e) {
   var x = a[e];
   a[e] = a[r];
   a[r] = x;
  };
  Array.prototype.shuffle = function () {
   var i,L;
   i = L = this.length;
   while (i--) swapper(this,Math.floor(Math.random()*L),i);
  };
  Array.prototype.each = function(fun)
  {
   if (typeof(fun) != "function") throw new TypeError();
   var thisp = arguments[1];
   for (var key in this){
    if(typeof(this[key])=="function") continue;
    fun.call(thisp, key, this[key]);
   }
  };
 })();

 var words = new Array();
 var fid=document.getElementById;
 var BORDER_STYLE_CLEAR="2px solid #FFFFFF";
 var BORDER_STYLE_OVER="2px solid #FFCC00";

 onload=function(){
  initImage();
  doProcess();
 }

 function initImage(){
  words.push("bend.jpg");
  words.push("carry.jpg");
  words.push("catch.jpg");
  words.push("climb.jpg");
  words.push("crawl.jpg");
  words.shuffle();
 }

 function clearMemo(imgObj){
  fid("MEMO").innerHTML="";
  imgObj.style.border = BORDER_STYLE_CLEAR;
 }

 function printMemo(imgObj){
  var fileNameArr=imgObj.src.split("/");
  var fileName=fileNameArr[fileNameArr.length-1];
  var name=fileName.split(".")[0].replace(".*/","");
  fid("MEMO").innerHTML=name+"<img src='"+fileName+"' align=top>";
  imgObj.style.border = BORDER_STYLE_OVER;

  // style="background: url(http://source.img) no-repeat; margin-left: 20px; padding: 10px; width:300px; height:200px;" >
 }

 function doProcess(){
  var str = "";

  words.each( function(key, value){

   str = str + "<img src='" + value + "' " +
    " onmouseover='printMemo(this)' " +
    " onmouseout='clearMemo(this)' " +
    " style='border:"+BORDER_STYLE_CLEAR+";height:64px;'>";

  });


  // 참고: http://www.w3schools.com/tags/tag_IMG.asp


  fid("SUMNAIL").innerHTML = str;
 }

  </script>
 </HEAD>

 <BODY>
 <div id="MEMO" style="font-size:24pt;height=200px"></div>
 <div id="SUMNAIL"></div>
 </BODY>
</HTML>

Posted by stekilove
,
<HTML>
<HEAD>
  <TITLE> Steki's Dynamic Button Making </TITLE>
  <script>

    var StekiUtil={
        fid:function(id)
        {
            return document.getElementById(id);
        }

        , addEventListenerById:function( objId, evtName, fuc )
        {
            StekiUtil.addEventListenerByObject(StekiUtil.fid(objId), evtName, fuc );
        }

        , addEventListenerByObject:function( obj, evtName, fuc )
        {
            if (obj.addEventListener)
            {
                obj.addEventListener(evtName, fuc, false);
            }
            else
            {
                obj.attachEvent("on" + evtName, fuc);
            }

            if(evtName=="click" && obj){
                obj.style.cursor=obj.addEventListener?"pointer":"hand";
            }
        }
    }

    function MyButton(id, func ){
        this.myButton = document.createElement("input");
        this.myButton.name = id;
        this.myButton.value = id;
        this.myButton.type = "button";
        StekiUtil.fid(id).appendChild(this.myButton);
        StekiUtil.addEventListenerByObject(this.myButton,"click", func );

        this.setValue = function(value){
            this.myButton.value=value;
        };
    }

    function onMyButtonClick()
    {
        alert('hi_button_2');
    }

    function initComponent(){

        new MyButton("myButton_1", function (){ alert('hi_button_1'); } );

        var myButton2 = new MyButton("myButton_2", onMyButtonClick );
        myButton2.setValue("Button click");


        StekiUtil.addEventListenerById("myImgButton","click", function(){ alert('hi_img_button'); } );

    }

    onload=function(){
        initComponent();
    }

  </script>

</HEAD>

<BODY>
  <span id="myButton_1"></span>
  <br>
  <span id="myButton_2"></span>
  <br>
  <img src="http://sstatic.naver.com/search/images11/btn_gnb_login.gif" id="myImgButton">

 </BODY>
</HTML>
Posted by stekilove
,
#!/usr/bin/ruby -w

fileName="파일명"
splitSize=60000

begin
    counter=0
    f=nil
    file = File.new(fileName, "r")
    while (line = file.gets)
        if(counter.modulo(splitSize)==0)
          f.close if f != nil
          f=File.open(fileName+".#{counter/splitSize}",'w')
          puts "#{counter}"
        end
        f.write(line)
        counter = counter + 1
      end
      f.close
    file.close
rescue => err
    puts "Exception: #{err}"
    err
end

Posted by stekilove
,
wxWidgets 에 zip 과 png, jpg 추가 하기

============================================
image 추가

#include "wx/wx.h"

bool MyApp::OnInit()
{
#if wxUSE_LIBPNG
    wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
    wxImage::AddHandler(new wxJPEGHandler);
#endif


============================================
zip 추가

#include "wx/fs_zip.h"

bool MyApp::OnInit()
{
    wxFileSystem::AddHandler(new wxZipFSHandler);
Posted by stekilove
,
wxWidgets 에서 sound call

#include "wx/sound.h"
#include "wx/numdlg.h"

bool MyFrame::playAsyncOnStack()
{
    wxString sndFile=wxString("9000g.wav");
    wxBusyCursor busy;
    wxSound snd(sndFile);
    if (snd.IsOk()) snd.Play(wxSOUND_ASYNC);
    return snd.IsOk();
}
Posted by stekilove
,
wxWidgets 에서 wxHtmlWindow 에
tag를 추가 하는 cpp 만들기.

#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#if wxUSE_HTML && wxUSE_STREAMS

#ifndef WX_PRECOMP
    #include "wx/textctrl.h"
    #include "wx/html/htmlwin.h"
    #include "wx/html/m_templ.h"
#endif

TAG_HANDLER_BEGIN(MYBIND, "MYBIND")

TAG_HANDLER_PROC(tag)
{
    wxWindow *wnd;
    int ax, ay;
    int fl = 0;

    tag.ScanParam(wxT("X"), wxT("%i"), &ax);
    tag.ScanParam(wxT("Y"), wxT("%i"), &ay);

    if (tag.HasParam(wxT("FLOAT"))) fl = ax;

    wnd = new wxTextCtrl(
        m_WParser->GetWindow(),
        wxID_ANY,
        tag.GetParam(wxT("NAME")),
        wxPoint(0,0),
        wxSize(ax, ay),
        wxTE_MULTILINE
    );

    wnd->Show(true);

    m_WParser->GetContainer()->InsertCell(new wxHtmlWidgetCell(wnd, fl));

    return false;
}

TAG_HANDLER_END(MYBIND)



TAGS_MODULE_BEGIN(MyBind)

    TAGS_MODULE_ADD(MYBIND)

TAGS_MODULE_END(MyBind)


#endif
Posted by stekilove
,

wxWidgets 에서 wxHtmlWindow 를 사용해서
나만의 custom tag를 만들어서 event를 추가 했다.
초보적인 접근 방법이라 부끄럽다. -_-;;

class MyFrame : public wxFrame
{
public:
    <<생략>>
    void OnClicked(wxCommandEvent& event){

         if(event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ){
             wxMessageBox(((wxButton *)event.GetEventObject())->GetLabel() );
         }
        
    };
}

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    <<생략>>
    EVT_BUTTON (wxID_OK, MyFrame::OnClicked)
END_EVENT_TABLE()




================================================[ wxHtmlWindow 사용시 ]
/*


TAG HANDER FOR 'MYBUTTON' TAG


*/

 
TAG_HANDLER_BEGIN(MYBUTTON, "MYBUTTON")
   
    TAG_HANDLER_PROC(tag)
    {
        wxWindow *wnd;
        int ax, ay;
        int fl = 0;
       
        tag.ScanParam(wxT("X"), wxT("%i"), &ax);
        tag.ScanParam(wxT("Y"), wxT("%i"), &ay);
       
        wnd = new wxButton(m_WParser->GetWindow(),
                                      wxID_OK,
                                      tag.GetParam(wxT("NAME")),
                                      wxPoint(ax, ay));
        wnd->Show(true);
   
        m_WParser->GetContainer()->InsertCell(new wxHtmlWidgetCell(wnd, fl));
   
        return false;
    }

TAG_HANDLER_END(MYBUTTON)

TAGS_MODULE_BEGIN(MyButton)
    TAGS_MODULE_ADD(MYBUTTON)
TAGS_MODULE_END(MyButton)



======================================[ html ]
<myButton name="voice" x=100 y=30>
<myButton name="korean" x=100 y=30>


======================================[연구]
wxButton을 상속받아서
html element의 속성 ( 예. id, name, value 등 )을
설정할 수 있는 field를 추가 해 보자.

IMG, MAP, AREA등 괜찮은 html 구현 소스가 있는 곳
   http://stuff.mit.edu/afs/sipb/project/vlcplayer/src/wxGTK-2.8.7/src/html/
Posted by stekilove
,
wxWidgets 2.9.0

Dev-C++ 에서 컴파일 시 parameter 순서. ^^;;
html을 사용할 때 아래와 같이 했었다.
불필요한 library들도 있긴 하지만
앞으로 모든 것을 적용한다는 가정 하에 남겨 두었다.

==========================================
-s -mthreads -mwindows

-lwx_mswu_html-2.9

-lwx_mswu_core-2.9
-lwx_baseu-2.9

-lwx_mswu_gl-2.9
-lwx_baseu_net-2.9
-lwx_baseu_xml-2.9

-lwx_mswu_richtext-2.9

-lwx_mswu_aui-2.9
-lwx_mswu_adv-2.9
-lwx_mswu_xrc-2.9
-lwx_mswu_media-2.9
-lwx_mswu_propgrid-2.9
-lwx_mswu_qa-2.9

-lwxexpat-2.9
-lwxjpeg-2.9
-lwxpng-2.9
-lwxregexu-2.9
-lwxtiff-2.9
-lwxzlib-2.9
-lwxscintilla-2.9

-lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32

==========================================================

wxwidgets library map
wxwidgets 2.9.0 devpack 구한 곳

Posted by stekilove
,
wxWidgets

wxHtmlWindow 상속받아서
OnLinkClicked 를 overriding 해 본다.

==================== 클래스 =========================
class MyHtmlWin : public wxHtmlWindow {
public:
    MyHtmlWin(){}
    MyHtmlWin( wxWindow *parent ) : wxHtmlWindow( parent ){}
    ~MyHtmlWin(){}
    virtual void OnLinkClicked(const wxHtmlLinkInfo& link)
    {
        wxString msg;
        msg.Append(wxString("link to [")).Append(link.GetHref()).Append(wxString("]"));
          
        wxString msgTitle;
        msgTitle.Printf(_T("Message (%s)"), wxVERSION_STRING );
        wxMessageBox(msg, msgTitle, wxOK | wxICON_INFORMATION, this);

        wxHtmlWindow::OnLinkClicked(link);
      
    }
};

==================== 사용 =========================
MyHtmlWin *html;

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
     html = new MyHtmlWin(this);
    html -> SetRelatedFrame(this, _("HTML : %s"));   
    html -> SetRelatedStatusBar(0);  // 상태바
    html -> LoadPage(wxT("start.htm"));
Posted by stekilove
,


참고사이트: Design Patterns Implementation in a Storage Explorer Application

복잡한 uml을 보니 기분이 좋아져서 글을 올렸다.




Posted by stekilove
,