태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

Search results for '지적유희'

gtkmm + Glade3 을 이용한 간단한 예제 프로그램.

2008/04/27 00:00
참고페이지 ->

http://gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/chapter-libglademm.html


실행화면 ->

사용자 삽입 이미지









Glade3 실행 ->

사용자 삽입 이미지


생성된 Glade 파일 ->





사용된 예제 코드 ->

#include "stdafx.h"
#include <gtkmm.h>
#include <libglademm.h>
#include <iostream>
#include <windows.h>
#include <direct.h>

Gtk::Dialog* pDialog = 0; Glib::ustring g_ustrFilePath;
void on_button_clicked() {     if(pDialog)         pDialog->hide(); //hide() will cause main::run() to end. }
int main (int argc, char *argv[]) {     Gtk::Main kit(argc, argv);
    // 현재 실행파일의 경로를 구함.     {         char buf[256] = {0,};         strncpy(buf, argv[0], strlen(argv[0])-strlen(strrchr(argv[0],'\\'))+1);         g_ustrFilePath=buf;     }
    //Load the Glade file and instiate its widgets:     Glib::RefPtr<Gnome::Glade::Xml> refXml;     try     {         refXml = Gnome::Glade::Xml::create(g_ustrFilePath+"test.glade");     }    catch(const Gnome::Glade::XmlError& ex)     {         std::cerr << ex.what() << std::endl;         return 1;     }
    //Get the Glade-instantiated Dialog:     refXml->get_widget("DialogBasic", pDialog);     if(pDialog)     {         //Get the Glade-instantiated Button, and connect a signal handler:         Gtk::Button* pButton = 0;         refXml->get_widget("Exit", pButton);         if(pButton)         {             pButton->signal_clicked().connect( sigc::ptr_fun(on_button_clicked) );                  }         kit.run(*pDialog);     }     return 0; }


glade파일과 코드를 함께 보면 그다지 어렵지는 않다.

개념적인 부분은 이미 번역되어있는 GTK+ 문서를 활용하자.

http://wiki.kldp.org/wiki.php/LinuxdocSgml/GtkTutorial-TRANS  같은 것들.
크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 지적유희/gtkmm gtkmm

  1. Blog Icon
    루나

    댓글.......ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

  2. 댓글에 성의좀..ㅠㅜ

  3. Blog Icon
    zin
  4. 우분투에서 해 보면 재밌겠당;;

    오사카 들렀다감~~

gtkmm 시작하기 - 개발환경 구축

2008/04/26 22:53



본인의 개발환경 -

Windows XP 32Bit.
MSVC8 (2005)


예전같았으면 mingw로 우기고 나갔겠지만

그냥 디버깅이 용이한 msvc로 간다.


GTK+ 설치 -

http://gladewin32.sourceforge.net/

GTK+ 와 glade3 등 통합 버전이다.

glade3는 gui 툴로서 사용자가 생성한 UI를 XML로 추출해준다.

UI는 코드로 작성하지 않고 glade를 이용할 계획이다.



gtkmm 설치 -

http://gtkmm.org/download.shtml


win32버전의 경우 2008년 4월 26일 현재
http://ftp.gnome.org/pub/gnome/binaries/win32/gtkmm/2.10/
http://ftp.gnome.org/pub/gnome/binaries/win32/gtkmm/2.10/gtkmm-win32-devel-2.10.11-1.exe
가 가장 최신이다.



MSVC8 설정 -

이것도 직접 설명하기보다는 링크를 보는게 좋을듯.

http://gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-visual-studio-new-project.html#figure-msvc-new-project



샘플코드 -

#include <gtkmm.h>

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    Gtk::Window window;
    Gtk::Main::run(window);    
    return 0;
}


혹여나 Compile할때 cairo.lib 를 못찾는 경우가있다.
정확히 말하자면 cairo.lib가 없다.


http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev-1.6.4-1.zip





앞으로 참고할 페이지들..


http://gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/index.html

http://magazin.c-plusplus.de/artikel/GTKmm%20Tutorial%20Teil%201

http://www.pebble.org.uk/programming/libglademm_simple

크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 지적유희/gtkmm gtkmm

gtkmm를 시작하며.

2008/04/26 21:03




참고 -

이 카테고리는
한글번역이나 강좌를 목적으로 시작하는것이 아니며,
개인적인 공부를 위해 쓰여질 것이다.

굳이 이유를 말하자면 본인도 이제 막 시작하는 단계이고
남을 가르칠 능력도, 번역할 만한 영어실력도 없다.

허나, 조금이나마 정보공유 혹은 차후를 위해 최대한 친절하게 포스팅 할 계획임을 밝혀둔다.






공식 사이트 - http://gtkmm.org

gtkmm is the official C++ interface for the popular GUI library GTK+. Highlights include typesafe callbacks, and a comprehensive set of widgets that are easily extensible via inheritance. You can create user interfaces either in code or with the Glade User Interface designer, using libglademm. There's extensive documentation, including API reference and a tutorial.

gtkmm is free software distributed under the GNU Library General Public License (LGPL).

gtkmm follows the official GNOME Platform Bindings release schedule. This guarantees API/ABI-stability and new releases on a predictable schedule, delivering C++ API for the underlying GTK+ and GNOME APIs as soon as possible.


다른거 업ㅂ고 GTK+를 C++로 바인딩한것이 GTK-- 이다.
간단히 gtkmm 으로 부른다.


GTK+에 대한 내용은 내가 직접 서술하는것보다는

http://www.gnome.or.kr/web/default/58

를 참고하길 바라며,

기본적인 GTK+ 튜토리얼은

http://wiki.kldp.org/wiki.php/LinuxdocSgml/GtkTutorial-TRANS
(한글, but 1.x)

를 참고하거나

http://library.gnome.org/devel/gtk-tutorial/stable/
(영문, 2.0)

를 참고하라.

아쉽게도 한글번역은 1.x버전이고,

영문은 2.0 을 기준으로 쓰여졌다.

(물론 본인도 말했다시피 시작하는 단계라 제대로 읽어보지는 않았다.)


크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 지적유희/gtkmm gtkmm

  1. Blog Icon
    Only

    나좀가르쳐줏메♡

오늘 만들어본 2진수 -> 10진수 변환..

2007/11/27 23:55



사용자 삽입 이미지


DC프갤에서 공대안습 낚시를 목표로 짠것.



: 제곱 ( n1 n2 -- n1^n2 )
    1 swap 0
    ?do
        over *
    loop
    swap drop
;

: 입력 ( -- 0|1 ..... 0|1 len )
    0 >r cr ." 2진수 입력 : "
    begin
        key r> 1 + >r dup emit [char] 0 -
        dup 0 2 within invert
    until
    drop cr r> 1 -
;

: 처리 ( 0|1 ..... 0|1 len -- n1 )
    0 swap 0
    do
        swap 2 i 제곱 * +
    loop ;

: 출력 ." 10진수는 " . cr ;

: 변환 입력 처리 출력 ;




별거 없는 코드이긴한데..

오늘 얻은 수확은..

do ... loop 따위도 리턴 스텍을 사용하는듯..
loop문 내부에서 리턴 스텍을 좀 만지작 거렸다고 꼬장 부리네;;ㄷㄷㄷ;;
게다가 리턴스텍을 남겨놓고 처리 끝내면 뻑나는구나..ㄷㄷㄷ;;


하악 패러다임이 너무 달라~

프로그래밍 언어에 대한 개념이 달라지는듯..

algol-like 언어에서 벗어나기가 이다지도 힘든가..



크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 지적유희/FORTH forth

FORTH #4

2007/11/23 23:33



오늘은 연산자에 대해 집고 넘어가도록 하자.


\ 뭐 여담이지만
\ forth 도움말시스템..
\ help-system <cr> 을 입력하면 모듈이 뜬다..
\ help-system <word> 를 치면 <word>에 해당하는 낱말에 대한 설명이 나온다.




Maths operations
수학 낱말들.

뭐 번역 안해줘도 되지?

+ \ n1|u1 n2|u2 -- n3|u3

Add two single precision integer numbers: n3=n1+n2. The stack comment
indicates that the operation works for both signed and unsigned numbers.


- \ n1|u1 n2|u2 -- n3|u3

Subtract two single precision integer numbers: n3=n1-n2.


* \ n1 n2 -- n3

Standard signed multiply: n3 = n1 * n2.


/ \ n1 n2 -- n3

Standard signed division operator: n3 = n1/n2.


MOD \ n1 n2 -- n3

Standard signed division operator returning the remainder: n3 = n1 mod n2.


UM* \ u1 u2 -- ud3

An unsigned multiply that produces an unsigned double result.


*/ \ n1 n2 n3 -- n4

Multiply n1 by n2 to give a double precision result, and then divide it by n3
returning the quotient. The point of this operation is to avoid loss of precision.
The ANS standard permits systems to restrict n3 to positive numbers. This
word is ideal for scaling operations, e.g. after reading an analogue to digital
converter or converting radians to degrees.
: PI \ n ?- n*pi
355 113 */
;
n1 n2 곱하고 n3으로 나눔.


UM/MOD \ ud u -- urem uquot

Perform unsigned division of double number ud by single number u and return
the remainder and quotient. In most CPU architectures that have divide
operations, the remainder is produced at the same time as the quotient. Note
that the dividend is a double number. Often used in conjunction with UM* for
scaling operations that take advantage of an intermediate double result to
preserve precision.
여기엔 안나와있지만 /mod도 있다.


NEGATE \ n1 -- n2

Negate a single precision integer number.
부정... 이라는 뜻.
음수는 양수로.
양수는 음수로.


ABS \ n -- u

If n is negative, return its positive equivalent (absolute value).
절대값


MIN \ n1 n2 -? n1|n2

Return the lesser of n1 and n2.
둘중 작은놈


MAX \ n1 n2 -? n1|n2

Return the greater of n1 and n2.
둘중 큰놈



Comparisons
비교 연산자.

In Forth there is no basic boolean type. The stack value 0 (all bits clear) is taken to
represent FALSE, while any other value is taken to represent TRUE. The stack
notation flag indicates a “well formed flag” which means that a TRUE value is
represented by all bits set, which corresponds to the number ?1 for most CPUs.
포스시스템에서는 기본적인 진위형 데이터타입이 없다. 스텍값이 0 (모든 비트가 클리어) 이면 거짓,
다른 값 (그게 뭐든간에) 이 들어있으면 참으로 인식한다.
좋은 모양의 flag는 모든 비트가 set 된 상태로서 대부분의 머신에서는 -1이다.
(왜 -1인지 이해 안되면 2의보수부터 다시공부하자.)


< \ n1 n2 -- flag

Returns true if n1<n2


> \ n1 n2 -- flag

Returns true if n1>n2


U< \ u1 u2 -- flag

Unsigned, returns true if u1<u2


U> \ u1 u2 -- flag

Unsigned, returns true if u1>u2


= \ n1 n2 -- flag

Returns true if n1=n2
C언어에서의 ==


<> \ n1 n2 -- flag

Returns true if n1 is not equal to n2
c언어에서의 !=


0= \ x1 -- flag

Returns true if x1=0.


0<> \ x1 -- flag

Returns true if x1 is not equal to 0.


WITHIN \ n1|u1 n2|u2 n3|u3 -? flag

Return TRUE if n2|u2 <= n1|u1 < n3|u3. Note the conditions. This word uses
unsigned arithmetic, so that signed compares are treated as existing on a
number circle.
n2 <= n1 < n3 인데.. 뭐 쉽게 말하면 n1이 n2이상 n3 미만이면 참.
중간값 작은값 큰값 되시겠다.n1이 사이에 끼어있으면 참임.


<= \ n1 n2 -- flag

Returns true if n1<=n2

>= \ n1 n2 -- flag

Returns true if n1>=n2


Bitwise logic
비트관련 로직.

AND \ n1 n2 -- n3

Returns n3 = n1 AND n2


OR \ n1 n2 -- n3

Returns n3 = n1 OR n2


XOR \ n1 n2 -- n3

Returns n3 = n1 XOR n2


INVERT \ n1 -- n2

Returns bitwise inverse of n1.
C언어의 ~


LSHIFT \ x1 u -- x2

Logically shift x1 by u bits left.
C언어의 <<

RSHIFT \ x1 u -- x2

Logically shift x1 by u bits right.
C언어의 >>



오늘은 여기까지.

크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 지적유희/FORTH forth