コード例 #1
0
ファイル: parser.c プロジェクト: GeorgeShaw/opensips
/* Parse the include modules line */
int parse_include_line(char *line,select_menu *parent)
{
	char *p,*start=NULL,*end;
	int len = strlen(line),mod_len=0;
	int found_mod=0;

	p=memchr(line,'=',len);
	if (!p) {
		fprintf(output,"Malformed include line\n");
		return -1;
	}
	p++;

	for (;*p==' ';p++)
		;

	for (;p<line+len-1;p++) {
		switch (*p) {
			case ' ':
				if (!found_mod)
					continue;
				else {
					end=p;
					mod_len = end-start;
					/* found an included module, mark it as enabled */
					enable_item(parent,start,mod_len);
					found_mod=0;
					break;
				}
			default:
				if (found_mod)
					continue;
				else {
					start = p;
					found_mod=1;
					break;
				}
		}
	}

	if (found_mod) {
		/* We skipped the last one, enable it as well */
		mod_len = line+len-start-1;
		enable_item(parent,start,mod_len);
	}

	return 0;
}
コード例 #2
0
static int CoolBarCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC              hdc;
    PCOOLBARCTRL     TbarData;
    PCOOLBARITEMDATA pTbid;
        
    switch (message) {
        case MSG_CREATE:
        {
            DWORD data; 
            DWORD dwStyle;
            const char* caption;

            if ((TbarData = (COOLBARCTRL*) calloc (1, sizeof (COOLBARCTRL))) == NULL)
                return 1;

            TbarData->nCount = 0;
            TbarData->head = TbarData->tail = NULL;
            TbarData->BackBmp = NULL;
            TbarData->iSel = -1;
            TbarData->iMvOver = -1;
            TbarData->ShowHint = TRUE;
            TbarData->hToolTip = 0;

            ExcludeWindowStyle (hWnd, WS_BORDER);

            dwStyle = GetWindowStyle (hWnd);
            if (dwStyle & CBS_BMP_32X32) {
                TbarData->ItemWidth = 32;
                TbarData->ItemHeight = 32;
            }
            else if (dwStyle & CBS_BMP_CUSTOM) {
                data = GetWindowAdditionalData (hWnd);
                TbarData->ItemWidth = LOWORD (data);
                TbarData->ItemHeight = HIWORD (data);
            }
            else {
                TbarData->ItemWidth = 16;
                TbarData->ItemHeight = 16;
            }

            caption = GetWindowCaption (hWnd);
            if ((dwStyle & CBS_USEBKBMP) && caption [0]) {
                TbarData->BackBmp = (BITMAP*)calloc (1, sizeof (BITMAP));
                if (LoadBitmap (HDC_SCREEN, TbarData->BackBmp, caption) < 0) {
                    free (TbarData->BackBmp);
                    TbarData->BackBmp = NULL;
                    break;
                }
            }
            SetWindowAdditionalData2 (hWnd, (DWORD)TbarData);
        }
        break;

        case MSG_DESTROY:
        { 
            COOLBARITEMDATA* unloaddata, *tmp;
            TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd);
            if (TbarData->hToolTip != 0) {
                DestroyToolTipWin (TbarData->hToolTip);
                TbarData->hToolTip = 0;
            }

            if (TbarData->BackBmp) {
                UnloadBitmap (TbarData->BackBmp);
                free (TbarData->BackBmp);
            }

            unloaddata = TbarData->head;
            while (unloaddata) {
                tmp = unloaddata->next;
                free (unloaddata);
                unloaddata = tmp;
            }

            free (TbarData);
        }
        break;

        case MSG_SIZECHANGING:
        {
            const RECT* rcExpect = (const RECT*)wParam;
            RECT* rcResult = (RECT*)lParam;

            TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd);

            rcResult->left = rcExpect->left;
            rcResult->top = rcExpect->top;
            rcResult->right = rcExpect->right;
            rcResult->bottom = rcExpect->top + TbarData->ItemHeight + 8;
            return 0;
        }

		case MSG_SIZECHANGED:
		{
			RECT* rcWin = (RECT*)wParam;
			RECT* rcClient = (RECT*)lParam;
			*rcClient = *rcWin;
			return 1;
		}

        case MSG_NCPAINT:
            return 0;

        case MSG_PAINT:
        {
            TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd);
            hdc = BeginPaint (hWnd);
            DrawCoolBox (hWnd, hdc, TbarData);
            EndPaint (hWnd, hdc);
            return 0;
        }

        case CBM_ADDITEM:
        {
            COOLBARITEMINFO* TbarInfo = NULL;
            COOLBARITEMDATA* ptemp;
            RECT rc;

            TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2 (hWnd);
            TbarInfo = (COOLBARITEMINFO*) lParam;

            if (!(ptemp = (COOLBARITEMDATA*)calloc (1, sizeof (COOLBARITEMDATA)))) {
                return -1;
            }

            GetClientRect (hWnd, &rc);

            ptemp->id = TbarInfo->id;
            ptemp->Disable = 0;
            ptemp->ItemType = TbarInfo->ItemType;

            if (TbarInfo->ItemHint) {
                strncpy (ptemp->Hint, TbarInfo->ItemHint, LEN_HINT);
                ptemp->Hint [LEN_HINT] = '\0';
            }
            else
                ptemp->Hint [0] = '\0';

            if (TbarInfo->Caption) {
                strncpy (ptemp->Caption, TbarInfo->Caption, LEN_TITLE);
                ptemp->Caption [LEN_TITLE] = '\0';
            }
            else
                ptemp->Caption [0] = '\0';
             
            ptemp->Bmp = TbarInfo->Bmp;

            set_item_rect (hWnd, TbarData, ptemp); 

            ptemp->next = NULL;
            if (TbarData->nCount == 0) {
                TbarData->head = TbarData->tail = ptemp;
            }
            else if (TbarData->nCount > 0) { 
                TbarData->tail->next = ptemp;
                TbarData->tail = ptemp;
            }
            ptemp->insPos = TbarData->nCount;
            TbarData->nCount++;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;
        }

        case CBM_ENABLE:
            TbarData = (PCOOLBARCTRL)GetWindowAdditionalData2 (hWnd);
            if (enable_item (TbarData, wParam, lParam))
                return -1;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;

        case MSG_LBUTTONDOWN:
        {         
             int posx, posy;
             TbarData=(PCOOLBARCTRL) GetWindowAdditionalData2(hWnd);

             posx = LOSWORD (lParam);
             posy = HISWORD (lParam);

             if (GetCapture () == hWnd)
                break;
             
             SetCapture (hWnd);
                         
             if ((pTbid = GetCurTag (posx, posy, TbarData)) == NULL)
                break; 
             
             TbarData->iSel = pTbid->insPos;
             break;
        }

        case MSG_LBUTTONUP:
        { 
            int x, y;
            TbarData = (PCOOLBARCTRL)GetWindowAdditionalData2(hWnd);
            x = LOSWORD(lParam);
            y = HISWORD(lParam);
                      
            if (GetCapture() != hWnd)
               break;
            ReleaseCapture ();

            ScreenToClient (hWnd, &x, &y);

            if ((pTbid = GetCurTag(x, y, TbarData)) == NULL) {
                break;
            }
          
            if (TbarData->iSel == pTbid->insPos && !pTbid->Disable)
                NotifyParent (hWnd, GetDlgCtrlID(hWnd), pTbid->id);

            TbarData->iSel = -1;
            break;
        }

        case MSG_MOUSEMOVE:
        {  
            int x, y;
            TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd);
            x = LOSWORD(lParam);
            y = HISWORD(lParam);

            if (GetCapture() == hWnd)
                ScreenToClient (hWnd, &x, &y);
                
            if ((pTbid = GetCurTag (x, y, TbarData)) == NULL) {
                unhilight (hWnd);
                break;
            }

            if (TbarData->iMvOver == pTbid->insPos)
               break;

            unhilight (hWnd);
            TbarData->iMvOver = pTbid->insPos;
            hilight (hWnd, TbarData, pTbid);
            break;
        }
        
        case MSG_MOUSEMOVEIN:
            if (!wParam)
                unhilight (hWnd);   
            break;

        case MSG_NCLBUTTONDOWN:
        case MSG_KILLFOCUS:
            unhilight (hWnd);   
            break;
    }

    return DefaultControlProc (hWnd, message, wParam, lParam);
}
コード例 #3
0
ファイル: coolIndicator.cpp プロジェクト: thatking/camdroid
static int CoolIndicatorCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC              hdc;
    PCOOL_INDICATOR_CTRL TbarData;
        
	//db_msg("message is %s, wParam: 0x%x, lParam: 0x%lx\n", Message2Str(message), wParam, lParam);
    switch (message) {
    case MSG_CREATE:
		{
			DWORD data; 
            DWORD dwStyle;

			//db_info("Cool Indicator ctrl proc\n");
            if ((TbarData = (COOL_INDICATOR_CTRL*) calloc (1, sizeof (COOL_INDICATOR_CTRL))) == NULL)
                return 1;

            TbarData->nCount = 0;
            TbarData->head = TbarData->tail = NULL;
            TbarData->BackBmp = NULL;
            TbarData->iSel = 0;
            TbarData->hToolTip = 0;

            //ExcludeWindowStyle (hWnd, WS_BORDER);

            dwStyle = GetWindowStyle (hWnd);
            if (dwStyle & CBS_BMP_CUSTOM) {
                data = GetWindowAdditionalData (hWnd);
                TbarData->ItemWidth = LOWORD (data);
                TbarData->ItemHeight = HIWORD (data);
				int screenW,screenH;
				getScreenInfo(&screenW,&screenH);
                TbarData->ItemHeight = 	screenH/8;
            }
            else {
                TbarData->ItemWidth = 16;
                TbarData->ItemHeight = 16;
            }

            SetWindowAdditionalData2 (hWnd, (DWORD)TbarData);
		}
		break;

	case MSG_DESTROY:
        { 
            COOL_INDICATOR_ITEMDATA* unloaddata, *tmp;
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);
            if (TbarData->hToolTip != 0) {
                DestroyCdrToolTipWin(TbarData->hToolTip);
                TbarData->hToolTip = 0;
            }

            if (TbarData->BackBmp) {
                UnloadBitmap (TbarData->BackBmp);
                free (TbarData->BackBmp);
            }

            unloaddata = TbarData->head;
            while (unloaddata) {
                tmp = unloaddata->next;
                free (unloaddata);
                unloaddata = tmp;
            }

            free (TbarData);
        }
        break;
	
	case MSG_SHOWWINDOW:
		{
			if(wParam == SW_SHOWNORMAL) {
				enable_hint = TRUE;
			} else {
				enable_hint = FALSE;
			}
		}
		break;

	case MSG_SIZECHANGING:
        {
            const RECT* rcExpect = (const RECT*)wParam;
            RECT* rcResult = (RECT*)lParam;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);

            rcResult->left = rcExpect->left;
            rcResult->top = rcExpect->top;
            rcResult->right = rcExpect->right;
            rcResult->bottom = rcExpect->top + TbarData->ItemHeight + 14;
            return 0;
        }
		break;

	case MSG_SIZECHANGED:
		{
			RECT* rcWin = (RECT*)wParam;
			RECT* rcClient = (RECT*)lParam;
			*rcClient = *rcWin;
			return 1;
		}
		break;

	case MSG_FONTCHANGED:
		{
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);

			PLOGFONT logfont = GetWindowFont(hWnd);
			//db_msg("MSG_FONTCHANGED, type :%s, familyt: %s, charset: %s\n", logfont->type, logfont->family, logfont->charset);
			if(TbarData != NULL && TbarData->hToolTip != 0) {
				SetWindowFont(TbarData->hToolTip, logfont );
			}
		}
		break;

    case MSG_NCPAINT:
        return 0;

	case MSG_PAINT:	//todo: why MSG_PAINT is received early than MSG_CREATE?
        {
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);
			if (TbarData == NULL) {
				break;
			}
            hdc = BeginPaint (hWnd);

			PLOGFONT logfont = GetWindowFont(hWnd);

			SelectFont(hdc, logfont );
            DrawCoolBox (hWnd, hdc, TbarData);
            EndPaint (hWnd, hdc);
            return 0;
        }
		break;

	case CBM_ADDITEM:
        {
            COOL_INDICATOR_ITEMINFO* TbarInfo = NULL;
            COOL_INDICATOR_ITEMDATA* ptemp;
            RECT rc;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);
            TbarInfo = (COOL_INDICATOR_ITEMINFO*) lParam;

            if (!(ptemp = (COOL_INDICATOR_ITEMDATA*)calloc (1, sizeof (COOL_INDICATOR_ITEMDATA)))) {
                return -1;
            }

            GetClientRect (hWnd, &rc);

			//db_msg("add item id is %d\n", TbarInfo->id);
            ptemp->id = TbarInfo->id;
            ptemp->Disable = 0;
            ptemp->ItemType = TbarInfo->ItemType;
			ptemp->sliderColor = TbarInfo->sliderColor;

           // if (TbarInfo->ItemHint) {
            //    strncpy (ptemp->Hint, TbarInfo->ItemHint, LEN_HINT);
            //    ptemp->Hint [LEN_HINT] = '\0';
            //}
           // else
                ptemp->Hint [0] = '\0';

            if (TbarInfo->Caption) {
                strncpy (ptemp->Caption, TbarInfo->Caption, LEN_TITLE);
                ptemp->Caption [LEN_TITLE] = '\0';
            }
            else
                ptemp->Caption [0] = '\0';
             
            ptemp->Bmp = TbarInfo->Bmp;

            set_item_rect (hWnd, TbarData, ptemp); 

            ptemp->next = NULL;
            if (TbarData->nCount == 0) {
                TbarData->head = TbarData->tail = ptemp;
            }
            else if (TbarData->nCount > 0) { 
                TbarData->tail->next = ptemp;
                TbarData->tail = ptemp;
            }
            TbarData->nCount++;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;
        }
		break;

	case CBM_CLEARITEM:
		{
            COOL_INDICATOR_ITEMINFO* TbarInfo = NULL;
            COOL_INDICATOR_ITEMDATA *ptemp1, *ptemp2;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);
            TbarInfo = (COOL_INDICATOR_ITEMINFO*) lParam;

			ptemp1 = TbarData->head;
            while (ptemp1) {
                ptemp2 = ptemp1->next;
				ptemp1->next = NULL;
                free (ptemp1);
                ptemp1 = ptemp2;
            }
			TbarData->head = TbarData->tail = NULL;
            TbarData->nCount = 0;
			TbarData->iSel = 0;
		}
		break;

	case CBM_SWITCH2NEXT:
		{
			TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);

			TbarData->iSel++;
			if(TbarData->iSel >= TbarData->nCount) {
				TbarData->iSel = 0;
			}
			db_info("switch to next, iSel is %d\n", TbarData->iSel);
            InvalidateRect (hWnd, NULL, TRUE);
		}
		break;

	case CBM_ENABLE:
		{
            TbarData = (PCOOL_INDICATOR_CTRL)GetWindowAdditionalData2 (hWnd);
            if (enable_item (TbarData, wParam, lParam))
                return -1;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;
		}
		break;
	default:
		break;
	}

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}