{ // SSEdit_Extensions: // Opens a font selector, returns 0 if cancelled, 1 if OK. Defaults: p1 = fontname, p2 = size, p3 = bold, p4 = italic extension exDialogs bool dlgFontDialog(string, int, bool, bool); // Returns boolean "bold?" of the last selected font if dlgFontDialog was OK'd, otherwise returns the default supplied extension exDialogs bool dlgFontDialogGetBold(); // Returns boolean "italic?" of the last selected font if dlgFontDialog was OK'd, otherwise returns the default supplied extension exDialogs bool dlgFontDialogGetItalic(); // Returns the name of the last selected font if dlgFontDialog was OK'd, otherwise returns the default supplied extension exDialogs string dlgFontDialogGetName(); // Returns the size of the last selected font if dlgFontDialog was OK'd, otherwise returns the default supplied extension exDialogs int dlgFontDialogGetSize(); // Opens a colour selection dialog, returns RGB selected. p1 = default RGB colour as int extension exDialogs int dlgColourDialog(int); // Opens a dialog for text input. p1=title, p2=frame, p3=prompt, p4=default, p5=X, p6=Y, p7=show cancel extension exDialogs bool dlgTextPrompt(string, string, string, string, int, int, bool); // Returns the text last entered into dlgTextPrompt if it was OK'd, otherwise returns blank extension exDialogs string dlgTextPromptGetText(); // Opens a dialog for list item selection. p1=title, p2=frame, p3=prompt, p4=X, p5=Y, p6=show cancel extension exDialogs bool dlgListPrompt(string, string, string, int, int, bool); // Add a string for display in the dlgListPromptDialog list window. p1 = the string to add extension exDialogs void dlgListPromptAddItem(string); // Returns the selected string in dlgListPrompt if it was OK'd, otherwise returns blank extension exDialogs string dlgListPromptGetSelString(); // Reset dlgListPromptDialog list window, remove all strings. Call before each new dialog. extension exDialogs void dlgListPromptReset(); // Displays a messagebox prompt, returns choice. p1=is text, p2=title, p3=flags as dword (see docs) extension exDialogs dword dlgMessageBox(string, string, dword); } font global MyFont; int global FontCol; string global DisplayText; bool global ShowMessageBox; // ************************************************************************************************************ // Called once when the plugin is started. Do one time setup here. // ************************************************************************************************************ function Init() { // This plugin demonstrates how to use the exDialogs extension DLL. When the display panel is clicked on, // it shows a colour selector, a font selector, a string entry dialog and a list selection dialog in // turn. The displayed text is then updated to reflect the changes made. // Start off with some defaults createfont(MyFont, "Arial", 10); FontCol = RGB(255, 255, 255); DisplayText = "Click the panel to start"; ShowMessageBox = True; } // ************************************************************************************************************ // Called when left mouse button is released. Params give X,Y pos of cursor at release. // ************************************************************************************************************ function OnMouseLButtonUp(int iX, int iY) { // First pop up a colour selection dialog and store the chosen colour in FontCol. We also supply // FontCol as the default, so the current colour is selected when the dialog opens. If the // dialog is cancelled, the default colour is returned so no change is made. FontCol = dlgColourDialog(FontCol); // Next pop up a font select dialog. dlgFontDialog returns true if OK was clicked. Here we're // specifying absolute defaults of an Arial 10 point font, but if this was a proper plugin it // would be better to store the current font and supply it as the default selection. if(dlgFontDialog("Arial", 10, False, False) == True) { // When a dlgFontDialog is dismissed, the individual info of the selected font is accessed // like this. Here we're just supplying them directly to createfont, but you can of course // store the values for later use createfont(MyFont, dlgFontDialogGetName(), dlgFontDialogGetSize(), dlgFontDialogGetBold(), dlgFontDialogGetItalic()); } // Next we pop up a prompt for a line of text to display. Param 1 is title of the window, // param 2 is title text of the frame, param 3 is the prompt in the window, param 4 is the default // text to put in the edit box, params 5 & 6 are X,Y position on screen (-1 is "use default"), and // param 7 is a boolean "Show Cancel Button" (True shows, False hides). The function returns // False if the cancel button was clicked if(dlgTextPrompt("The Title", "The Frame", "Enter some text", DisplayText, -1, -1, True) == True) { // To retrieve the text entered into the prompt dialog by the user, call dlgTextPromptGetText() DisplayText = dlgTextPromptGetText(); } // Next we pop up a list of items for the user to select from. Before using a list selection // dialog we must reset the data dlgListPromptReset(); // Next we start adding strings for display dlgListPromptAddItem("list item 1"); dlgListPromptAddItem("list item 2"); dlgListPromptAddItem("list item 3"); // Now the process is the same as a text prompt. Param 1 is title of the window, // param 2 is title text of the frame, param 3 is the prompt in the window, params 4 & 5 are // X,Y position on screen (-1 is "use default"), and param 6 is a boolean // "Show Cancel Button" (True shows, False hides). Note that we don't supply a default here, // so this function is 1 param less than dlgTextPrompt. The function returns // False if the cancel button was clicked if(dlgListPrompt("The Title", "The Frame", "Select an item", -1, -1, True) == True) { // Append the selected string to the display text for demo purposes DisplayText = DisplayText + " " + dlgListPromptGetSelString(); } // Display a text box with a standard message. We're only using a basic style // here, so we can test the return code directly against an integer using // implicit type conversion. SSEdit knows about the defines (MB_YESNO etc) // however if you want you can use the integer constants instead. if(dlgMessageBox("Hello!", "Very important message...", MB_OKCANCEL) == IDOK) { // The user clicked OK to the dialog box. } if(ShowMessageBox == True) { // Now we'll display another message box using extended styles. We'll ask // if the user is happy, and give the option not to show it again. dword res = dlgMessageBox("test", "title", MB_YESNO | MB_DONOTASKAGAIN); // Unlike basic styles (above), we can't just directly test the return code. // This is because the status of the "Don't ask again" checkbox is bitwise OR'd // into the return code. Instead we must test using the bitwise AND operator to // remove the high bytes as follows. First we see whether the user clicked Yes or No if(res & 0x0000000F == IDYES) { // The user clicked "Yes" in the dialog } // Now it's our responsibility to check the "Don't ask again" checkbox state, // and act on it. We test for it in the same way: if(res & MB_DONOTASKAGAIN == MB_DONOTASKAGAIN) { // The user checked the "Don't ask again" checkbox. We should set a boolean // variable here to remember the selection for the future. ShowMessageBox = False; } } redraw(); } // ************************************************************************************************************ // The plugin must draw all output here ONLY. This is the only valid drawing function. // ************************************************************************************************************ function Render() { selectfont(MyFont); setfontcol(MyFont, FontCol); drawtext(DisplayText, 0, 0); }