static INT GraphOpen (GRAPH_WINDOW *gw, const char *title, short h, short v, short dh, short dv) { WindowPtr MacWin; GrafPtr myPort; PaletteHandle myPalette; Str255 pstr; MacWin = MAC_WIN(gw); /* read in resources */ if (GetNewCWindow(GRAPH_RSRC_ID,(Ptr) MacWin,(WindowPtr) -1)==NULL) return (1); myPalette = GetNewPalette(PALETTE_RSRC_ID); SetPalette(MacWin,myPalette,FALSE); /* move and size window */ myPort = (GrafPtr) MacWin; SetPort(myPort); MoveWindow(MacWin,h,v,false); SizeWindow(MacWin,dh,dv,false); CopyCStringToPascal(title,pstr); SetWTitle(MacWin,pstr); ShowWindow(MacWin); SelectWindow(MacWin); DrawGrowIcon(MacWin); return (0); }
GBWindow::GBWindow(GBView * contents, short left, short top, bool vis) : showGrowBox(false), //TODO window(nil), view(contents), visible(vis) { Rect bounds; bounds.left = left; bounds.top = top; bounds.right = left + view->PreferredWidth(); bounds.bottom = top + view->PreferredHeight(); Str255 s; ToPascalString(view->Name(), s); view->SetBounds(GBRect(0, 0, view->PreferredWidth(), view->PreferredHeight())); if ( CreateNewWindow(kDocumentWindowClass, view->Resizable() ? kWindowStandardDocumentAttributes : (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute), &bounds, &window) ) throw GBOutOfMemoryError(); SetWTitle(window, s); SetWRefCon(window, (long)this); SetWindowKind(window, kMacWindowKind); view->SetGraphics(&graphics); if ( vis ) ShowWindow(window); }
void Init(void) { Str255 winTitle; OSErr err = noErr; Str255 instMode; Ptr pinstMode; gDone = false; InitManagers(); InitControlsObject(); CleanTemp(); ParseInstall(); gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1); GetIndString( instMode, rTitleStrList, sNSInstTitle); pinstMode = PascalToC(instMode); #if MOZILLA == 0 GetResourcedString(winTitle, rInstList, sNsTitle); #else GetResourcedString(winTitle, rInstList, sMoTitle); #endif SetWTitle( gWPtr, winTitle ); SetWRefCon(gWPtr, kMIWMagic); MakeMenus(); ParseConfig(); InitOptObject(); ShowWelcomeWin(); SetThemeWindowBackground(gWPtr, kThemeBrushDialogBackgroundActive, true); /* Set menu */ InitNewMenu(); }
void setwtitle(WindowRef window, char* title) { char localStr[256] =""; strcpy(localStr,title); my_c2pstr(localStr); SetWTitle(window,(StringPtr)localStr); }
static void mac_config(int midsession) { Session *s; WinInfo *wi; Str255 mactitle; char *str; if (midsession) { s = mac_windowsession(FrontWindow()); } else { s = snew(Session); memset(s, 0, sizeof(*s)); do_defaults(NULL, &s->cfg); s->hasfile = FALSE; s->session_closed = FALSE; } /* Copy the configuration somewhere else in case this is a * * reconfiguration and the user cancels the operation */ s->temp_cfg = s->cfg; if (HAVE_COLOR_QD()) s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1); else s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1); s->ctrlbox = ctrl_new_box(); setup_config_box(s->ctrlbox, midsession, 0, 0); s->settings_ctrls.data = &s->temp_cfg; if (midsession) s->settings_ctrls.end = &mac_enddlg_reconfig; else s->settings_ctrls.end = &mac_enddlg_config; macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls); wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->s = s; wi->mcs = &s->settings_ctrls; wi->wtype = wSettings; wi->update = &macctrl_update; wi->click = &macctrl_click; wi->key = &macctrl_key; wi->activate = &macctrl_activate; wi->adjustmenus = &macctrl_adjustmenus; wi->close = &mac_closedlg; SetWRefCon(s->settings_window, (long)wi); if (midsession) str = dupprintf("%s Reconfiguration", appname); else str = dupprintf("%s Configuration", appname); c2pstrcpy(mactitle, str); sfree(str); SetWTitle(s->settings_window, mactitle); ShowWindow(s->settings_window); }
void Mac_SetCaption(_THIS, const char *title, const char *icon) { /* Don't convert C to P string in place, because it may be read-only */ Str255 ptitle; /* MJS */ ptitle[0] = strlen (title); SDL_memcpy(ptitle+1, title, ptitle[0]); /* MJS */ if (SDL_Window) SetWTitle(SDL_Window, ptitle); /* MJS */ }
void Mac_SetCaption(_THIS, const char *title, const char *icon) { Str255 ptitle; ptitle[0] = strlen (title); SDL_memcpy(ptitle+1, title, ptitle[0]); if (SDL_Window) SetWTitle(SDL_Window, ptitle); }
void screenOpen(char *Title) { FontInfo fontInfo; int n; theWindow = GetNewWindow(screenWindow, nil, (WindowPtr)(-1)); if ((Title != NULL) && (*Title != '\0')) { c2pstr(Title); SetWTitle(theWindow, Title); p2cstr(Title); } ShowWindow(theWindow); SetPort(theWindow); TextFont(monaco); TextSize(9); GetFontInfo(&fontInfo); fontHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading; fontWidth = fontInfo.widMax; scrollRgn = NewRgn(); screenWidth = (theWindow->portRect.right - theWindow->portRect.left - 10) / fontWidth; screenHeight = (theWindow->portRect.bottom - theWindow->portRect.top) / fontHeight; maxPosition = screenHeight * fontHeight; pausePosition = maxPosition - (currentPosition = fontHeight); SetRect(&scrollRect, theWindow->portRect.left, theWindow->portRect.top + fontInfo.descent, theWindow->portRect.right, theWindow->portRect.bottom); SetRect(&pauseRect, theWindow->portRect.left, pausePosition + fontInfo.descent, theWindow->portRect.right, theWindow->portRect.bottom); MoveTo(5, currentPosition); n = (sizeof(char *) + sizeof(short) + screenWidth) * screenHeight; screenLine = (char **)NewPtr(n); screenLength = (short *)&screenLine[screenHeight]; screenImage = (char *)&screenLength[screenHeight]; for (n = 0; n < screenHeight; n++) { screenLine[n] = &screenImage[n * screenWidth]; screenLength[n] = 0; } startLine = endLine = 0; screenOptions = 0; return; }
static int CreateApplicationWindow (AWindowRecord *wr, char *fname, short h, short v, short dh, short dv) { Rect r; GrafPtr myPort; PaletteHandle myPalette; char name[80]; /* init AWindowRecord */ wr->theWindow = (WindowPtr) wr; /* read in resources */ if (GetNewCWindow(appWinId,(Ptr)wr,(WindowPtr) -1)==NULL) { return(1); } myPalette = GetNewPalette(defaultPaletteId); SetPalette(wr->theWindow,myPalette,false); /* move and size window */ myPort = (GrafPtr) wr->theWindow; SetPort(myPort); MoveWindow(wr->theWindow,h,v,false); SizeWindow(wr->theWindow,dh+15,dv+15,false); strcpy(name,fname); SetWTitle(wr->theWindow,c2pstr(name)); ShowWindow(wr->theWindow); SelectWindow(wr->theWindow); DrawGrowIcon(wr->theWindow); r = myPort->portRect; TextFont(kFontIDMonaco); /* get the scroll bars */ wr->vScrollBar = GetNewControl(vScrollBarId,wr->theWindow); wr->hScrollBar = GetNewControl(hScrollBarId,wr->theWindow); /* set correct size of the scroll bars */ MoveControl(wr->vScrollBar,r.right-15,-1); SizeControl(wr->vScrollBar,16,r.bottom-13); SetControlMinimum(wr->vScrollBar,0); SetControlMaximum(wr->vScrollBar,0); SetControlValue(wr->vScrollBar,0); ShowControl(wr->vScrollBar); MoveControl(wr->hScrollBar,-1,r.bottom-15); SizeControl(wr->hScrollBar,r.right-13,16); SetControlMinimum(wr->hScrollBar,0); SetControlMaximum(wr->hScrollBar,0); SetControlValue(wr->hScrollBar,0); ShowControl(wr->hScrollBar); DrawControls(wr->theWindow); SetRect(&(wr->usableRect),0,0,dh,dv); return(0); }
static void Quartz_Deactivate(NewDevDesc *dd) { Str255 Title; char buffer[250]; QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific; int devnum = devNumber((DevDesc *)dd); sprintf(buffer,"Quartz (%d) - Not Active",devnum+1); CopyCStringToPascal(buffer,Title); SetWTitle(xd->window,Title); ShowWindow(xd->window); }
void pause( void ) { EventRecord event; Str255 saveTitle; if( FrontWindow() ) { GetWTitle( FrontWindow(), saveTitle ); SetWTitle( FrontWindow(), "\p(paused)" ); } do { // wait } while( false == WaitNextEvent( mDownMask + keyDownMask, &event, 0, NULL ) ); if( FrontWindow() ) SetWTitle( FrontWindow(), saveTitle ); }
static int DoXOPAlert(short dlogID, const char* title, const char* message) { DialogPtr theDialog; WindowRef theWindow; short hit; unsigned char temp[256]; int result = 0; ArrowCursor(); paramtext(message, "", "", ""); theDialog = GetNewDialog(dlogID, NULL, (WindowPtr)-1L); // This must access Igor's data fork which contains the DLOG resources for these dialogs. if (theDialog == NULL) return -1; theWindow = GetDialogWindow(theDialog); if (theWindow == NULL) return -1; CopyCStringToPascal(title, temp); SetWTitle(theWindow, temp); ShowDialogWindow(theDialog); do { ModalDialog(NULL, &hit); switch(hit) { case 1: // OK or Yes. result = 1; break; case 2: // No or Cancel. if (dlogID == IGOR_OK_CANCEL_DLOG) result = -1; // Cancel result is -1. else result = 2; break; case 3: // Cancel. result = -1; break; } } while(result == 0); DisposeDialog(theDialog); return result; }
void attach_new_endpoint_to_application( struct endpoint_data *endpoint, char *title, NMBoolean system_time) { static long startLeft = 100; static long startTop = 100; WindowPtr wp; char window_title[128]; if(system_time) { Rect boundsRect; boundsRect.left = startLeft; startLeft += 32; boundsRect.right = boundsRect.left + 500; boundsRect.top = startTop; startTop += 32; boundsRect.bottom = boundsRect.top + 300; wp = NewCWindow(nil,&boundsRect,"\pWindow", true, noGrowDocProc,(WindowPtr)-1,false,0); //wp = NewCWind( //wp= GetNewWindow(winDOCUMENT, NULL, (WindowPtr) -1l); op_assert(wp); //add a close box //FIXME: i forgot how to do this on classic =) #ifdef OP_PLATFORM_MAC_CARBON_FLAG ChangeWindowAttributes(wp,kWindowCloseBoxAttribute,0); #endif if(wp) { SetWRefCon(wp, (long) endpoint); strcpy(window_title, title); c2pstr(window_title); SetWTitle(wp, (const unsigned char *) window_title); ShowWindow(wp); new_log(wp); } } else {
static void Quartz_Activate(NewDevDesc *dd) { Str255 Title; char buffer[250]; QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific; int devnum = devNumber((DevDesc *)dd); OSStatus err; sprintf(buffer,"Quartz (%d) - Active",devnum+1); CopyCStringToPascal(buffer,Title); SetWTitle(xd->window,Title); /* We add a property to the Window each time we activate it. We should only make this the first time we open the device. */ err = SetWindowProperty(xd->window,kRAppSignature,'QRTZ',sizeof(int),&devnum); ShowWindow(xd->window); }
DisplayDialog::DisplayDialog(ProfileDoc *dc,RawData *pD,int wn):InputDialog(dc,pD,1) { short iType; Handle iHandle; Handle sHandle; Rect iRect, r,pRect,tRect; UserItemUPP box3D; QDErr error; GDHandle oldGD; GWorldPtr oldGW; RGBColor c,oldbackcolor,oldforecolor; WindowPtr oldP; OSErr err; int32 i,wi,hi; double w,h; short dtp_ids[] = DISPPATCH_IDS; Str255 theString,name; for (i=0; i<NumInputIDS; i++) ids[i] = dtp_ids[i]; WinType = DisplayWindow; WinNum = wn; setDialog(Input_Dialog); GetIndString(theString,Display_Title,1); SetWTitle( dp, theString); // Added by James, 3D the box threeD_box(ids[ThreeDBox]); //playSound(8193); // initialize the big gworld GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect); tRect = iRect; OffsetRect(&tRect,-iRect.left,-iRect.top); error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 ); if (error != 0) { delete this; return; } GetGWorld(&oldGW,&oldGD); SetGWorld(BigGW,nil); // GetBackColor(&oldbackcolor); GetForeColor(&oldforecolor); c.red = 65535; c.green = 65535; c.blue = 65535; RGBBackColor(&c); c.red = 0; c.green = 0; c.blue = 0; RGBForeColor(&c); // EraseRect( &tRect ); SetGWorld(oldGW,oldGD); // RGBBackColor(&oldbackcolor); RGBForeColor(&oldforecolor); // SetPort(oldP); GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect); num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top); top_patch = 0; //init the static members //current_patch = total_patches-1; //current_patch = 0; current_patch = 0; current_strip = 0; current_sheet = 0; _done = 0; _waiting = 0; SetSheetStripText(); current_top = current_patch - 2*num_display_patch/3; current_bottom = current_top + num_display_patch - 1; if (current_top < 0) { current_top = 0; current_bottom = current_top + num_display_patch - 1; } if (current_bottom >= total_patches-1) { current_bottom = total_patches - 1; current_top = current_bottom - num_display_patch + 1; } current_disp = 2*num_display_patch/3; init(); getpatchRGB(); Disable(dp,ids[Redo]); GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect); SetCtlMin((ControlHandle)iHandle,0); SetCtlMax((ControlHandle)iHandle,total_patches-1); // GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &pRect ); // SetIText(iHandle,"\p"); GetDItem ( dp,PatchLabel, &iType, (Handle*)&iHandle, &pRect ); GetIndString(theString,Message_List_ID,Patch_Message); SetIText(iHandle,theString); strcpy((char*)name,pD->desc); ctopstr((char*)name); SetWTitle( dp, name); DrawWindow(); }
int tgetch() { char ch; EventRecord theEvent; Rect cursorRect,box,windowRect; long message,cursorTime,start; MenuHandle theMenu; register short keyCode; short temp; term_info *t; GrafPtr oldPort,oldPort1; static char nextCommand; short aboutBox(); char mButtonDown(); Point mouseLoc; WindowPtr theWindow; void doUpdate(); #define clearKey 0x47 #define ESCAPEkey 0x1B static int see, saw = 0; int eye, cursOff = 100; boolean cursRectInv; /* should be a macflag */ short fInFront = TRUE; t = (term_info *)GetWRefCon(HackWindow); mouseLoc.h = (macflags & fMoveWRTMouse) ? t->tcur_x : (u.ux-1); mouseLoc.v = (macflags & fMoveWRTMouse) ? t->tcur_y : (u.uy+1); cursorRect.left = t->tcur_x * t->charWidth + Screen_Border; cursorRect.right = cursorRect.left + t->charWidth - 1; cursorRect.top = t->height * t->tcur_y + Screen_Border; cursorRect.bottom = cursorRect.top + t->height - 1; cursorTime = GetCaretTime(); box.left = mouseLoc.h * t->charWidth + Screen_Border - 1; box.right = box.left + t->charWidth + 2; box.top = mouseLoc.v * t->height + Screen_Border - 1; box.bottom = box.top + t->height + 2; /* permit use of cursor keys and numeric keypad */ /* does the same translation as in msdos.c but includes cursor keys */ ch = '\0'; /* handle extended command from menu */ if (nextCommand && (macflags & (fExtCmdSeq1 | fExtCmdSeq2 | fExtCmdSeq3))) { if (macflags & fExtCmdSeq1) { ch = '#'; macflags = macflags ^ (fExtCmdSeq1 | fExtCmdSeq2); } else if (macflags & fExtCmdSeq2) { ch = nextCommand; macflags = macflags ^ (fExtCmdSeq2 | fExtCmdSeq3); if (!(macflags & fExtCmdSeq3)) nextCommand = '\0'; } else if (macflags & fExtCmdSeq3) { ch = '\r'; macflags &= ~fExtCmdSeq3; } } GetPort(&oldPort); SetPort(HackWindow); if (!(macflags & fDoNonKeyEvt)) { cursorPos = -1; if (! flags.wantspace) SetCursor(&ARROW_CURSOR); } /* initialize cursor blinking */ message = TickCount() + ((Invisible || (macflags & fMoveWRTMouse)) ? 0L : cursorTime); cursRectInv = FALSE; while (!ch) { (void)WaitNextEvent(everyEvent, &theEvent, (fInFront) ? 0L : 50L, 0L); if ((theEvent.what == keyDown || theEvent.what == autoKey) && (FrontWindow() == HackWindow)) { ch = 0; ObscureCursor(); /* use raw key codes */ keyCode = (LoWord(theEvent.message) & keyCodeMask)>>8; if (keyCode == clearKey) { macflags = macflags ^ fToggleNumPad; SetWTitle(HackWindow, (macflags & fToggleNumPad) ? "\016NetHack [MOVE]" : "\015NetHack [NUM]"); ch = 0; continue; } if ((macflags & fToggleNumPad) && (keyCode>0x40 &&keyCode < 0x5D) || (keyCode > 0x7A && keyCode<0x7F)) { ch = t->keyMap[keyCode-65]; if ((theEvent.modifiers & shiftKey) && (ch)) { ch = (ch == '.') ? ':' : (char)toupper(ch); } if (ch) break; } if (t->system.keyBoardType < 4 && keyCode == 50) { ch = (char)ESCAPEkey; /* ESC */ break; } /* make the command key = control key on all non-adb keyboards Now, LEAVE it this way ! Otherwise you'll render non-us keyboards useless, since here is where "<" and ">" are located */ if ((theEvent.message & 0xFF) == 0x60) { ch = (char)ESCAPEkey; break; } /* This is the way to fix backquote->esc for all macs */ if (theEvent.modifiers & cmdKey) { ch = (char)(theEvent.message & 0x1F); if(ch == ('Q' & 0x1F)) ch = 'Q'; /* For Quit */ break; } if (theEvent.modifiers & optionKey) { for(start = 43; start < 56; start++) { if (t->keyMap[start] == (char)(theEvent.message & 0xFFL)) { ch = t->keyMap[start - 13]; break; } } } /* not a cursor key or from the numeric keypad */ if (!ch) { ch = (char)(theEvent.message & 0xFF); } } else { /* what other events to handle */ switch (theEvent.what) {
void MCStack::realize() { //create window if (!MCnoui && MCModeMakeLocalWindows()) { if ( getextendedstate(ECS_FULLSCREEN) ) { //TS-2008-08-01 : [[Bug 5703 - fullscreen stack prop interacts badly with HideMenuBar]] if (!((MCScreenDC*)MCscreen)->getmenubarhidden()) SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); const MCDisplay *t_display; t_display = MCscreen -> getnearestdisplay(rect); MCRectangle t_workarea, t_viewport; t_workarea = t_display -> workarea; t_viewport = t_display -> viewport ; setrect(t_viewport); } else { if (!((MCScreenDC*)MCscreen)->getmenubarhidden()) SetSystemUIMode(kUIModeNormal, NULL); } Rect wrect; MCScreenDC *psdc = (MCScreenDC *)MCscreen; psdc->MCRect2MacRect(rect, wrect); window = new _Drawable; window->type = DC_WINDOW; window->handle.window = 0; char *tmpname = NULL; const unsigned char *namePascal; if (!isunnamed()) { //set window title to name of stack temporarily. tmpname = strclone(getname_cstring()); //it will be changed by setname() later. namePascal = c2pstr(tmpname); } else namePascal = (unsigned char*)"\p"; loadwindowshape(); window->handle.window = NULL; uint32_t wclass; uint32_t wattributes; getWinstyle(wattributes,wclass); wattributes |= kWindowCompositingAttribute; long testdecorations = WD_TITLE | WD_MENU | WD_CLOSE | WD_MINIMIZE | WD_MAXIMIZE; if (m_window_shape != NULL) { static WindowDefUPP s_window_mask_proc = NULL; if (s_window_mask_proc == NULL) s_window_mask_proc = NewWindowDefUPP(WindowMaskProc); WindowDefSpec t_spec; t_spec . defType = kWindowDefProcPtr; t_spec . u . defProc = s_window_mask_proc; CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window -> handle . window); HIWindowChangeFeatures((WindowPtr)window -> handle . window, 0, kWindowIsOpaque); } else if (((flags & F_DECORATIONS && !(decorations & testdecorations)) || wclass == kPlainWindowClass)) { static WindowDefUPP s_borderless_proc = NULL; if (s_borderless_proc == NULL) s_borderless_proc = NewWindowDefUPP(BorderlessWindowProc); WindowDefSpec t_spec; t_spec . defType = kWindowDefProcPtr; t_spec . u . defProc = s_borderless_proc; if (wclass == kPlainWindowClass) wclass = kUtilityWindowClass; CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window->handle.window); } else CreateNewWindow(wclass, wattributes,&wrect, (WindowPtr *)&window->handle.window); if (wclass == kFloatingWindowClass) ChangeWindowAttributes((WindowPtr)window -> handle . window, kWindowNoAttributes, kWindowHideOnSuspendAttribute); // MW-2009-10-31: Make sure we can collapse any rev window HIWindowChangeFeatures((WindowPtr)window -> handle . window, kWindowCanCollapse, 0); if (window->handle.window == NULL) SetWTitle((WindowPtr)window->handle.window, namePascal); SetWTitle((WindowPtr)window->handle.window, namePascal); setopacity(blendlevel * 255 / 100); SetWRefCon((WindowPtr)window->handle.window, mode); ControlRef t_control; MCRevolutionStackViewCreate(this, &t_control); ControlRef t_root_control; GetRootControl((WindowPtr)window -> handle . window, &t_root_control); HIViewAddSubview(t_root_control, t_control); ShowControl(t_control); if (wclass == kDrawerWindowClass) { Window pwindow = NULL; if (parentwindow != DNULL) pwindow = parentwindow; else if (MCdefaultstackptr && MCdefaultstackptr->getw() != DNULL ) pwindow = MCdefaultstackptr->getw(); if (pwindow && GetWRefCon((WindowPtr)pwindow->handle.window) != WM_DRAWER) { SetDrawerParent((WindowPtr)window->handle.window, (WindowPtr)pwindow->handle.window); WindowAttributes watt; GetWindowAttributes((WindowPtr)pwindow->handle.window,&watt); if (wattributes & kWindowResizableAttribute) ChangeWindowAttributes((WindowPtr)pwindow->handle.window, kWindowLiveResizeAttribute, 0); OptionBits draweredge; switch (wposition) { case WP_PARENTTOP: draweredge = kWindowEdgeTop; break; case WP_PARENTRIGHT: draweredge = kWindowEdgeRight; break; case WP_PARENTBOTTOM: draweredge = kWindowEdgeBottom; break; case WP_PARENTLEFT: draweredge = kWindowEdgeLeft; break; default: draweredge = kWindowEdgeDefault; break; } SetDrawerPreferredEdge((WindowPtr)window->handle.window, draweredge); if (walignment) { MCRectangle parentwindowrect; MCscreen->getwindowgeometry(pwindow, parentwindowrect); int2 wspace = 0; RgnHandle r = NewRgn(); GetWindowRegion((WindowPtr)window->handle.window, kWindowStructureRgn, r); Rect tRect; GetRegionBounds(r, &tRect); DisposeRgn(r); MCRectangle drawerwindowrect; psdc->MacRect2MCRect(tRect, drawerwindowrect); if (wposition == WP_PARENTTOP || wposition == WP_PARENTBOTTOM) { wspace = parentwindowrect.width - drawerwindowrect.width; if (watt & kWindowMetalAttribute) if (wspace) wspace += 10; //for metal } else { wspace = parentwindowrect.height - drawerwindowrect.height; if (watt & kWindowMetalAttribute) if (wspace) wspace += 5; //for metal } if (wspace > 0) switch (walignment) { case OP_CENTER: SetDrawerOffsets ((WindowPtr)window->handle.window,ceil(wspace/2) -1,floor(wspace/2) + 1); break; case OP_RIGHT: case OP_BOTTOM: SetDrawerOffsets ((WindowPtr)window->handle.window,wspace,0); break; case OP_TOP: case OP_LEFT: SetDrawerOffsets ((WindowPtr)window->handle.window,0,wspace); break; } } } } delete tmpname; // MW-2005-11-06: We also need to catch window constraining events so we can flush // the screen geometry cache. EventTypeSpec list[] = { {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassMouse, kEventMouseWheelMoved}, {kEventClassWindow, kEventWindowBoundsChanging}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowConstrain}, {kEventClassWindow, kEventWindowFocusAcquired}, {kEventClassWindow, kEventWindowFocusRelinquish}, {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowClose}, }; EventHandlerRef ref; // MW-2005-09-07: Pass the window handle as user data, otherwise 'takewindow' causes problems InstallWindowEventHandler((WindowPtr)window->handle.window, MCS_weh, sizeof(list) / sizeof(EventTypeSpec), list, (WindowPtr)window -> handle . window, &ref); ChangeWindowAttributes((WindowPtr)window->handle.window, 0, kWindowHideOnFullScreenAttribute); updatemodifiedmark(); } start_externals(); }
bool CSMNativeWindow::init(void) { osx_AllowForeground(); CSMDrawer *pDrawer = this->getParent(); CarbonWindowUnrecPtr pCarbonWindow = OSG::CarbonWindow::create(); AGLPixelFormat pixelFormat = NULL; std::vector<int> pfForm; pfForm.push_back(AGL_RGBA); pfForm.push_back(AGL_DEPTH_SIZE); pfForm.push_back(16); pfForm.push_back(AGL_DOUBLEBUFFER); if(_sfRequestSamples.getValue() > 0) { pfForm.push_back(AGL_SAMPLE_BUFFERS_ARB); pfForm.push_back(1); pfForm.push_back(AGL_SAMPLES_ARB); pfForm.push_back(_sfRequestSamples.getValue()); } if(this->requestStereoVisual() == true) { fprintf(stderr, "Choose stereo format\n"); pfForm.push_back(AGL_STEREO); } pfForm.push_back(AGL_NONE); pixelFormat = aglChoosePixelFormat(NULL, 0, &(pfForm.front())); fprintf(stderr, "Got pf : %p\n", pixelFormat); if(pixelFormat == NULL) { fprintf(stderr, "no RGB visual with depth buffer : :0.0"); exit(0); } _pContext = aglCreateContext(pixelFormat, 0); aglDestroyPixelFormat(pixelFormat); UInt32 uiWidth; UInt32 uiHeight; Int32 iXPos = 0; Int32 iYPos = 0; if(this->getXPos() > 0.f && this->getYPos() > 0.f) { iXPos = Int32(this->getXPos()); iYPos = Int32(this->getYPos()); } if(this->getXSize() >= 1.f) { uiWidth = UInt32(this->getXSize()); } else if(this->getXSize() <= 0.f) { uiWidth = 300; //DisplayWidth(_pDisplay, vi->screen); } else { uiWidth = 300; //UInt32(Real32(DisplayWidth(_pDisplay, vi->screen)) * // this->getXSize()); } if(this->getYSize() >= 1.f) { uiHeight = UInt32(this->getYSize()); } else if(this->getYSize() <= 0.f) { uiHeight = 300; //DisplayHeight(_pDisplay, vi->screen); } else { uiHeight = 300; //UInt32(Real32(DisplayHeight(_pDisplay, vi->screen)) * // this->getYSize()); } WindowAttributes windowAttrs = (kWindowStandardDocumentAttributes | kWindowLiveResizeAttribute | kWindowStandardHandlerAttribute ); Rect contentRect; SetRect(&contentRect, iXPos, iYPos, iXPos + uiWidth, iYPos + uiHeight); CreateNewWindow(kDocumentWindowClass, windowAttrs, &contentRect, &_pLocalWindow); SetWindowTitleWithCFString(_pLocalWindow, CFSTR("OpenSG - CSM")); // Install event handler _pEventHandler = NewEventHandlerUPP(eventHandler); EventTypeSpec eventList[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseDragged }, { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowBoundsChanged } }; InstallWindowEventHandler(_pLocalWindow, _pEventHandler, GetEventTypeCount(eventList), eventList, this, 0); aglSetWindowRef(_pContext, _pLocalWindow); _pCarbWindow = pCarbonWindow; _pCarbWindow->setContext(_pContext); _pCarbWindow->init ( ); _pCarbWindow->resize ( uiWidth, uiHeight); std::string windowName(" OpenSG - CSM - "); _pCarbWindow->activate(); windowName += reinterpret_cast<const char *>(glGetString(GL_VERSION)); windowName += " - "; windowName += reinterpret_cast<const char *>(glGetString(GL_RENDERER)); _pCarbWindow->deactivate(); SetWTitle(_pLocalWindow, reinterpret_cast<const unsigned char *>(windowName.c_str())); // Show window RepositionWindow(_pLocalWindow, 0, kWindowCascadeOnMainScreen); ShowWindow (_pLocalWindow ); if(ComplexSceneManager::the() != NULL) ComplexSceneManager::the()->setMainloop( &CSMNativeWindow::carbonMainLoop); _pWindow = _pCarbWindow; _bRun = true; Inherited::init(); return true; }
int main(int argc, char *argv[]) { AGLPixelFormat format; /* OpenGL pixel format */ WindowPtr window; /* Window */ int winattrs; /* Window attributes */ Str255 title; /* Title of window */ Rect rect; /* Rectangle definition */ EventHandlerUPP handler; /* Event handler */ EventLoopTimerUPP thandler; /* Timer handler */ EventLoopTimerRef timer; /* Timer for animating the window */ ProcessSerialNumber psn; /* Process serial number */ static EventTypeSpec events[] = /* Events we are interested in... */ { { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseDragged }, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowShown }, { kEventClassWindow, kEventWindowHidden }, { kEventClassWindow, kEventWindowActivated }, { kEventClassWindow, kEventWindowDeactivated }, { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowBoundsChanged }, { kCoreEventClass, kAEOpenApplication } }; static GLint attributes[] = /* OpenGL attributes */ { AGL_RGBA, AGL_GREEN_SIZE, 1, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE }; //Set initial values for window const int origWinHeight = 628; const int origWinWidth = 850; const int origWinXOffset = 50; const int origWinYOffset = 50; // Create the window... aglContext = 0; WindowVisible = 0; SetRect(&rect, origWinXOffset, origWinYOffset, origWinWidth, origWinHeight); winattrs = kWindowStandardHandlerAttribute | kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute | kWindowLiveResizeAttribute; winattrs &= GetAvailableWindowAttributes(kDocumentWindowClass); strcpy((char *)(title + 1), "Rigid Body Dynamics"); title[0] = strlen((char *)(title + 1)); CreateNewWindow(kDocumentWindowClass, winattrs, &rect, &window); SetWTitle(window, title); handler = NewEventHandlerUPP(EventHandler); InstallWindowEventHandler(window, handler, sizeof(events) / sizeof(events[0]), events, NULL, 0L); thandler = NewEventLoopTimerUPP((void (*)(EventLoopTimerRef, void *))IdleFunc); InstallEventLoopTimer(GetMainEventLoop(), 0, 0, thandler, 0, &timer); GetCurrentProcess(&psn); SetFrontProcess(&psn); DrawGrowIcon(window); ShowWindow(window); // Create the OpenGL context and bind it to the window... format = aglChoosePixelFormat(NULL, 0, attributes); aglContext = aglCreateContext(format, NULL); aglSetCurrentContext(aglContext); if (aglContext == NULL) { printf("Unable to create OpenGL context.\n"); return 1; } aglDestroyPixelFormat(format); aglSetDrawable(aglContext, GetWindowPort(window)); // Set the initial size of the cube altEngine.init((void *)&window, (void *)&aglContext); altEngine.resize(origWinWidth - origWinXOffset, origWinHeight - origWinYOffset); for (;;) { if (WindowVisible) SetEventLoopTimerNextFireTime(timer, 0.05); RunApplicationEventLoop(); if (WindowVisible) { altEngine.step(); //render frame, must pass a message to event handler altEngine.render(); } } }
void NCarbonWindowManager::SetWindowCaption(NWindow* window, const NString & sNewCaption) { WindowRef macWindow = GetMacWindowFromNWindow(window); SetWTitle(macWindow, sNewCaption.AsPString()); }
LPSTR create_gensetup (HWND hwnd, LPCSTR dsn, LPCSTR attrs, BOOL add, BOOL *verify_conn) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; TGENSETUP gensetup_t; ControlID controlID; WindowRef wgensetup; ControlRef control; EventRecord event; IBNibRef nibRef; OSStatus err; char msg[1024]; gensetup_t.verify_conn = true; /* Search the bundle for a .nib file named 'odbcadmin'. */ /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier ( CFSTR ("org.iodbc.adm")), CFSTR ("gensetup"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wgensetup); DisposeNibReference (nibRef); /* Set the title with the DSN */ if (dsn) { msg[0] = STRLEN ("Setup of ") + STRLEN(dsn); sprintf (msg+1, "Setup of %s", (char*)dsn); SetWTitle (wgensetup, msg); } /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSDSN_CNTL, wgensetup, gensetup_t.dsn_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVERIFYCONN_CNTL, wgensetup, gensetup_t.verify_conn_cb); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSLIST_CNTL, wgensetup, gensetup_t.key_list); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSKEYWORD_CNTL, wgensetup, gensetup_t.key_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVALUE_CNTL, wgensetup, gensetup_t.value_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSUPDATE_CNTL, wgensetup, gensetup_t.bupdate); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSADD_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_add_clicked), 1, &controlSpec, &gensetup_t, NULL); InstallEventHandler (GetControlEventTarget (gensetup_t.bupdate), NewEventHandlerUPP (gensetup_update_clicked), 1, &controlSpec, &gensetup_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSOK_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_ok_clicked), 1, &controlSpec, &gensetup_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSCANCEL_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_cancel_clicked), 1, &controlSpec, &gensetup_t, NULL); /* Parse the attributes line */ gensetup_t.mainwnd = wgensetup; parse_attribute_line (&gensetup_t, dsn, attrs, add); AdvanceKeyboardFocus (wgensetup); /* Show the window and run the loop */ DeactivateControl (gensetup_t.bupdate); DSNSETUP = &gensetup_t; ShowWindow (wgensetup); /* The main loop */ while (gensetup_t.mainwnd) { switch (WaitNextEvent (everyEvent, &event, 60L, cursorRgn)) { }; } *verify_conn = gensetup_t.verify_conn; } else goto error; return gensetup_t.connstr; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return gensetup_t.connstr; }
void create_login (HWND hwnd, LPCSTR username, LPCSTR password, LPCSTR dsn, TLOGIN * log_t) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; WindowRef wlogin; ControlRef control; ControlID controlID; EventRecord event; IBNibRef nibRef; OSStatus err; char msg[1024]; if (hwnd == NULL) return; /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.drvproxy")), CFSTR ("login"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wlogin); DisposeNibReference (nibRef); /* Set the title with the DSN */ if (dsn) { msg[0] = STRLEN ("Login for ") + STRLEN(dsn); sprintf (msg+1, "Login for %s", (char*)dsn); SetWTitle (wlogin, msg); } /* Set the control into the structure */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBUSER_CNTL, wlogin, log_t->username); GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBPASS_CNTL, wlogin, log_t->password); log_t->user = log_t->pwd = NULL; log_t->mainwnd = wlogin; /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBOK_CNTL, wlogin, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (login_ok_clicked), 1, &controlSpec, log_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBCANCEL_CNTL, wlogin, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (login_cancel_clicked), 1, &controlSpec, log_t, NULL); SetControlData (log_t->username, 0, kControlEditTextTextTag, username ? STRLEN (username) : STRLEN(""), (UInt8 *) username ? username : ""); SetControlData (log_t->password, 0, kControlEditTextPasswordTag, password ? STRLEN (password) : STRLEN(""), (UInt8 *) password ? password : ""); /* Show the window and run the loop */ AdvanceKeyboardFocus (wlogin); ShowWindow (wlogin); /* The main loop */ while (log_t->mainwnd) { switch (WaitNextEvent (everyEvent, &event, 60L, cursorRgn)) { }; } } else goto error; return; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return; }
static Rboolean Quartz_Open(NewDevDesc *dd, QuartzDesc *xd, char *dsp, double wid, double hgt, int bg) { OSStatus err; WindowRef devWindow = NULL; Rect devBounds, mainRect; Str255 Title; char buffer[250]; int devnum = devNumber((DevDesc *)dd); xd->windowWidth = wid*72; xd->windowHeight = hgt*72; xd->window = NULL; xd->context = NULL; xd->auxcontext = NULL; xd->bg = dd->startfill = bg; /* 0xffffffff; transparent */ dd->startcol = R_RGB(0, 0, 0); /* Create a new window with the specified size */ SetRect(&devBounds, 0, 0, xd->windowWidth, xd->windowHeight ) ; err = CreateNewWindow( kDocumentWindowClass, kWindowStandardHandlerAttribute|kWindowVerticalZoomAttribute | kWindowCollapseBoxAttribute|kWindowResizableAttribute | kWindowCloseBoxAttribute , & devBounds, & devWindow); SetWindowBounds(devWindow, kWindowContentRgn, &devBounds); mainRect = (*GetMainDevice()) -> gdRect; switch(xd->QuartzPos){ case kQuartzTopRight: /* Top Right */ RepositionWindow (devWindow, NULL, kWindowCascadeOnMainScreen); GetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); devBounds.left = mainRect.right - devBounds.right + 1; devBounds.right = mainRect.right; SetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); break; case kQuartzBottomRight: /* Bottom Right */ GetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); devBounds.left = mainRect.right - devBounds.right + 1; devBounds.right = mainRect.right; devBounds.top = mainRect.bottom - devBounds.bottom + 1; devBounds.bottom = mainRect.bottom; SetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); break; case kQuartzBottomLeft: /* Bottom Left */ GetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); devBounds.top = mainRect.bottom - devBounds.bottom + 1; devBounds.bottom = mainRect.bottom; SetWindowBounds(devWindow, kWindowStructureRgn, &devBounds); break; case kQuartzCenter: /* Center */ RepositionWindow (devWindow, NULL, kWindowCenterOnMainScreen); break; case kQuartzTopLeft: /* TopLeft */ RepositionWindow (devWindow, NULL, kWindowCascadeOnMainScreen); break; default: break; } sprintf(buffer,"Quartz (%d) - Active",devnum+1); CopyCStringToPascal(buffer,Title); SetWTitle(devWindow, Title); ShowWindow(devWindow); err = InstallWindowEventHandler( devWindow, NewEventHandlerUPP(QuartzEventHandler), GetEventTypeCount(QuartzEvents), QuartzEvents, (void *)devWindow, NULL); if(err != noErr) return(0); xd->window = devWindow; xd->color = xd->fill = R_TRANWHITE; xd->resize = false; xd->lineType = 0; xd->lineWidth = 1; return TRUE; }
OSStatus PickMonitor (DisplayIDType *inOutDisplayID, WindowRef parentWindow) { WindowRef theWindow; OSStatus status = noErr; static const ControlID kUserPane = { 'MONI', 1 }; // Fetch the dialog IBNibRef aslNib; CFBundleRef theBundle = CFBundleGetMainBundle(); status = CreateNibReferenceWithCFBundle(theBundle, CFSTR("ASLCore"), &aslNib); status = ::CreateWindowFromNib(aslNib, CFSTR( "Pick Monitor" ), &theWindow ); if (status != noErr) { assert(false); return userCanceledErr; } #if 0 // Put game name in window title. By default the title includes the token <<<kGameName>>>. Str255 windowTitle; GetWTitle(theWindow, windowTitle); FormatPStringWithGameName(windowTitle); SetWTitle(theWindow, windowTitle); #endif // Set up the controls ControlRef monitorPane; GetControlByID( theWindow, &kUserPane, &monitorPane ); assert(monitorPane); SetupPickMonitorPane(monitorPane, *inOutDisplayID); // Create our UPP and install the handler. EventTypeSpec cmdEvent = { kEventClassCommand, kEventCommandProcess }; EventHandlerUPP handler = NewEventHandlerUPP( PickMonitorHandler ); InstallWindowEventHandler( theWindow, handler, 1, &cmdEvent, theWindow, NULL ); // Show the window if (parentWindow) ShowSheetWindow( theWindow, parentWindow ); else ShowWindow( theWindow ); // Now we run modally. We will remain here until the PrefHandler // calls QuitAppModalLoopForWindow if the user clicks OK or // Cancel. RunAppModalLoopForWindow( theWindow ); // OK, we're done. Dispose of our window and our UPP. // We do the UPP last because DisposeWindow can send out // CarbonEvents, and we haven't explicitly removed our // handler. If we disposed the UPP, the Toolbox might try // to call it. That would be bad. TearDownPickMonitorPane(monitorPane); if (parentWindow) HideSheetWindow( theWindow ); DisposeWindow( theWindow ); DisposeEventHandlerUPP( handler ); // Return settings to caller if (sSelectedDevice != 0) { // Read back the controls DMGetDisplayIDByGDevice (sSelectedDevice, &*inOutDisplayID, true); return noErr; } else return userCanceledErr; }
void OpenProxySettings(void) { short itemHit = 999; short itemType; Handle item; Rect itemBox; Str255 itemText, pswdBuf, blindPswdText; DialogPtr psDlg; Boolean bDefault = true; /* show dialog */ psDlg = GetNewDialog(rDlgProxySettg, NULL, (WindowPtr) -1); /* show dialog title, button and lable from install.ini */ GetResourcedString(itemText, rInstList, sProxyDlg); SetWTitle(psDlg, itemText); GetDialogItem(psDlg, rProxyStrOK, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sOKBtn); SetControlTitle((ControlRecord **)item, itemText); SetControlData((ControlRecord **)item, kControlNoPart, kControlPushButtonDefaultTag, sizeof(bDefault),(Ptr) &bDefault); GetDialogItem(psDlg, rProxyStrCancel, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sCancel); SetControlTitle((ControlRecord **)item, itemText); GetDialogItem(psDlg, rProxyStrHostLab, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sProxyHost); SetDialogItemText(item, itemText); GetDialogItem(psDlg, rProxyStrPortLab, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sProxyPort); SetDialogItemText(item, itemText); GetDialogItem(psDlg, rProxyStrUserLab, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sProxyUsername); SetDialogItemText(item, itemText); GetDialogItem(psDlg, rProxyStrPswdLab, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sProxyPassword); SetDialogItemText(item, itemText); /* pre-populate text fields */ if (gControls->opt->proxyHost) { my_c2pstrcpy(gControls->opt->proxyHost, itemText); GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox); SetDialogItemText(item, itemText); } if (gControls->opt->proxyPort) { my_c2pstrcpy(gControls->opt->proxyPort, itemText); GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox); SetDialogItemText(item, itemText); } if (gControls->opt->proxyUsername) { my_c2pstrcpy(gControls->opt->proxyUsername, itemText); GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox); SetDialogItemText(item, itemText); } if (gControls->opt->proxyPassword) { int pswdLen = strlen(gControls->opt->proxyPassword); memset(&blindPswdText[1], '¥', pswdLen); blindPswdText[0] = pswdLen; GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox); SetDialogItemText(item, blindPswdText); } if (gControls->opt->proxyPassword) my_c2pstrcpy(gControls->opt->proxyPassword, pswdBuf); else pswdBuf[0] = 0; do { ModalDialog(NULL, &itemHit); /* special handling for "blind" password field */ if (itemHit == rProxyPswdItem) { GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox); GetDialogItemText(item, itemText); /* char deleted ? */ if (itemText[0] < pswdBuf[0]) { /* truncate password buffer */ pswdBuf[0] = itemText[0]; } else { /* store new char in password buffer */ pswdBuf[itemText[0]] = itemText[itemText[0]]; pswdBuf[0] = itemText[0]; } memset(&blindPswdText[1], '¥', pswdBuf[0]); blindPswdText[0] = itemText[0]; SetDialogItemText(item, blindPswdText); } } while(itemHit != 1 && itemHit != 2); /* if OK was hit then take changed settings */ if (itemHit == 1) { GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox); GetDialogItemText(item, itemText); if (itemText[0] > 0) { if (gControls->opt->proxyHost) free(gControls->opt->proxyHost); gControls->opt->proxyHost = (char *) malloc(itemText[0] + 1); strncpy(gControls->opt->proxyHost, (const char *)&itemText[1], itemText[0]); *(gControls->opt->proxyHost + itemText[0]) = 0; } GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox); GetDialogItemText(item, itemText); if (itemText[0] > 0) { if (gControls->opt->proxyPort) free(gControls->opt->proxyPort); gControls->opt->proxyPort = (char *) malloc(itemText[0] + 1); strncpy(gControls->opt->proxyPort, (const char *)&itemText[1], itemText[0]); *(gControls->opt->proxyPort + itemText[0]) = 0; } GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox); GetDialogItemText(item, itemText); if (itemText[0] > 0) { if (gControls->opt->proxyUsername) free(gControls->opt->proxyUsername); gControls->opt->proxyUsername = (char *) malloc(itemText[0] + 1); strncpy(gControls->opt->proxyUsername, (const char *)&itemText[1], itemText[0]); *(gControls->opt->proxyUsername + itemText[0]) = 0; } if (pswdBuf[0] > 0) { if (gControls->opt->proxyPassword) free(gControls->opt->proxyPassword); gControls->opt->proxyPassword = (char *) malloc(pswdBuf[0] + 1); strncpy(gControls->opt->proxyPassword, (const char *)&pswdBuf[1], pswdBuf[0]); *(gControls->opt->proxyPassword + pswdBuf[0]) = 0; } } DisposeDialog(psDlg); }