src/radiobutton.cpp

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2006 by Kirill Kolodyazhniy.
00003 * See the file "license.terms" for information on usage and redistribution
00004 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00005 */
00006 
00007 #include "stdinc.h"
00008 #include "icon.h"
00009 #include "eventhandler.h"
00010 #include "widgets.h"
00011 #include "menu.h"
00012 #include "widget.h"
00013 #include "radiobutton.h"
00014 #include "exception.h"
00015 namespace MWidgets
00016 {
00017 
00018         /*******************************************************************************/
00019         RadioButton::RadioButton():Widget()
00020         {
00021         };
00022         /*******************************************************************************/
00023         void RadioButton::Create(Widget *parent,int x,int y,int w,int h,string caption)
00024         {
00025                 Widget::Create(x,y,w,h,caption,"BUTTON",WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP|WS_CLIPSIBLINGS,parent->GetHwnd());
00026         };
00027         /*******************************************************************************/
00028         void RadioButton::OnCommand( WORD code,WORD  )
00029         {
00030                 if(code==BN_CLICKED)
00031                 {
00032                         if(GetCheked()==FALSE)
00033                                 SetCheked();
00034                 };
00035         };
00036         /*******************************************************************************/
00037         BOOL RadioButton::GetCheked()
00038         {
00039                 LRESULT rez=SendMessage(m_hWnd,BM_GETCHECK,0,0);
00040                 return (rez==BST_CHECKED);
00041         };
00042         /*******************************************************************************/
00043         BOOL CALLBACK RadioButton::EnumChildProc(HWND hwnd,LPARAM lParam)
00044         {
00045                 WINDOWINFO wi;
00046                 wi.cbSize=sizeof(WINDOWINFO);
00047                 GetWindowInfo(hwnd,&wi);
00048                 if((wi.dwStyle&BS_RADIOBUTTON)==BS_RADIOBUTTON)
00049                         SendMessage(hwnd,BM_SETCHECK,lParam,0);
00050                 return TRUE;
00051         };
00052         /*******************************************************************************/
00053         void RadioButton::SetCheked()
00054         {
00055                 HWND hwndPar=GetParent();
00056                 EnumChildWindows(hwndPar,EnumChildProc,BST_UNCHECKED);
00057                 SendMessage(m_hWnd,BM_SETCHECK,BST_CHECKED,0);
00058         };
00059         /*******************************************************************************/
00060         WIDGET_TYPE RadioButton::GetType()
00061         {
00062                 return RADIOBUTTON;
00063         };
00064         /*******************************************************************************/
00065 };

Generated on Thu Oct 26 13:47:45 2006 for MWidgets by  doxygen 1.4.7