wxgraphics.cc

来自「LastWave」· CC 代码 · 共 1,621 行 · 第 1/3 页

CC
1,621
字号
  else if (x != x1 || y != y1) {    ((Frame *) frame)->Move(x,y);  }     if (title) ((Frame *) frame)->SetTitle(ANSI2WXSTRING(title));}FRAME XXGetFrontFrame(void){ return(NULL);}void XXFrontFrame(FRAME frame){  ((Frame *) frame)->Raise();  ((Frame *) frame)->canvas->SetFocus();}void XXErrorFrame(FRAME frame){  ((Frame *) frame)->canvas->dc = NULL;  ((Frame *) frame)->canvas->flagResizeEvent = false;  ((Frame *) frame)->canvas->mouseButton = NoButton;  if (((Frame *) frame)->canvas->HasCapture()) ((Frame *) frame)->canvas->ReleaseMouse();}/********************************************************//*               Event managing                         *//* Return the next event of type EventMask on the queue *//* Return 0 if no event                                 *//* EventMask =          1- BUTTONPRESS - Param : x,y,button     2- REFRESH     - Param : x,y,dx,dy        The parameters corresponds to the area of the	window which has to be refreshed.        This event must take care of the change	of size/position of the window (this is indicated	by dx < 0)     3- KEYPRESS/KEYRELEASE    - Param : key,x,y     4- ENTERWINDOW - no param     5- LEAVEWINDOW - no param   Any combination of those is possible                 *//********************************************************//* Turn the autorepeat on */void XXAutoRepeatOn(void){}/* Turn the autorepeat off */void XXAutoRepeatOff(void){}/* Change the color of the Graphic port */void XXSetColor(FRAME frame, unsigned long pixel){  unsigned char r,g,b;    thePalette->GetRGB(pixel,&r,&g,&b);  theR = r;  theG = g;  theB = b;  thePen.SetColour(r,g,b);  theBrush.SetColour(r,g,b);}/* * Set the current colormap according to the values of red, green and blue.  * Specifies the index of the color of the cursor and of the colors that must * behave 'properly' during a PenInverse mode. * Returns the number of color cells that are used. */int XXSetColormap(unsigned short red[],unsigned short green[],unsigned short blue[],		  unsigned long pixels[],int nCols,int flagSharedColormap, int mouseMode,		  unsigned short mouseRed, unsigned short mouseGreen, unsigned short mouseBlue){  int i;  unsigned char cred[32000];  unsigned char cgreen[32000];  unsigned char cblue[32000];    if (thePalette != NULL) {    delete thePalette;    thePalette = NULL;  }  for (i=0;i<nCols;i++) {    cred[i] = (unsigned char) (red[i]/256);    cblue[i] = (unsigned char) (blue[i]/256);    cgreen[i] = (unsigned char) (green[i]/256);  }    thePalette = new wxPalette(nCols,cred,cgreen,cblue);    for (i=0;i<nCols;i++) {    pixels[i] = thePalette->GetPixel(cred[i],cgreen[i],cblue[i]);  }    return(nCols);}/* * Animate one color of the colormap */void XXAnimateColor(unsigned long pixel, unsigned short r, unsigned short g, unsigned short b){}/* * Returns the number of colors available  */int XXNumOfColors(void){return(65000);}/* * Returns the depth */int XXDepth(void){return(16);}/* * Is the screen BW ? */int XXIsBWScreen(void){return(NO);}/* * Type of the screen */char * XXScreenType(void){  return("wx");}void XXScreenRect(int *x, int *y, int *w, int *h){  *x = 0;  *y = 0;  *w = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);  *h = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);}/* * Get the foreground and background colors of the terminal window  */void XXBgColor(unsigned short *r,unsigned short *g,unsigned short *b){ wxColour col =  wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);  *r = ((int) col.Red())*256; *g = ((int) col.Green())*256; *b = ((int) col.Blue())*256;}void XXFgColor(unsigned short *r,unsigned short *g,unsigned short *b){ wxColour col =  wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);  *r = ((int) col.Red())*256; *g = ((int) col.Green())*256; *b = ((int) col.Blue())*256;}/* Draw a string in the graphic port */void XXDrawString(FRAME frame,int x,int y,char *str, double angle){  wxString s = ANSI2WXSTRING(str);  if (((Frame *) frame)->canvas->dc == NULL) {    wxClientDC dc(((Frame *) frame)->canvas);      dc.SetPen(thePen);    dc.SetBrush(*wxTRANSPARENT_BRUSH);    dc.DestroyClippingRegion();    dc.SetClippingRegion(theClipX,theClipY,theClipW,theClipH);    dc.SetFont(theFont);    int w,h,d,i;    dc.GetTextExtent(s,&w,&h,&d,&i);    if (angle == 0) dc.DrawText(s,x, y-(h-d));    else dc.DrawRotatedText(s,x, y-(h-d),angle);  }  else {    int w,h,d,i;    ((Frame *) frame)->canvas->dc->GetTextExtent(s,&w,&h,&d,&i);    if (angle == 0) ((Frame *) frame)->canvas->dc->DrawText(s,x, y-(h-d));    else ((Frame *) frame)->canvas->dc->DrawRotatedText(s,x, y-(h-d),angle);  }}char *XXGetDefaultFont(FONTID *fontStruct,int *size) {  *size = 10;  return("default");}void XXGetFontInfo(FONT font, int *ascent, int *descent, int *interline){  wxScreenDC dc;      wxString s(_T("gfy|pA\193\198"));  wxFontFamily ff;  char *face = NULL;    if (!strcmp(font->fontName,"default")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"decorative")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"roman")) ff = wxFONTFAMILY_ROMAN;  else if (!strcmp(font->fontName,"script")) ff = wxFONTFAMILY_SCRIPT;  else if (!strcmp(font->fontName,"swiss")) ff = wxFONTFAMILY_SWISS;  else if (!strcmp(font->fontName,"modern")) ff = wxFONTFAMILY_MODERN;  else if (!strcmp(font->fontName,"teletype")) ff = wxFONTFAMILY_TELETYPE;  else {    ff = wxFONTFAMILY_DEFAULT;    face = font->fontName;  }  if (face == NULL) face = "";    int style,weight;    if (font->style == FontPlain) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontItalic) {    style = wxFONTSTYLE_ITALIC;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontBold) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_BOLD;  }    wxFontEncoding fe;  if (font->encoding = FontEncodingDefault) fe = wxFONTENCODING_DEFAULT;  else if (font->encoding = FontEncodingGreek) fe = greekEncoding;    wxFont f(font->size, ff, style, weight,false,ANSI2WXSTRING(face),fe);  wxFont f1 = dc.GetFont();  dc.SetFont(f);    int w,h,d,i;    dc.GetTextExtent(s,&w,&h,&d,&i);    *ascent = h-d;  *descent = d;  *interline = 1;  /*  *ascent = 1;  *descent = 0;  */  dc.SetFont(f1);}int XXGetStringWidth(FONT font, char *text){  wxScreenDC dc;      wxString s = ANSI2WXSTRING(text);  wxFontFamily ff;  char *face = NULL;    if (!strcmp(font->fontName,"default")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"decorative")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"roman")) ff = wxFONTFAMILY_ROMAN;  else if (!strcmp(font->fontName,"script")) ff = wxFONTFAMILY_SCRIPT;  else if (!strcmp(font->fontName,"swiss")) ff = wxFONTFAMILY_SWISS;  else if (!strcmp(font->fontName,"modern")) ff = wxFONTFAMILY_MODERN;  else if (!strcmp(font->fontName,"teletype")) ff = wxFONTFAMILY_TELETYPE;  else {    ff = wxFONTFAMILY_DEFAULT;    face = font->fontName;  }  if (face == NULL) face = "";    int style,weight;    if (font->style == FontPlain) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontItalic) {    style = wxFONTSTYLE_ITALIC;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontBold) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_BOLD;  }  wxFontEncoding fe;  if (font->encoding = FontEncodingDefault) fe = wxFONTENCODING_DEFAULT;  else if (font->encoding = FontEncodingGreek) fe = greekEncoding;    wxFont f(font->size, ff, style, weight,false,ANSI2WXSTRING(face),fe);  wxFont f1 = dc.GetFont();  dc.SetFont(f);    int w,h,d,i;    dc.GetTextExtent(s,&w,&h,&d,&i);    return(w);}int XXGetStringHeight(FONT font, char *text){  wxScreenDC dc;    wxString s=ANSI2WXSTRING(text);  wxFontFamily ff;  char *face = NULL;    if (!strcmp(font->fontName,"default")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"decorative")) ff = wxFONTFAMILY_DEFAULT;  else if (!strcmp(font->fontName,"roman")) ff = wxFONTFAMILY_ROMAN;  else if (!strcmp(font->fontName,"script")) ff = wxFONTFAMILY_SCRIPT;  else if (!strcmp(font->fontName,"swiss")) ff = wxFONTFAMILY_SWISS;  else if (!strcmp(font->fontName,"modern")) ff = wxFONTFAMILY_MODERN;  else if (!strcmp(font->fontName,"teletype")) ff = wxFONTFAMILY_TELETYPE;  else {    ff = wxFONTFAMILY_DEFAULT;    face = font->fontName;  }  if (face == NULL) face = "";    int style,weight;    if (font->style == FontPlain) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontItalic) {    style = wxFONTSTYLE_ITALIC;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontBold) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_BOLD;  }    wxFontEncoding fe;  if (font->encoding = FontEncodingDefault) fe = wxFONTENCODING_DEFAULT;  else if (font->encoding = FontEncodingGreek) fe = greekEncoding;    wxFont f(font->size, ff, style, weight,false,ANSI2WXSTRING(face),fe);  wxFont f1 = dc.GetFont();  dc.SetFont(f);    int w,h,d,i;    dc.GetTextExtent(s,&w,&h,&d,&i);    return(h);}// If frame is NULL then set font to the terminalvoid XXSetFont(FRAME frame,FONT font){  wxFontFamily ff;  char *face = NULL;  if (!strcmp(font->fontName,"default")) {    ff = wxFONTFAMILY_DEFAULT;    font->encoding = FontEncodingDefault;  }  else if (!strcmp(font->fontName,"decorative")) ff = wxFONTFAMILY_DECORATIVE;  else if (!strcmp(font->fontName,"roman")) ff = wxFONTFAMILY_ROMAN;  else if (!strcmp(font->fontName,"script")) ff = wxFONTFAMILY_SCRIPT;  else if (!strcmp(font->fontName,"swiss")) ff = wxFONTFAMILY_SWISS;  else if (!strcmp(font->fontName,"modern")) ff = wxFONTFAMILY_MODERN;  else if (!strcmp(font->fontName,"teletype")) ff = wxFONTFAMILY_TELETYPE;  else {    ff = wxFONTFAMILY_DEFAULT;    face = font->fontName;  }  if (face == NULL) face = "";       //  ff = wxFONTFAMILY_TELETYPE;  int style,weight;    if (font->style == FontPlain) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontItalic) {    style = wxFONTSTYLE_ITALIC;    weight = wxFONTWEIGHT_NORMAL;  }  else if (font->style == FontBold) {    style = wxFONTSTYLE_NORMAL;    weight = wxFONTWEIGHT_BOLD;  }  wxFontEncoding fe;  if (font->encoding == FontEncodingDefault) fe = wxFONTENCODING_DEFAULT;  else if (font->encoding == FontEncodingGreek) {fe = greekEncoding;}    wxFont f(font->size, ff, style, weight,false,ANSI2WXSTRING(face),fe);    theFont = f;    if (frame != NULL) {    if (((Frame *) frame)->canvas->dc != NULL) ((Frame *) frame)->canvas->dc->SetFont(theFont);  }  else {    myApp->terminal->textCtrl->SetFont(theFont);  }}// ????void XXFontMatch(char *name, int encoding, char flagFixed, LISTV lv){/*  static char *list[] = {"default","decorative","roman","script","swiss","modern","teletype",NULL};  char **l = list;    while (*l != NULL) {    if (MatchStr(*l,name))  Append2ListvStr(lv,*l);    l++;  }*/    wxFontEnumerator fontEnumerator;    switch (encoding) {    case FontEncodingGreek :       fontEnumerator.EnumerateFacenames(greekEncoding);      break;    case FontEncodingDefault :      fontEnumerator.EnumerateFacenames(wxFONTENCODING_DEFAULT,(flagFixed!=0 ? true : false));      break;    default :       Errorf("XXFontMatch() : Unknown font encoding %d",encoding);  }     // This is a change from wxWidget version 2.6 to 2.8#ifndef __WX26__  int nFacenames = fontEnumerator.GetFacenames().Count();    #else  int nFacenames = fontEnumerator.GetFacenames()->Count();    #endif    wxString facename;  for (int i = 0; i< nFacenames; i++) {    #ifndef __WX26__    facename = fontEnumerator.GetFacenames().Item(i);#else    facename = fontEnumerator.GetFacenames()->Item(i);#endif    if (MatchStr(WXSTRING2ANSI(facename),name)) AppendStr2Listv(lv,WXSTRING2ANSI(facename));  }}// ????char XXExistFont(char *name,int size, unsigned char style, unsigned char encoding, FONTID *fontStruct){  return(YES);}extern "C" {void C_System(char **argv){  char *str;  char **l;  long *bb,c;  int n;  argv = ParseArgv(argv,tWORD,&str,-1);    if (!strcmp(str,"nEvents")) {    NoMoreArgs(argv);    SetResultInt(toplevelCur->nEvents+1);  }  else if (!strcmp(str,"mouse")) {    argv = ParseArgv(argv,tINT,&n,-1);    switch (n) {      case 1 : nbOfButtons = 1; break;      case 2 : nbOfButtons = 2; break;      case 3 : nbOfButtons = 3; break;      default: Errorf("The number of buttons should be 1 or 2 or 3");    }    for (int i = 0;i< 3-nbOfButtons;i++) {      argv = ParseArgv(argv,tLIST,&l,-1);      if (l[0] == NULL) ErrorUsage();      if (!strcmp(l[0],"left")) bb = &leftButton;      else if (!strcmp(l[0],"right")) bb = &rightButton;      else if (!strcmp(l[0],"middle")) bb = &middleButton;      else Errorf("Bad mouse button name '%s'",l[0]);      int j = 1;      if (l[j] == NULL) ErrorUsage();      if (!strcmp(l[j],"opt")) {c = ModOpt; j=2;}      else if (!strcmp(l[1],"meta")) {c = ModMeta; j=2;}      else c = 0;      if (l[j] == NULL) ErrorUsage();      if (l[j+1] != NULL) ErrorUsage();      if (!strcmp(l[j],"right")) c += RightButton;      else if (!strcmp(l[j],"middle")) c += MiddleButton;      else if (!strcmp(l[j],"left")) c += LeftButton;      else ErrorUsage();      *bb = c;    }    NoMoreArgs(argv);  }    }}void XXFlushEvents(){  myApp->Yield(true);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?