comparison os2/dw.c @ 823:fd775ade945f

Implemented dw_clipboard_get_text() and dw_clipboard_set_text() on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 26 Mar 2011 13:38:01 +0000
parents eaaef18d5b21
children c6040726eb92
comparison
equal deleted inserted replaced
822:eaaef18d5b21 823:fd775ade945f
9176 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not 9176 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
9177 * be converted to text. 9177 * be converted to text.
9178 */ 9178 */
9179 char *dw_clipboard_get_text() 9179 char *dw_clipboard_get_text()
9180 { 9180 {
9181 return NULL; 9181 APIRET rc;
9182 char *retbuf = NULL;
9183 ULONG fmtInfo;
9184
9185 WinOpenClipbrd(dwhab);
9186
9187 rc = WinQueryClipbrdFmtInfo(dwhab, CF_TEXT, &fmtInfo);
9188 if (rc) /* Text data in clipboard */
9189 {
9190 PSZ pszClipText = (PSZ)WinQueryClipbrdData(dwhab, CF_TEXT); /* Query data handle */
9191 retbuf = strdup(pszClipText);
9192 }
9193 WinCloseClipbrd(dwhab);
9194 return retbuf;
9182 } 9195 }
9183 9196
9184 /* 9197 /*
9185 * Sets the contents of the default clipboard to the supplied text. 9198 * Sets the contents of the default clipboard to the supplied text.
9186 * INCOMPLETE 9199 * INCOMPLETE
9187 * Parameters: 9200 * Parameters:
9188 * Text. 9201 * Text.
9189 */ 9202 */
9190 void dw_clipboard_set_text( char *str, int len ) 9203 void dw_clipboard_set_text( char *str, int len )
9191 { 9204 {
9192 str = str; 9205 APIRET rc;
9193 len = len; 9206 static PVOID shared;
9207
9208 WinOpenClipbrd(dwhab); /* Open clipboard */
9209 WinEmptyClipbrd(dwhab); /* Empty clipboard */
9210
9211 /* Ok, clipboard wants giveable unnamed shared memory */
9212
9213 shared = NULL;
9214 rc = DosAllocSharedMem(&shared, NULL, len, OBJ_GIVEABLE | PAG_COMMIT | PAG_READ | PAG_WRITE);
9215
9216 if (rc == 0)
9217 {
9218 memcpy(shared, str, len);
9219
9220 WinSetClipbrdData(dwhab, (ULONG)shared, CF_TEXT, CFI_POINTER);
9221 }
9222
9223 WinCloseClipbrd(dwhab); /* Close clipboard */
9194 return; 9224 return;
9195 } 9225 }
9196 9226
9197 /* 9227 /*
9198 * Returns some information about the current operating environment. 9228 * Returns some information about the current operating environment.
10048 * text: The text to be display by the static text widget. 10078 * text: The text to be display by the static text widget.
10049 * id: An ID to be used with dw_window_from_id() or 0L. 10079 * id: An ID to be used with dw_window_from_id() or 0L.
10050 */ 10080 */
10051 HWND API dw_calendar_new(ULONG id) 10081 HWND API dw_calendar_new(ULONG id)
10052 { 10082 {
10053 char *text = "dummy calendar"; 10083 char *text = "dummy calendar";
10054 WindowData *blah = calloc(sizeof(WindowData), 1); 10084 WindowData *blah = calloc(sizeof(WindowData), 1);
10055 HWND tmp = WinCreateWindow(HWND_OBJECT, 10085 HWND tmp = WinCreateWindow(HWND_OBJECT,
10056 WC_STATIC, 10086 WC_STATIC,
10057 text, 10087 text,
10058 WS_VISIBLE | SS_TEXT, 10088 WS_VISIBLE | SS_TEXT,
10059 0,0,2000,1000, 10089 0,0,2000,1000,
10060 NULLHANDLE, 10090 NULLHANDLE,
10061 HWND_TOP, 10091 HWND_TOP,
10062 id, 10092 id,
10063 NULL, 10093 NULL,
10064 NULL); 10094 NULL);
10065 blah->oldproc = WinSubclassWindow(tmp, _textproc); 10095 blah->oldproc = WinSubclassWindow(tmp, _textproc);
10066 WinSetWindowPtr(tmp, QWP_USER, blah); 10096 WinSetWindowPtr(tmp, QWP_USER, blah);
10067 dw_window_set_font(tmp, DefaultFont); 10097 dw_window_set_font(tmp, DefaultFont);
10068 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 10098 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
10069 WinSetWindowText(tmp, text); 10099 WinSetWindowText(tmp, text);
10070 return tmp; 10100 return tmp;
10071 } 10101 }
10072 10102
10073 /* 10103 /*
10074 * The following are stubs 10104 * The following are stubs
10075 */ 10105 */
10076 void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day ) 10106 void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day )
10077 { 10107 {
10078 char tmp[30]; 10108 char tmp[30];
10079 sprintf( tmp, "%4.4d-%2.2d-%2.2d", year, month, day); 10109 sprintf( tmp, "%4.4d-%2.2d-%2.2d", year, month, day);
10080 WinSetWindowText(window, tmp); 10110 WinSetWindowText(window, tmp);
10081 } 10111 }
10082 10112
10083 void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day ) 10113 void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day )
10084 { 10114 {
10085 *year = *month = *day = 0; 10115 window = window;
10086 } 10116 *year = *month = *day = 0;
10117 }