Example #1
0
BOOL
FooControl::handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam)
{
	if (message == CC_SPINNER_CHANGE)
	{
		one_value_local(arg);
		/* handle CC_SPINNER_CHANGE message received for this control - call my _T('changed') event handler with
		 * with the current spinner value as the argument */
		if (spin_type == EDITTYPE_INT)
		{
			value = (float)((ISpinnerControl *)lParam)->GetIVal();
			vl.arg = Integer::intern((int)value);
		}
		else
			vl.arg = Float::intern(value = ((ISpinnerControl *)lParam)->GetFVal()); 
		try
		{
			call_event_handler(ro, n_changed, &vl.arg, 1);
		}
		catch (...)
		{
   			SendMessage(GetDlgItem(ro->page, control_ID), WM_LBUTTONUP, 0, 0); // on error, force a buttonup to release the spinner
			throw;
		}
		pop_value_locals();
		return TRUE;
	}
	return FALSE;
}
Example #2
0
// ============================================================================
void AngleControl::CallChangedHandler()
{
   init_thread_locals();
   push_alloc_frame();
   one_value_local(arg);
   vl.arg = Float::intern(m_degrees);
   run_event_handler(parent_rollout, n_changed, &vl.arg, 1);
   pop_value_locals();
   pop_alloc_frame();
}
Example #3
0
LRESULT CALLBACK ish3_ProgressBar::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
   // Get back at our stored class pointer
   ish3_ProgressBar *UGC = DLGetWindowLongPtr<ish3_ProgressBar*>(hWnd);
   if(UGC == NULL && message != WM_CREATE)
      return DefWindowProc(hWnd, message, wParam, lParam);

   switch ( message ) {
   
      case WM_CREATE:
         {
            LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
            UGC = (ish3_ProgressBar*)lpcs->lpCreateParams;
            DLSetWindowLongPtr(hWnd, UGC);
            break;
         }

      case WM_MOUSEMOVE:
         {
         if(wParam && MK_LBUTTON)
         {
            init_thread_locals();
            push_alloc_frame();
            one_value_local(arg);
            // work out a positional click value and fire a 'clicked' event
            int xPos = LOWORD(lParam);
            int yPos = HIWORD(lParam);
            Rect rect;
            GetClientRect(hWnd,&rect);
            float fDelta = 0.0f;

            if(UGC->type==TYPE_HORIZ)
            {
               int rWide = (rect.right-1)-(rect.left+2);

               float Delta = 100.0f/rWide;
               fDelta = Delta*xPos;
            }
            if(UGC->type==TYPE_VERT)
            {
               int rHigh = (rect.bottom)-(rect.top);

               float Delta = 100.0f/rHigh;
               fDelta = Delta*(rHigh-yPos);
            }
            
            vl.arg = Integer::intern((int)fDelta);
            UGC->run_event_handler(UGC->parent_rollout, n_clicked, &vl.arg, 1);
            pop_value_locals();
            pop_alloc_frame();
         }

         if(UGC->enabled)
            SetCursor(LoadCursor(NULL, IDC_ARROW));
         }
      break;

      case WM_LBUTTONDOWN:
         {
            init_thread_locals();
            push_alloc_frame();
            one_value_local(arg);
            // ditto - just wanted to handle first time clicks
            int xPos = LOWORD(lParam);
            int yPos = HIWORD(lParam);
            Rect rect;
            GetClientRect(hWnd,&rect);
            float fDelta = 0.0f;

            if(UGC->type==TYPE_HORIZ)
            {
               int rWide = (rect.right-1)-(rect.left+2);

               float Delta = 100.0f/rWide;
               fDelta = Delta*xPos;
            }
            if(UGC->type==TYPE_VERT)
            {
               int rHigh = (rect.bottom)-(rect.top);

               float Delta = 100.0f/rHigh;
               fDelta = Delta*(rHigh-yPos);
            }
            
            vl.arg = Integer::intern((int)fDelta);
            UGC->run_event_handler(UGC->parent_rollout, n_clicked, &vl.arg, 1);
            pop_value_locals();
            pop_alloc_frame();
         }
         break;

	  case WM_RBUTTONUP:
		  UGC->call_event_handler(UGC->parent_rollout, n_rightClick, NULL, 0);
		  break;

      case WM_PAINT:
         {
            // begin paint cycle
            PAINTSTRUCT ps;
            HDC hdc;
            hdc = BeginPaint( hWnd, &ps );

            Rect rect;
            GetClientRect(hWnd,&rect);


            // Setup pens, brushes and colours
            SetBkColor( hdc, GetCustSysColor( COLOR_BTNFACE ) );
            SetBkMode( hdc, TRANSPARENT );   
            HPEN hLight = CreatePen( PS_SOLID, 0, GetCustSysColor( COLOR_BTNHIGHLIGHT ) );
            HPEN hBlack = (HPEN)GetStockObject(BLACK_PEN);
            HPEN hDark  = CreatePen( PS_SOLID, 0, GetCustSysColor( COLOR_BTNSHADOW ) );   

            // setup the progress bar colour, taking enabled flag into account
            HBRUSH hProgress;
            if(UGC->enabled)
             hProgress = CreateSolidBrush( UGC->colorPro );
            else hProgress = CreatePatternBrush( LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_DISABLED)) );

            HPEN hPP;
            if(UGC->enabled)
               hPP = CreatePen( PS_SOLID, 0, UGC->colorPro );
            else hPP = CreatePen( PS_SOLID, 0, GetCustSysColor( COLOR_BTNFACE ) );

            // the 'blanker' definition
            HBRUSH hProgressTerm = CreateSolidBrush( GetCustSysColor( COLOR_BTNFACE ) );
            HPEN hPT = CreatePen( PS_SOLID, 0, GetCustSysColor( COLOR_BTNFACE ) );


            // Do some 3D control drawing (frame)
            SelectObject(hdc, hDark);

            MoveToEx(hdc, rect.right-1, 0, NULL);
            LineTo  (hdc, 0, 0);
            LineTo  (hdc, 0, rect.bottom-1);

            SelectObject(hdc, hBlack);

            MoveToEx(hdc, rect.right-2, 1, NULL);
            LineTo  (hdc, 1, 1);
            LineTo  (hdc, 1, rect.bottom-2);

            SelectObject(hdc, hLight);

            MoveToEx(hdc, 0, rect.bottom-1, NULL);
            LineTo  (hdc, rect.right-1, rect.bottom-1);
            LineTo  (hdc, rect.right-1, 0 );

      // HORIZONTAL DRAW
      if(UGC->type==TYPE_HORIZ)
      {

            // prepare progress bar
            float delta = (float)((rect.right-rect.left)-1)/100.0f;
            int amt     = UGC->value;
            int draw = (int)(amt*delta);

            // handle extremities
            if(amt==100)   draw = ((rect.right-rect.left)-1);
            if(amt==0)     draw = rect.left+1;
            if(draw<=2) draw=2;


            // blit out unused to background
            if(amt!=100)
            {

               HGDIOBJ hOldPen = SelectObject(hdc, hPT);
               HGDIOBJ hOldBrush = SelectObject(hdc, hProgressTerm);
               Rectangle(hdc,draw,2,rect.right-1,rect.bottom-2);
			   SelectObject(hdc, hOldPen);
			   SelectObject(hdc, hOldBrush);
          }

            // draw progress bar
            if(amt>0)
            {
               HGDIOBJ hOldPen = SelectObject(hdc, hPP);
               HGDIOBJ hOldBrush = SelectObject(hdc, hProgress);
               Rectangle(hdc,2,2,draw,rect.bottom-2);
			   SelectObject(hdc, hOldPen);
			   SelectObject(hdc, hOldBrush);
            }
      }
      // VERTICAL DRAW
      if(UGC->type==TYPE_VERT)
      {

            // prepare progress bar
            float delta = (float)((rect.bottom-rect.top)-4)/100.0f;
            int amt     = UGC->value;
            int draw = (int)(amt*delta);

            // handle extremities
            if(amt==100)   draw = ((rect.bottom-rect.top)-4);
            if(amt==0)     draw = 0;//rect.bottom-2;

            
            // blit out unused to background
            if(amt!=100)
            {
               HGDIOBJ hOldPen = SelectObject(hdc, hPT);
               HGDIOBJ hOldBrush = SelectObject(hdc, hProgressTerm);
               Rectangle(hdc,2,rect.top+2,rect.right-2,(rect.bottom-2)-draw);
			   SelectObject(hdc, hOldPen);
			   SelectObject(hdc, hOldBrush);
            }

            // draw progress bar
            if(amt>0)
            {
               HGDIOBJ hOldPen = SelectObject(hdc, hPP);
               HGDIOBJ hOldBrush = SelectObject(hdc, hProgress);
               Rectangle(hdc,2,rect.bottom-2,rect.right-2,(rect.bottom-2)-draw);
			   SelectObject(hdc, hOldPen);
			   SelectObject(hdc, hOldBrush);
            }
      }

            DeleteObject(hLight);
            DeleteObject(hDark);
            DeleteObject(hBlack);
            DeleteObject(hPP);
            DeleteObject(hPT);
            DeleteObject(hProgress);
            DeleteObject(hProgressTerm);

            // end paint cycle
            EndPaint( hWnd, &ps );
            return 0;
         }

   }

   return TRUE;
}