Ejemplo n.º 1
0
void __fastcall TConfDlg::SelectedBoxDrawItem(TWinControl *Control, int Index,
	TRect &Rect, TOwnerDrawState State)
{
	int Offset = 2;// default offset
    TColor FC,BC,PC;
	TListBox *ListBox = dynamic_cast<TListBox*>(Control);
	TCanvas *Canvas = ListBox->Canvas;
    BC=Canvas->Brush->Color;
    PC=Canvas->Pen->Color;
    FC = Canvas->Font->Color;
    Canvas->Brush->Color=clWindow;
    CHostRef *actHost;
    TFontStyles FS;


    FS = Canvas->Font->Style;
    actHost=(CHostRef *)ListBox->Items->Objects[Index];
    if((*actHost)->ProcData || (*actHost)->Account)
   		Canvas->Font->Style = FS<<fsBold;

	Canvas->Font->Color=clWindowText;
   	if((ListBox->Focused() || RemoveBtn->Focused()) && State.Contains(odSelected)) {
   		Canvas->Brush->Color=Canvas->Font->Color;
        Canvas->Font->Color=clHighlightText;
   	}
   	Canvas->Pen->Color=Canvas->Brush->Color;
   	Canvas->FillRect(Rect);                       // clear the rectangle
   	Canvas->TextOut(Rect.Left + Offset, Rect.Top, ListBox->Items->Strings[Index]);
   	Canvas->Font->Color=FC;
   	Canvas->Brush->Color=BC;
   	Canvas->Pen->Color=PC;
   	Canvas->Font->Style=FS;
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
void __fastcall TConfDlg::HostBoxDrawItem(TWinControl *Control, int Index,
	TRect &Rect, TOwnerDrawState State)
{
	int Offset = 2;// default offset
    TColor FC,BC,PC;
	TListBox *ListBox = dynamic_cast<TListBox*>(Control);
	TCanvas *Canvas = ListBox->Canvas;
    BC=Canvas->Brush->Color;
    PC=Canvas->Pen->Color;
    Canvas->Brush->Color=clWindow;
    HostData *actHost;

	// display the text
   FC=Canvas->Font->Color;
   if(!Servers->Refreshing) {
	   actHost=(*Servers)[ListBox->Items->Strings[Index].c_str()];
	   	if(!(actHost)||!actHost->Alive||!(actHost->State) || !(actHost->State->Valid))
   			Canvas->Font->Color=clRed;
   		else
   			Canvas->Font->Color=clWindowText;
    } else Canvas->Font->Color=clGrayText;

   if((ListBox->Focused() || AddBtn->Focused()) && State.Contains(odSelected)) {
   		Canvas->Brush->Color=Canvas->Font->Color;
        Canvas->Font->Color=clHighlightText;
   }
   Canvas->Pen->Color=Canvas->Brush->Color;
   Canvas->FillRect(Rect);                       // clear the rectangle
   Canvas->TextOut(Rect.Left + Offset, Rect.Top, ListBox->Items->Strings[Index]);
   Canvas->Font->Color=FC;
   Canvas->Brush->Color=BC;
   Canvas->Pen->Color=PC;
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbUnitsDrawItem(
      TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State)
{
    char        *s, *pos;
    int         flags, len;
    TColor      _color;
    TListBox    *lb;
    TCanvas     *canvas;
    String      text, str1, str2;

    lb = (TListBox*)Control;
    canvas = lb->Canvas;
    SaveCanvas(canvas);

    if (Index < lb->Count)
    {
        flags = Control->DrawTextBiDiModeFlags(DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
        if (!Control->UseRightToLeftAlignment())
            Rect.Left += 2;
        else
            Rect.Right -= 2;

        text = lb->Items->Strings[Index];
        //lb->ItemHeight = canvas->TextHeight(text);
        canvas->FillRect(Rect);

        s = text.c_str();
        //*XXXXXXXX #XXX XX NAME
        pos = strrchr(s, ' ');
        len = pos - s;
        str1 = text.SubString(2, len - 1);
        str2 = text.SubString(len + 1, text.Length() - len);

        if (!State.Contains(odSelected))
            _color = TColor(0);        //Black
        else
            _color = TColor(0xBBBBBB); //LightGray
        Rect.Right = Rect.Left;
        DrawOneItem(str1, canvas, Rect, _color, flags);

        //Unit name
        //Trivial unit - red
        if (text[1] & TRIV_UNIT)
        {
            if (!State.Contains(odSelected))
                _color = TColor(0x0000B0); //Red
            else
                _color = TColor(0xBBBBBB); //LightGray
        }
        else
        {
            //User unit - green
            if (text[1] & USER_UNIT)
            {
                if (!State.Contains(odSelected))
                {
                	if (text[1] & UNEXP_UNIT)
                    	_color = TColor(0xC0C0FF); //Light Red
                    else
                    	_color = TColor(0x00B000); //Green
                }
                else
                    _color = TColor(0xBBBBBB); //LightGray
            }
            //From knowledge base - blue
            else
            {
                if (!State.Contains(odSelected))
                    _color = TColor(0xC08000); //Blue
                else
                    _color = TColor(0xBBBBBB); //LightGray
            }
        }
        DrawOneItem(str2, canvas, Rect, _color, flags);
    }
    RestoreCanvas(canvas);
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbUnitItemsDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State)
{
    int         flags;
    TColor      _color;
    TListBox    *lb;
    TCanvas     *canvas;
    String      text, str;

    lb = (TListBox*)Control;
    canvas = lb->Canvas;
    SaveCanvas(canvas);

    if (Index < lb->Count)
    {
        flags = Control->DrawTextBiDiModeFlags(DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
        if (!Control->UseRightToLeftAlignment())
            Rect.Left += 2;
        else
            Rect.Right -= 2;
        canvas->FillRect(Rect);

        text = lb->Items->Strings[Index];
        //lb->ItemHeight = canvas->TextHeight(text);
        str = text.SubString(2, text.Length() - 1);
        //Procs with Xrefs
        if (text[1] & 6)
        {
            //Xrefs from user units
            if (text[1] & 4)
            {
                if (!State.Contains(odSelected))
                    _color = TColor(0x00B000); //Green
                else
                    _color = TColor(0xBBBBBB); //LightGray
            }
            //No Xrefs from user units, only from KB units 
            else
            {
                if (!State.Contains(odSelected))
                    _color = TColor(0xC08000); //Blue
                else
                    _color = TColor(0xBBBBBB); //LightGray
            }
        }
        //Unresolved items
        else if (text[1] & 1)
        {
            if (!State.Contains(odSelected))
                _color = TColor(0x8080FF); //Red
            else
                _color = TColor(0xBBBBBB); //LightGray
        }
        //Other
        else
        {
            if (!State.Contains(odSelected))
                _color = TColor(0);        //Black
            else
                _color = TColor(0xBBBBBB); //LightGray
        }
        Rect.Right = Rect.Left;
        DrawOneItem(str, canvas, Rect, _color, flags);
    }
    RestoreCanvas(canvas);
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------
void __fastcall TMainWindow::NodesBoxDrawItem(TWinControl *Control, int Index,
   TRect &Rect, TOwnerDrawState State)
{
	
    TClientForm *Window;
    CHostRef *ref = NULL;
    HostData *refdata = NULL; //si
   	TColor FC,BC;
    TFontStyles FS;

	long int i = 0;  //si
    bool DoStrikeOut = false; //si

    if (Index >= NodesBox->Items->Count)
     return;
    memcpy(&ref,&i,sizeof(ref));//ref = NULL; is ignored by compiler //si
    memcpy(&refdata,&i,sizeof(refdata));//refdata = NULL; is ignored by compiler  //si
	TListBox *ListBox = dynamic_cast<TListBox*>(Control);
	TCanvas *Canvas = ListBox->Canvas;
   	BC=Canvas->Brush->Color;

   	Canvas->Brush->Color=clWindow;
	// display the text
   	FC=Canvas->Font->Color;
    FS = Canvas->Font->Style;
    ref = (CHostRef*)NodesBox->Items->Objects[Index];
    refdata = (*ref);

    /*Si: memory-access error occured sometimes in original code:
    if(!ref || !(*ref)->ProcData ||
       !(*ref)->ProcData->Executable ||
       !(*ref)->Account) {
       	Canvas->Font->Style = FS<<fsStrikeOut;
        Canvas->Font->Color=clWindowText;
    }   */

    //replace (*ref) with refdata and divide if-expression
    // original fails when *ref==NULL
    if (!ref)
    {
        DoStrikeOut = true;
    }
    else
    {
    	if (! refdata)
        {
           DoStrikeOut = true;
        }
        else
          if(!(refdata->ProcData))  //ERROR refdata invalid!!!
          {
            DoStrikeOut = true;
         	}
    	  else
          {
        	if ((!(refdata->ProcData->Executable)) || (!(refdata->Account)))
            {
            	DoStrikeOut = true;
            }
          }
     }   

    if(DoStrikeOut) {
       	Canvas->Font->Style = FS<<fsStrikeOut; //strike out invalid host
        Canvas->Font->Color=clWindowText;
    }
	else {
    	Window = ref->GetWindow();
   		if(Window) {
			switch(Window->state) {
                case killing: Canvas->Font->Color=clFuchsia; break;
                case running: Canvas->Font->Color=clGreen; break;
       			//case init: Canvas->Font->Color=clOlive; break;  //si
                case init: Canvas->Font->Color=clBlue; break;
       			default: Canvas->Font->Color=clWindowText; break;
     		}
   		} else Canvas->Font->Color=clGrayText;
    }
   	if(State.Contains(odSelected)) {
    	Canvas->Brush->Color=Canvas->Font->Color;
        Canvas->Font->Color=clHighlightText;
   	}

	Canvas->FillRect(Rect);                       // clear the rectangle
   	Canvas->TextOut(Rect.Left + 2, Rect.Top, ListBox->Items->Strings[Index]);
   	Canvas->Font->Color=FC;
   	Canvas->Brush->Color=BC;
    Canvas->Font->Style = FS;
}